Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: content/browser/renderer_host/media/audio_renderer_host.h

Issue 2655413004: Strip out stream counting from AudioRendererHost. (Closed)
Patch Set: Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 RenderProcessHostImpl, and instantiated on UI 8 // This class is owned by RenderProcessHostImpl, 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 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
86 // BrowserMessageFilter implementation. 86 // BrowserMessageFilter implementation.
87 void OnChannelClosing() override; 87 void OnChannelClosing() override;
88 void OnDestruct() const override; 88 void OnDestruct() const override;
89 bool OnMessageReceived(const IPC::Message& message) override; 89 bool OnMessageReceived(const IPC::Message& message) override;
90 90
91 // AudioOutputDelegate::EventHandler implementation 91 // AudioOutputDelegate::EventHandler implementation
92 void OnStreamCreated(int stream_id, 92 void OnStreamCreated(int stream_id,
93 base::SharedMemory* shared_memory, 93 base::SharedMemory* shared_memory,
94 base::CancelableSyncSocket* foreign_socket) override; 94 base::CancelableSyncSocket* foreign_socket) override;
95 void OnStreamError(int stream_id) override; 95 void OnStreamError(int stream_id) override;
96 void OnStreamStateChanged(bool is_playing) override;
97
98 // Returns true if any streams managed by this host are actively playing. Can
99 // be called from any thread.
100 bool HasActiveAudio();
101 96
102 void OverrideDevicePermissionsForTesting(bool has_access); 97 void OverrideDevicePermissionsForTesting(bool has_access);
103 98
104 private: 99 private:
105 friend class AudioRendererHostTest; 100 friend class AudioRendererHostTest;
106 friend class BrowserThread; 101 friend class BrowserThread;
107 friend class base::DeleteHelper<AudioRendererHost>; 102 friend class base::DeleteHelper<AudioRendererHost>;
108 friend class MockAudioRendererHost; 103 friend class MockAudioRendererHost;
109 friend class TestAudioRendererHost; 104 friend class TestAudioRendererHost;
110 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream); 105 FRIEND_TEST_ALL_PREFIXES(AudioRendererHostTest, CreateMockStream);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 203
209 media::AudioManager* const audio_manager_; 204 media::AudioManager* const audio_manager_;
210 AudioMirroringManager* const mirroring_manager_; 205 AudioMirroringManager* const mirroring_manager_;
211 206
212 // Used to access to AudioInputDeviceManager. 207 // Used to access to AudioInputDeviceManager.
213 MediaStreamManager* media_stream_manager_; 208 MediaStreamManager* media_stream_manager_;
214 209
215 // A list of the current open streams. 210 // A list of the current open streams.
216 AudioOutputDelegateVector delegates_; 211 AudioOutputDelegateVector delegates_;
217 212
218 // The number of streams in the playing state. Atomic read safe from any
219 // thread, but should only be updated from the IO thread.
220 base::AtomicRefCount num_playing_streams_;
221
222 // Salt required to translate renderer device IDs to raw device unique IDs 213 // Salt required to translate renderer device IDs to raw device unique IDs
223 std::string salt_; 214 std::string salt_;
224 215
225 // Map of device authorizations for streams that are not yet created 216 // Map of device authorizations for streams that are not yet created
226 // The key is the stream ID, and the value is a pair. The pair's first element 217 // The key is the stream ID, and the value is a pair. The pair's first element
227 // is a bool that is true if the authorization process completes successfully. 218 // is a bool that is true if the authorization process completes successfully.
228 // The second element contains the unique ID of the authorized device. 219 // The second element contains the unique ID of the authorized device.
229 std::map<int, std::pair<bool, std::string>> authorizations_; 220 std::map<int, std::pair<bool, std::string>> authorizations_;
230 221
231 // At stream creation time, AudioRendererHost will call this function on the 222 // At stream creation time, AudioRendererHost will call this function on the
232 // UI thread to validate render frame IDs. A default is set by the 223 // UI thread to validate render frame IDs. A default is set by the
233 // constructor, but this can be overridden by unit tests. 224 // constructor, but this can be overridden by unit tests.
234 ValidateRenderFrameIdFunction validate_render_frame_id_function_; 225 ValidateRenderFrameIdFunction validate_render_frame_id_function_;
235 226
236 // The maximum number of simultaneous streams during the lifetime of this
237 // host. Reported as UMA stat at shutdown.
238 size_t max_simultaneous_streams_;
239
240 AudioOutputAuthorizationHandler authorization_handler_; 227 AudioOutputAuthorizationHandler authorization_handler_;
241 228
242 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost); 229 DISALLOW_COPY_AND_ASSIGN(AudioRendererHost);
243 }; 230 };
244 231
245 } // namespace content 232 } // namespace content
246 233
247 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_ 234 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_AUDIO_RENDERER_HOST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698