| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_device_impl.h" | 5 #include "content/renderer/media/webrtc_audio_device_impl.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/metrics/histogram.h" | 8 #include "base/metrics/histogram.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "base/win/windows_version.h" | 10 #include "base/win/windows_version.h" |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 61 | 61 |
| 62 void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, | 62 void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, |
| 63 int sample_rate, | 63 int sample_rate, |
| 64 int audio_delay_milliseconds, | 64 int audio_delay_milliseconds, |
| 65 base::TimeDelta* current_time) { | 65 base::TimeDelta* current_time) { |
| 66 { | 66 { |
| 67 base::AutoLock auto_lock(lock_); | 67 base::AutoLock auto_lock(lock_); |
| 68 #if DCHECK_IS_ON() | 68 #if DCHECK_IS_ON() |
| 69 DCHECK(renderer_->CurrentThreadIsRenderingThread()); | 69 DCHECK(renderer_->CurrentThreadIsRenderingThread()); |
| 70 if (!audio_renderer_thread_checker_.CalledOnValidThread()) { | 70 if (!audio_renderer_thread_checker_.CalledOnValidThread()) { |
| 71 for (const auto& sink : playout_sinks_) | 71 for (auto* sink : playout_sinks_) |
| 72 sink->OnRenderThreadChanged(); | 72 sink->OnRenderThreadChanged(); |
| 73 } | 73 } |
| 74 #endif | 74 #endif |
| 75 if (!playing_) { | 75 if (!playing_) { |
| 76 // Force silence to AudioBus after stopping playout in case | 76 // Force silence to AudioBus after stopping playout in case |
| 77 // there is lingering audio data in AudioBus. | 77 // there is lingering audio data in AudioBus. |
| 78 audio_bus->Zero(); | 78 audio_bus->Zero(); |
| 79 return; | 79 return; |
| 80 } | 80 } |
| 81 DCHECK(audio_transport_callback_); | 81 DCHECK(audio_transport_callback_); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 | 127 |
| 128 renderer_ = NULL; | 128 renderer_ = NULL; |
| 129 } | 129 } |
| 130 | 130 |
| 131 void WebRtcAudioDeviceImpl::AudioRendererThreadStopped() { | 131 void WebRtcAudioDeviceImpl::AudioRendererThreadStopped() { |
| 132 DCHECK(main_thread_checker_.CalledOnValidThread()); | 132 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 133 audio_renderer_thread_checker_.DetachFromThread(); | 133 audio_renderer_thread_checker_.DetachFromThread(); |
| 134 // Notify the playout sink of the change. | 134 // Notify the playout sink of the change. |
| 135 // Not holding |lock_| because the caller must guarantee that the audio | 135 // Not holding |lock_| because the caller must guarantee that the audio |
| 136 // renderer thread is dead, so no race is possible with |playout_sinks_| | 136 // renderer thread is dead, so no race is possible with |playout_sinks_| |
| 137 for (const auto& sink : playout_sinks_) | 137 for (auto* sink : playout_sinks_) |
| 138 sink->OnPlayoutDataSourceChanged(); | 138 sink->OnPlayoutDataSourceChanged(); |
| 139 } | 139 } |
| 140 | 140 |
| 141 int32_t WebRtcAudioDeviceImpl::RegisterAudioCallback( | 141 int32_t WebRtcAudioDeviceImpl::RegisterAudioCallback( |
| 142 webrtc::AudioTransport* audio_callback) { | 142 webrtc::AudioTransport* audio_callback) { |
| 143 DVLOG(1) << "WebRtcAudioDeviceImpl::RegisterAudioCallback()"; | 143 DVLOG(1) << "WebRtcAudioDeviceImpl::RegisterAudioCallback()"; |
| 144 DCHECK(signaling_thread_checker_.CalledOnValidThread()); | 144 DCHECK(signaling_thread_checker_.CalledOnValidThread()); |
| 145 base::AutoLock lock(lock_); | 145 base::AutoLock lock(lock_); |
| 146 DCHECK_EQ(audio_transport_callback_ == NULL, audio_callback != NULL); | 146 DCHECK_EQ(audio_transport_callback_ == NULL, audio_callback != NULL); |
| 147 audio_transport_callback_ = audio_callback; | 147 audio_transport_callback_ = audio_callback; |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 487 | 487 |
| 488 *session_id = device_info.session_id; | 488 *session_id = device_info.session_id; |
| 489 *output_sample_rate = device_info.device.matched_output.sample_rate; | 489 *output_sample_rate = device_info.device.matched_output.sample_rate; |
| 490 *output_frames_per_buffer = | 490 *output_frames_per_buffer = |
| 491 device_info.device.matched_output.frames_per_buffer; | 491 device_info.device.matched_output.frames_per_buffer; |
| 492 | 492 |
| 493 return true; | 493 return true; |
| 494 } | 494 } |
| 495 | 495 |
| 496 } // namespace content | 496 } // namespace content |
| OLD | NEW |