OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 // | 4 // |
5 // AudioRendererHost serves audio related requests from AudioRenderer which | 5 // AudioRendererHost serves audio related requests from AudioRenderer which |
6 // lives inside the render process and provide access to audio hardware. | 6 // lives inside the render process and provide access to audio hardware. |
7 // | 7 // |
8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI | 8 // This class is owned by BrowserRenderProcessHost, and instantiated on UI |
9 // thread, but all other operations and method calls happen on IO thread, so we | 9 // thread, but all other operations and method calls happen on IO thread, so we |
10 // need to be extra careful about the lifetime of this object. AudioManager is a | 10 // need to be extra careful about the lifetime of this object. AudioManager is a |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 53 #define CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
54 #pragma once | 54 #pragma once |
55 | 55 |
56 #include <map> | 56 #include <map> |
57 | 57 |
58 #include "base/gtest_prod_util.h" | 58 #include "base/gtest_prod_util.h" |
59 #include "base/process.h" | 59 #include "base/process.h" |
60 #include "base/ref_counted.h" | 60 #include "base/ref_counted.h" |
61 #include "base/scoped_ptr.h" | 61 #include "base/scoped_ptr.h" |
62 #include "base/shared_memory.h" | 62 #include "base/shared_memory.h" |
63 #include "chrome/browser/browser_io_message_filter.h" | 63 #include "chrome/browser/browser_message_filter.h" |
64 #include "chrome/browser/browser_thread.h" | 64 #include "chrome/browser/browser_thread.h" |
65 #include "ipc/ipc_message.h" | 65 #include "ipc/ipc_message.h" |
66 #include "media/audio/audio_io.h" | 66 #include "media/audio/audio_io.h" |
67 #include "media/audio/audio_output_controller.h" | 67 #include "media/audio/audio_output_controller.h" |
68 #include "media/audio/simple_sources.h" | 68 #include "media/audio/simple_sources.h" |
69 | 69 |
70 class AudioManager; | 70 class AudioManager; |
71 struct ViewHostMsg_Audio_CreateStream_Params; | 71 struct ViewHostMsg_Audio_CreateStream_Params; |
72 | 72 |
73 class AudioRendererHost : public BrowserIOMessageFilter, | 73 class AudioRendererHost : public BrowserMessageFilter, |
74 public media::AudioOutputController::EventHandler { | 74 public media::AudioOutputController::EventHandler { |
75 public: | 75 public: |
76 typedef std::pair<int32, int> AudioEntryId; | 76 typedef std::pair<int32, int> AudioEntryId; |
77 | 77 |
78 struct AudioEntry { | 78 struct AudioEntry { |
79 AudioEntry(); | 79 AudioEntry(); |
80 ~AudioEntry(); | 80 ~AudioEntry(); |
81 | 81 |
82 // The AudioOutputController that manages the audio stream. | 82 // The AudioOutputController that manages the audio stream. |
83 scoped_refptr<media::AudioOutputController> controller; | 83 scoped_refptr<media::AudioOutputController> controller; |
(...skipping 16 matching lines...) Expand all Loading... |
100 // Set to true after we called Close() for the controller. | 100 // Set to true after we called Close() for the controller. |
101 bool pending_close; | 101 bool pending_close; |
102 }; | 102 }; |
103 | 103 |
104 typedef std::map<AudioEntryId, AudioEntry*> AudioEntryMap; | 104 typedef std::map<AudioEntryId, AudioEntry*> AudioEntryMap; |
105 | 105 |
106 // Called from UI thread from the owner of this object. | 106 // Called from UI thread from the owner of this object. |
107 AudioRendererHost(); | 107 AudioRendererHost(); |
108 | 108 |
109 | 109 |
110 // BrowserIOMessageFilter implementation | 110 // BrowserMessageFilter implementation. |
111 virtual bool OnMessageReceived(const IPC::Message& message); | |
112 virtual void OnChannelClosing(); | 111 virtual void OnChannelClosing(); |
113 virtual void OnDestruct() const; | 112 virtual void OnDestruct() const; |
| 113 virtual bool OnMessageReceived(const IPC::Message& message, |
| 114 bool* message_was_ok); |
114 | 115 |
115 ///////////////////////////////////////////////////////////////////////////// | 116 ///////////////////////////////////////////////////////////////////////////// |
116 // AudioOutputController::EventHandler implementations. | 117 // AudioOutputController::EventHandler implementations. |
117 virtual void OnCreated(media::AudioOutputController* controller); | 118 virtual void OnCreated(media::AudioOutputController* controller); |
118 virtual void OnPlaying(media::AudioOutputController* controller); | 119 virtual void OnPlaying(media::AudioOutputController* controller); |
119 virtual void OnPaused(media::AudioOutputController* controller); | 120 virtual void OnPaused(media::AudioOutputController* controller); |
120 virtual void OnError(media::AudioOutputController* controller, | 121 virtual void OnError(media::AudioOutputController* controller, |
121 int error_code); | 122 int error_code); |
122 virtual void OnMoreData(media::AudioOutputController* controller, | 123 virtual void OnMoreData(media::AudioOutputController* controller, |
123 AudioBuffersState buffers_state); | 124 AudioBuffersState buffers_state); |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 // event is received. | 214 // event is received. |
214 AudioEntry* LookupByController(media::AudioOutputController* controller); | 215 AudioEntry* LookupByController(media::AudioOutputController* controller); |
215 | 216 |
216 // A map of id to audio sources. | 217 // A map of id to audio sources. |
217 AudioEntryMap audio_entries_; | 218 AudioEntryMap audio_entries_; |
218 | 219 |
219 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 220 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
220 }; | 221 }; |
221 | 222 |
222 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ | 223 #endif // CHROME_BROWSER_RENDERER_HOST_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |