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 #include "content/browser/renderer_host/media/audio_renderer_host.h" | 5 #include "content/browser/renderer_host/media/audio_renderer_host.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
139 num_playing_streams_(0) { | 139 num_playing_streams_(0) { |
140 DCHECK(audio_manager_); | 140 DCHECK(audio_manager_); |
141 DCHECK(media_stream_manager_); | 141 DCHECK(media_stream_manager_); |
142 } | 142 } |
143 | 143 |
144 AudioRendererHost::~AudioRendererHost() { | 144 AudioRendererHost::~AudioRendererHost() { |
145 DCHECK(audio_entries_.empty()); | 145 DCHECK(audio_entries_.empty()); |
146 } | 146 } |
147 | 147 |
148 void AudioRendererHost::GetOutputControllers( | 148 void AudioRendererHost::GetOutputControllers( |
149 int render_view_id, | 149 const RenderProcessHost::GetAudioOutputControllersCallback& callback) |
150 const RenderViewHost::GetAudioOutputControllersCallback& callback) const { | 150 const { |
jam
2015/01/29 00:19:04
ditto
| |
151 BrowserThread::PostTaskAndReplyWithResult( | 151 BrowserThread::PostTaskAndReplyWithResult( |
152 BrowserThread::IO, | 152 BrowserThread::IO, FROM_HERE, |
153 FROM_HERE, | 153 base::Bind(&AudioRendererHost::DoGetOutputControllers, this), callback); |
154 base::Bind(&AudioRendererHost::DoGetOutputControllers, this, | |
155 render_view_id), | |
156 callback); | |
157 } | 154 } |
158 | 155 |
159 void AudioRendererHost::OnChannelClosing() { | 156 void AudioRendererHost::OnChannelClosing() { |
160 // Since the IPC sender is gone, close all requested audio streams. | 157 // Since the IPC sender is gone, close all requested audio streams. |
161 while (!audio_entries_.empty()) { | 158 while (!audio_entries_.empty()) { |
162 // Note: OnCloseStream() removes the entries from audio_entries_. | 159 // Note: OnCloseStream() removes the entries from audio_entries_. |
163 OnCloseStream(audio_entries_.begin()->first); | 160 OnCloseStream(audio_entries_.begin()->first); |
164 } | 161 } |
165 } | 162 } |
166 | 163 |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
274 entry->stream_id(), | 271 entry->stream_id(), |
275 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, | 272 base::Bind(&media::AudioOutputController::ReadCurrentPowerAndClip, |
276 entry->controller())); | 273 entry->controller())); |
277 } else { | 274 } else { |
278 AudioStreamMonitor::StopMonitoringStream( | 275 AudioStreamMonitor::StopMonitoringStream( |
279 render_process_id_, entry->render_frame_id(), entry->stream_id()); | 276 render_process_id_, entry->render_frame_id(), entry->stream_id()); |
280 } | 277 } |
281 UpdateNumPlayingStreams(entry, is_playing); | 278 UpdateNumPlayingStreams(entry, is_playing); |
282 } | 279 } |
283 | 280 |
284 RenderViewHost::AudioOutputControllerList | 281 RenderProcessHost::AudioOutputControllerList |
285 AudioRendererHost::DoGetOutputControllers(int render_view_id) const { | 282 AudioRendererHost::DoGetOutputControllers() const { |
286 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 283 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
287 | 284 |
288 RenderViewHost::AudioOutputControllerList controllers; | 285 RenderProcessHost::AudioOutputControllerList controllers; |
289 for (AudioEntryMap::const_iterator it = audio_entries_.begin(); | 286 for (AudioEntryMap::const_iterator it = audio_entries_.begin(); |
290 it != audio_entries_.end(); | 287 it != audio_entries_.end(); |
291 ++it) { | 288 ++it) { |
292 AudioEntry* entry = it->second; | 289 controllers.push_back(it->second->controller()); |
293 if (entry->render_view_id() == render_view_id) | |
294 controllers.push_back(entry->controller()); | |
295 } | 290 } |
296 | 291 |
297 return controllers; | 292 return controllers; |
298 } | 293 } |
299 | 294 |
300 /////////////////////////////////////////////////////////////////////////////// | 295 /////////////////////////////////////////////////////////////////////////////// |
301 // IPC Messages handler | 296 // IPC Messages handler |
302 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message) { | 297 bool AudioRendererHost::OnMessageReceived(const IPC::Message& message) { |
303 bool handled = true; | 298 bool handled = true; |
304 IPC_BEGIN_MESSAGE_MAP(AudioRendererHost, message) | 299 IPC_BEGIN_MESSAGE_MAP(AudioRendererHost, message) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
505 it != audio_entries_.end(); | 500 it != audio_entries_.end(); |
506 ++it) { | 501 ++it) { |
507 AudioEntry* entry = it->second; | 502 AudioEntry* entry = it->second; |
508 if (entry->render_view_id() == render_view_id && entry->playing()) | 503 if (entry->render_view_id() == render_view_id && entry->playing()) |
509 return true; | 504 return true; |
510 } | 505 } |
511 return false; | 506 return false; |
512 } | 507 } |
513 | 508 |
514 } // namespace content | 509 } // namespace content |
OLD | NEW |