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 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
82 | 82 |
83 // BrowserMessageFilter implementation. | 83 // BrowserMessageFilter implementation. |
84 virtual void OnChannelClosing() OVERRIDE; | 84 virtual void OnChannelClosing() OVERRIDE; |
85 virtual void OnDestruct() const OVERRIDE; | 85 virtual void OnDestruct() const OVERRIDE; |
86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 86 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
87 | 87 |
88 // Returns true if any streams managed by this host are actively playing. Can | 88 // Returns true if any streams managed by this host are actively playing. Can |
89 // be called from any thread. | 89 // be called from any thread. |
90 bool HasActiveAudio(); | 90 bool HasActiveAudio(); |
91 | 91 |
92 // Returns true if any streams managed by the RenderView identified by | |
93 // |render_view_id| are actively playing. Can be called from any thread. | |
94 bool RenderViewHasActiveAudio(int render_view_id); | |
DaleCurtis
2014/09/30 17:15:15
const
aiolos (Not reviewing)
2014/09/30 18:15:13
Done.
| |
95 | |
92 private: | 96 private: |
93 friend class AudioRendererHostTest; | 97 friend class AudioRendererHostTest; |
94 friend class BrowserThread; | 98 friend class BrowserThread; |
95 friend class base::DeleteHelper<AudioRendererHost>; | 99 friend class base::DeleteHelper<AudioRendererHost>; |
96 friend class MockAudioRendererHost; | 100 friend class MockAudioRendererHost; |
97 friend class TestAudioRendererHost; | 101 friend class TestAudioRendererHost; |
98 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); | 102 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); |
99 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); | 103 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, MockStreamDataConversation); |
100 | 104 |
101 class AudioEntry; | 105 class AudioEntry; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
150 // AudioOutputController after it has closed. | 154 // AudioOutputController after it has closed. |
151 void DeleteEntry(scoped_ptr<AudioEntry> entry); | 155 void DeleteEntry(scoped_ptr<AudioEntry> entry); |
152 | 156 |
153 // Send an error message to the renderer, then close the stream. | 157 // Send an error message to the renderer, then close the stream. |
154 void ReportErrorAndClose(int stream_id); | 158 void ReportErrorAndClose(int stream_id); |
155 | 159 |
156 // A helper method to look up a AudioEntry identified by |stream_id|. | 160 // A helper method to look up a AudioEntry identified by |stream_id|. |
157 // Returns NULL if not found. | 161 // Returns NULL if not found. |
158 AudioEntry* LookupById(int stream_id); | 162 AudioEntry* LookupById(int stream_id); |
159 | 163 |
164 // A helper method to update the number of playing streams and alert the | |
165 // ResourceScheduler when the renderer starts or stops playing an audiostream. | |
166 void UpdateNumPlayingStreams(AudioEntry* entry, bool is_playing); | |
167 | |
160 // ID of the RenderProcessHost that owns this instance. | 168 // ID of the RenderProcessHost that owns this instance. |
161 const int render_process_id_; | 169 const int render_process_id_; |
162 | 170 |
163 media::AudioManager* const audio_manager_; | 171 media::AudioManager* const audio_manager_; |
164 AudioMirroringManager* const mirroring_manager_; | 172 AudioMirroringManager* const mirroring_manager_; |
165 scoped_ptr<media::AudioLog> audio_log_; | 173 scoped_ptr<media::AudioLog> audio_log_; |
166 | 174 |
167 // Used to access to AudioInputDeviceManager. | 175 // Used to access to AudioInputDeviceManager. |
168 MediaStreamManager* media_stream_manager_; | 176 MediaStreamManager* media_stream_manager_; |
169 | 177 |
170 // A map of stream IDs to audio sources. | 178 // A map of stream IDs to audio sources. |
171 AudioEntryMap audio_entries_; | 179 AudioEntryMap audio_entries_; |
172 | 180 |
173 // The number of streams in the playing state. | 181 // The number of streams in the playing state. |
174 base::AtomicRefCount num_playing_streams_; | 182 base::AtomicRefCount num_playing_streams_; |
175 | 183 |
176 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); | 184 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); |
177 }; | 185 }; |
178 | 186 |
179 } // namespace content | 187 } // namespace content |
180 | 188 |
181 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ | 189 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ |
OLD | NEW |