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/renderer/media/webrtc_local_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_local_audio_renderer.h" |
6 | 6 |
7 #include "base/debug/trace_event.h" | 7 #include "base/debug/trace_event.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop/message_loop_proxy.h" | 9 #include "base/message_loop/message_loop_proxy.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 | 146 |
147 { | 147 { |
148 base::AutoLock auto_lock(thread_lock_); | 148 base::AutoLock auto_lock(thread_lock_); |
149 playing_ = false; | 149 playing_ = false; |
150 loopback_fifo_.reset(); | 150 loopback_fifo_.reset(); |
151 } | 151 } |
152 | 152 |
153 // Stop the output audio stream, i.e, stop asking for data to render. | 153 // Stop the output audio stream, i.e, stop asking for data to render. |
154 // It is safer to call Stop() on the |sink_| to clean up the resources even | 154 // It is safer to call Stop() on the |sink_| to clean up the resources even |
155 // when the |sink_| is never started. | 155 // when the |sink_| is never started. |
156 if (sink_) { | 156 if (sink_.get()) { |
157 sink_->Stop(); | 157 sink_->Stop(); |
158 sink_ = NULL; | 158 sink_ = NULL; |
159 } | 159 } |
160 | 160 |
161 if (!sink_started_) { | 161 if (!sink_started_) { |
162 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates", | 162 UMA_HISTOGRAM_ENUMERATION("Media.LocalRendererSinkStates", |
163 kSinkNeverStarted, kSinkStatesMax); | 163 kSinkNeverStarted, kSinkStatesMax); |
164 } | 164 } |
165 sink_started_ = false; | 165 sink_started_ = false; |
166 | 166 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 // the FIFO overflows. | 309 // the FIFO overflows. |
310 const int blocks_of_buffers = | 310 const int blocks_of_buffers = |
311 10 * params.frames_per_buffer() / sink_params_.frames_per_buffer() + 1; | 311 10 * params.frames_per_buffer() / sink_params_.frames_per_buffer() + 1; |
312 media::AudioBlockFifo* new_fifo = new media::AudioBlockFifo( | 312 media::AudioBlockFifo* new_fifo = new media::AudioBlockFifo( |
313 params.channels(), sink_params_.frames_per_buffer(), blocks_of_buffers); | 313 params.channels(), sink_params_.frames_per_buffer(), blocks_of_buffers); |
314 | 314 |
315 base::AutoLock auto_lock(thread_lock_); | 315 base::AutoLock auto_lock(thread_lock_); |
316 loopback_fifo_.reset(new_fifo); | 316 loopback_fifo_.reset(new_fifo); |
317 } | 317 } |
318 | 318 |
319 if (!sink_) | 319 if (!sink_.get()) |
320 return; // WebRtcLocalAudioRenderer has not yet been started. | 320 return; // WebRtcLocalAudioRenderer has not yet been started. |
321 | 321 |
322 // Stop |sink_| and re-create a new one to be initialized with different audio | 322 // Stop |sink_| and re-create a new one to be initialized with different audio |
323 // parameters. Then, invoke MaybeStartSink() to restart everything again. | 323 // parameters. Then, invoke MaybeStartSink() to restart everything again. |
324 if (sink_started_) { | 324 if (sink_started_) { |
325 sink_->Stop(); | 325 sink_->Stop(); |
326 sink_started_ = false; | 326 sink_started_ = false; |
327 } | 327 } |
328 | 328 |
329 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_view_id_, | 329 sink_ = AudioDeviceFactory::NewOutputDevice(source_render_view_id_, |
330 source_render_frame_id_); | 330 source_render_frame_id_); |
331 MaybeStartSink(); | 331 MaybeStartSink(); |
332 } | 332 } |
333 | 333 |
334 } // namespace content | 334 } // namespace content |
OLD | NEW |