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

Side by Side Diff: content/renderer/media/webrtc_local_audio_renderer.cc

Issue 1122393004: Add support for switching the audio output device for HTMLMediaElements. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes to MediaPlayers so that they invoke callbacks in the correct threads. First complete implem… Created 5 years, 6 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 #include "content/renderer/media/webrtc_local_audio_renderer.h" 5 #include "content/renderer/media/webrtc_local_audio_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/message_loop/message_loop_proxy.h" 8 #include "base/message_loop/message_loop_proxy.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/synchronization/lock.h" 10 #include "base/synchronization/lock.h"
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 } 200 }
201 201
202 // Lazily start the |sink_| when the local renderer is unmuted during 202 // Lazily start the |sink_| when the local renderer is unmuted during
203 // playing. 203 // playing.
204 MaybeStartSink(); 204 MaybeStartSink();
205 205
206 if (sink_.get()) 206 if (sink_.get())
207 sink_->SetVolume(volume); 207 sink_->SetVolume(volume);
208 } 208 }
209 209
210 void WebRtcLocalAudioRenderer::SwitchOutputDevice(
211 const std::string& device_id,
212 const GURL& security_origin,
213 const base::Callback<void(int)>& callback) {
214 DVLOG(1) << "WebRtcLocalAudioRenderer::SwitchOutputDevice("
215 << device_id << ")";
216 DCHECK(message_loop_->BelongsToCurrentThread());
217
218 if (sink_.get())
219 sink_->SwitchOutputDevice(device_id, security_origin, callback);
220 }
221
210 base::TimeDelta WebRtcLocalAudioRenderer::GetCurrentRenderTime() const { 222 base::TimeDelta WebRtcLocalAudioRenderer::GetCurrentRenderTime() const {
211 DCHECK(message_loop_->BelongsToCurrentThread()); 223 DCHECK(message_loop_->BelongsToCurrentThread());
212 base::AutoLock auto_lock(thread_lock_); 224 base::AutoLock auto_lock(thread_lock_);
213 if (!sink_.get()) 225 if (!sink_.get())
214 return base::TimeDelta(); 226 return base::TimeDelta();
215 return total_render_time(); 227 return total_render_time();
216 } 228 }
217 229
218 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const { 230 bool WebRtcLocalAudioRenderer::IsLocalRenderer() const {
219 return true; 231 return true;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 if (sink_started_) { 314 if (sink_started_) {
303 sink_->Stop(); 315 sink_->Stop();
304 sink_started_ = false; 316 sink_started_ = false;
305 } 317 }
306 318
307 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_); 319 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_);
308 MaybeStartSink(); 320 MaybeStartSink();
309 } 321 }
310 322
311 } // namespace content 323 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698