OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 // ownership of the reader. | 83 // ownership of the reader. |
84 scoped_ptr<media::AudioOutputController::SyncReader> reader; | 84 scoped_ptr<media::AudioOutputController::SyncReader> reader; |
85 | 85 |
86 // Set to true after we called Close() for the controller. | 86 // Set to true after we called Close() for the controller. |
87 bool pending_close; | 87 bool pending_close; |
88 }; | 88 }; |
89 | 89 |
90 typedef std::map<int, AudioEntry*> AudioEntryMap; | 90 typedef std::map<int, AudioEntry*> AudioEntryMap; |
91 | 91 |
92 // Called from UI thread from the owner of this object. | 92 // Called from UI thread from the owner of this object. |
93 AudioRendererHost(media::AudioManager* audio_manager, | 93 AudioRendererHost(int render_process_id, |
| 94 media::AudioManager* audio_manager, |
94 content::MediaObserver* media_observer); | 95 content::MediaObserver* media_observer); |
95 | 96 |
96 // content::BrowserMessageFilter implementation. | 97 // content::BrowserMessageFilter implementation. |
97 virtual void OnChannelClosing() OVERRIDE; | 98 virtual void OnChannelClosing() OVERRIDE; |
98 virtual void OnDestruct() const OVERRIDE; | 99 virtual void OnDestruct() const OVERRIDE; |
99 virtual bool OnMessageReceived(const IPC::Message& message, | 100 virtual bool OnMessageReceived(const IPC::Message& message, |
100 bool* message_was_ok) OVERRIDE; | 101 bool* message_was_ok) OVERRIDE; |
101 | 102 |
102 // AudioOutputController::EventHandler implementations. | 103 // AudioOutputController::EventHandler implementations. |
103 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; | 104 virtual void OnCreated(media::AudioOutputController* controller) OVERRIDE; |
(...skipping 11 matching lines...) Expand all Loading... |
115 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); | 116 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
116 | 117 |
117 virtual ~AudioRendererHost(); | 118 virtual ~AudioRendererHost(); |
118 | 119 |
119 // Methods called on IO thread ---------------------------------------------- | 120 // Methods called on IO thread ---------------------------------------------- |
120 | 121 |
121 // Audio related IPC message handlers. | 122 // Audio related IPC message handlers. |
122 // Creates an audio output stream with the specified format. If this call is | 123 // Creates an audio output stream with the specified format. If this call is |
123 // successful this object would keep an internal entry of the stream for the | 124 // successful this object would keep an internal entry of the stream for the |
124 // required properties. | 125 // required properties. |
125 void OnCreateStream(int stream_id, const media::AudioParameters& params); | 126 void OnCreateStream(int render_view_id, |
| 127 int stream_id, |
| 128 const media::AudioParameters& params); |
126 | 129 |
127 // Play the audio stream referenced by |stream_id|. | 130 // Play the audio stream referenced by |stream_id|. |
128 void OnPlayStream(int stream_id); | 131 void OnPlayStream(int stream_id); |
129 | 132 |
130 // Pause the audio stream referenced by |stream_id|. | 133 // Pause the audio stream referenced by |stream_id|. |
131 void OnPauseStream(int stream_id); | 134 void OnPauseStream(int stream_id); |
132 | 135 |
133 // Discard all audio data in stream referenced by |stream_id|. | 136 // Discard all audio data in stream referenced by |stream_id|. |
134 void OnFlushStream(int stream_id); | 137 void OnFlushStream(int stream_id); |
135 | 138 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 | 172 |
170 // A helper method to look up a AudioEntry identified by |stream_id|. | 173 // A helper method to look up a AudioEntry identified by |stream_id|. |
171 // Returns NULL if not found. | 174 // Returns NULL if not found. |
172 AudioEntry* LookupById(int stream_id); | 175 AudioEntry* LookupById(int stream_id); |
173 | 176 |
174 // Search for a AudioEntry having the reference to |controller|. | 177 // Search for a AudioEntry having the reference to |controller|. |
175 // This method is used to look up an AudioEntry after a controller | 178 // This method is used to look up an AudioEntry after a controller |
176 // event is received. | 179 // event is received. |
177 AudioEntry* LookupByController(media::AudioOutputController* controller); | 180 AudioEntry* LookupByController(media::AudioOutputController* controller); |
178 | 181 |
| 182 int render_process_id_; |
| 183 |
179 // A map of stream IDs to audio sources. | 184 // A map of stream IDs to audio sources. |
180 AudioEntryMap audio_entries_; | 185 AudioEntryMap audio_entries_; |
181 | 186 |
182 media::AudioManager* audio_manager_; | 187 media::AudioManager* audio_manager_; |
183 content::MediaObserver* media_observer_; | 188 content::MediaObserver* media_observer_; |
184 | 189 |
185 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 190 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
186 }; | 191 }; |
187 | 192 |
188 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 193 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |