| 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_audio_renderer.h" | 5 #include "content/renderer/media/webrtc_audio_renderer.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 | 295 |
| 296 DCHECK_EQ(state_, PLAYING); | 296 DCHECK_EQ(state_, PLAYING); |
| 297 DCHECK_GT(play_ref_count_, 0); | 297 DCHECK_GT(play_ref_count_, 0); |
| 298 if (!--play_ref_count_) | 298 if (!--play_ref_count_) |
| 299 state_ = PAUSED; | 299 state_ = PAUSED; |
| 300 } | 300 } |
| 301 | 301 |
| 302 void WebRtcAudioRenderer::Stop() { | 302 void WebRtcAudioRenderer::Stop() { |
| 303 DVLOG(1) << "WebRtcAudioRenderer::Stop()"; | 303 DVLOG(1) << "WebRtcAudioRenderer::Stop()"; |
| 304 DCHECK(thread_checker_.CalledOnValidThread()); | 304 DCHECK(thread_checker_.CalledOnValidThread()); |
| 305 // If |max_render_time_| is zero, no render call has been made. | |
| 306 if (!max_render_time_.is_zero()) { | |
| 307 UMA_HISTOGRAM_CUSTOM_COUNTS( | |
| 308 "Media.Audio.Render.GetSourceDataTimeMax.WebRTC", | |
| 309 max_render_time_.InMicroseconds(), kRenderTimeHistogramMinMicroseconds, | |
| 310 kRenderTimeHistogramMaxMicroseconds, 50); | |
| 311 max_render_time_ = base::TimeDelta(); | |
| 312 } | |
| 313 | |
| 314 { | 305 { |
| 315 base::AutoLock auto_lock(lock_); | 306 base::AutoLock auto_lock(lock_); |
| 316 if (state_ == UNINITIALIZED) | 307 if (state_ == UNINITIALIZED) |
| 317 return; | 308 return; |
| 318 | 309 |
| 319 if (--start_ref_count_) | 310 if (--start_ref_count_) |
| 320 return; | 311 return; |
| 321 | 312 |
| 322 DVLOG(1) << "Calling RemoveAudioRenderer and Stop()."; | 313 DVLOG(1) << "Calling RemoveAudioRenderer and Stop()."; |
| 323 | 314 |
| 324 source_->RemoveAudioRenderer(this); | 315 source_->RemoveAudioRenderer(this); |
| 325 source_ = NULL; | 316 source_ = NULL; |
| 326 state_ = UNINITIALIZED; | 317 state_ = UNINITIALIZED; |
| 327 } | 318 } |
| 328 | 319 |
| 320 // Apart from here, |max_render_time_| is only accessed in SourceCallback(), |
| 321 // which is guaranteed to not run after |source_| has been set to null, and |
| 322 // not before this function has returned. |
| 323 // If |max_render_time_| is zero, no render call has been made. |
| 324 if (!max_render_time_.is_zero()) { |
| 325 UMA_HISTOGRAM_CUSTOM_COUNTS( |
| 326 "Media.Audio.Render.GetSourceDataTimeMax.WebRTC", |
| 327 max_render_time_.InMicroseconds(), |
| 328 kRenderTimeHistogramMinMicroseconds, |
| 329 kRenderTimeHistogramMaxMicroseconds, 50); |
| 330 max_render_time_ = base::TimeDelta(); |
| 331 } |
| 332 |
| 329 // Make sure to stop the sink while _not_ holding the lock since the Render() | 333 // Make sure to stop the sink while _not_ holding the lock since the Render() |
| 330 // callback may currently be executing and trying to grab the lock while we're | 334 // callback may currently be executing and trying to grab the lock while we're |
| 331 // stopping the thread on which it runs. | 335 // stopping the thread on which it runs. |
| 332 sink_->Stop(); | 336 sink_->Stop(); |
| 333 } | 337 } |
| 334 | 338 |
| 335 void WebRtcAudioRenderer::SetVolume(float volume) { | 339 void WebRtcAudioRenderer::SetVolume(float volume) { |
| 336 DCHECK(thread_checker_.CalledOnValidThread()); | 340 DCHECK(thread_checker_.CalledOnValidThread()); |
| 337 DCHECK(volume >= 0.0f && volume <= 1.0f); | 341 DCHECK(volume >= 0.0f && volume <= 1.0f); |
| 338 | 342 |
| (...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 661 base::Bind(&WebRtcAudioRenderer::SourceCallback, | 665 base::Bind(&WebRtcAudioRenderer::SourceCallback, |
| 662 base::Unretained(this)))); | 666 base::Unretained(this)))); |
| 663 } | 667 } |
| 664 sink_params_ = new_sink_params; | 668 sink_params_ = new_sink_params; |
| 665 } | 669 } |
| 666 | 670 |
| 667 sink_->Initialize(new_sink_params, this); | 671 sink_->Initialize(new_sink_params, this); |
| 668 } | 672 } |
| 669 | 673 |
| 670 } // namespace content | 674 } // namespace content |
| OLD | NEW |