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

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

Issue 562273008: Add audio signal to the ResourceScheduler. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase Created 6 years, 2 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 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
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) const;
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
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_
OLDNEW
« no previous file with comments | « content/browser/loader/resource_scheduler_unittest.cc ('k') | content/browser/renderer_host/media/audio_renderer_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698