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

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

Issue 1323403005: Allow AudioOutputDevice objects to be initialized with a specific hardware output device and store … (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Split permissions check and device-ID translation for clarity Created 5 years, 3 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/location.h" 7 #include "base/location.h"
8 #include "base/logging.h" 8 #include "base/logging.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 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 115
116 void WebRtcLocalAudioRenderer::Start() { 116 void WebRtcLocalAudioRenderer::Start() {
117 DVLOG(1) << "WebRtcLocalAudioRenderer::Start()"; 117 DVLOG(1) << "WebRtcLocalAudioRenderer::Start()";
118 DCHECK(task_runner_->BelongsToCurrentThread()); 118 DCHECK(task_runner_->BelongsToCurrentThread());
119 119
120 // We get audio data from |audio_track_|... 120 // We get audio data from |audio_track_|...
121 MediaStreamAudioSink::AddToAudioTrack(this, audio_track_); 121 MediaStreamAudioSink::AddToAudioTrack(this, audio_track_);
122 // ...and |sink_| will get audio data from us. 122 // ...and |sink_| will get audio data from us.
123 DCHECK(!sink_.get()); 123 DCHECK(!sink_.get());
124 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_); 124 sink_ =
125 AudioDeviceFactory::NewOutputDevice(source_render_frame_id_, session_id_);
125 126
126 base::AutoLock auto_lock(thread_lock_); 127 base::AutoLock auto_lock(thread_lock_);
127 last_render_time_ = base::TimeTicks::Now(); 128 last_render_time_ = base::TimeTicks::Now();
128 playing_ = false; 129 playing_ = false;
129 } 130 }
130 131
131 void WebRtcLocalAudioRenderer::Stop() { 132 void WebRtcLocalAudioRenderer::Stop() {
132 DVLOG(1) << "WebRtcLocalAudioRenderer::Stop()"; 133 DVLOG(1) << "WebRtcLocalAudioRenderer::Stop()";
133 DCHECK(task_runner_->BelongsToCurrentThread()); 134 DCHECK(task_runner_->BelongsToCurrentThread());
134 135
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 { 236 {
236 // Clear up the old data in the FIFO. 237 // Clear up the old data in the FIFO.
237 base::AutoLock auto_lock(thread_lock_); 238 base::AutoLock auto_lock(thread_lock_);
238 audio_shifter_->Flush(); 239 audio_shifter_->Flush();
239 } 240 }
240 241
241 if (!sink_params_.IsValid() || !playing_ || !volume_ || sink_started_) 242 if (!sink_params_.IsValid() || !playing_ || !volume_ || sink_started_)
242 return; 243 return;
243 244
244 DVLOG(1) << "WebRtcLocalAudioRenderer::MaybeStartSink() -- Starting sink_."; 245 DVLOG(1) << "WebRtcLocalAudioRenderer::MaybeStartSink() -- Starting sink_.";
245 sink_->InitializeWithSessionId(sink_params_, this, session_id_); 246 sink_->Initialize(sink_params_, this);
246 sink_->Start(); 247 sink_->Start();
247 sink_started_ = true; 248 sink_started_ = true;
248 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates", 249 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates",
249 kSinkStarted, kSinkStatesMax); 250 kSinkStarted, kSinkStatesMax);
250 } 251 }
251 252
252 void WebRtcLocalAudioRenderer::ReconfigureSink( 253 void WebRtcLocalAudioRenderer::ReconfigureSink(
253 const media::AudioParameters& params) { 254 const media::AudioParameters& params) {
254 DCHECK(task_runner_->BelongsToCurrentThread()); 255 DCHECK(task_runner_->BelongsToCurrentThread());
255 256
(...skipping 28 matching lines...) Expand all
284 285
285 base::AutoLock auto_lock(thread_lock_); 286 base::AutoLock auto_lock(thread_lock_);
286 audio_shifter_.reset(new_shifter); 287 audio_shifter_.reset(new_shifter);
287 } 288 }
288 289
289 if (!sink_.get()) 290 if (!sink_.get())
290 return; // WebRtcLocalAudioRenderer has not yet been started. 291 return; // WebRtcLocalAudioRenderer has not yet been started.
291 292
292 // Stop |sink_| and re-create a new one to be initialized with different audio 293 // Stop |sink_| and re-create a new one to be initialized with different audio
293 // parameters. Then, invoke MaybeStartSink() to restart everything again. 294 // parameters. Then, invoke MaybeStartSink() to restart everything again.
294 if (sink_started_) { 295 sink_->Stop();
295 sink_->Stop(); 296 sink_started_ = false;
296 sink_started_ = false;
297 }
298 297
299 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_frame_id_); 298 sink_ =
299 AudioDeviceFactory::NewOutputDevice(source_render_frame_id_, session_id_);
300 MaybeStartSink(); 300 MaybeStartSink();
301 } 301 }
302 302
303 } // namespace content 303 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698