| 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/bind.h" | 7 #include "base/bind.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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 int ret = base::subtle::Barrier_AtomicIncrement(&ref_count_, -1); | 57 int ret = base::subtle::Barrier_AtomicIncrement(&ref_count_, -1); |
| 58 if (ret == 0) { | 58 if (ret == 0) { |
| 59 delete this; | 59 delete this; |
| 60 } | 60 } |
| 61 return ret; | 61 return ret; |
| 62 } | 62 } |
| 63 | 63 |
| 64 void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, | 64 void WebRtcAudioDeviceImpl::RenderData(media::AudioBus* audio_bus, |
| 65 int sample_rate, | 65 int sample_rate, |
| 66 int audio_delay_milliseconds, | 66 int audio_delay_milliseconds, |
| 67 uint32_t skipped_frames, |
| 67 base::TimeDelta* current_time) { | 68 base::TimeDelta* current_time) { |
| 68 DCHECK(audio_renderer_thread_checker_.CalledOnValidThread()); | 69 DCHECK(audio_renderer_thread_checker_.CalledOnValidThread()); |
| 69 { | 70 { |
| 70 base::AutoLock auto_lock(lock_); | 71 base::AutoLock auto_lock(lock_); |
| 71 if (!playing_) { | 72 if (!playing_) { |
| 72 // Force silence to AudioBus after stopping playout in case | 73 // Force silence to AudioBus after stopping playout in case |
| 73 // there is lingering audio data in AudioBus. | 74 // there is lingering audio data in AudioBus. |
| 74 audio_bus->Zero(); | 75 audio_bus->Zero(); |
| 75 return; | 76 return; |
| 76 } | 77 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 // De-interleave each channel and convert to 32-bit floating-point | 114 // De-interleave each channel and convert to 32-bit floating-point |
| 114 // with nominal range -1.0 -> +1.0 to match the callback format. | 115 // with nominal range -1.0 -> +1.0 to match the callback format. |
| 115 audio_bus->FromInterleaved(&render_buffer_[0], | 116 audio_bus->FromInterleaved(&render_buffer_[0], |
| 116 audio_bus->frames(), | 117 audio_bus->frames(), |
| 117 bytes_per_sample); | 118 bytes_per_sample); |
| 118 | 119 |
| 119 // Pass the render data to the playout sinks. | 120 // Pass the render data to the playout sinks. |
| 120 base::AutoLock auto_lock(lock_); | 121 base::AutoLock auto_lock(lock_); |
| 121 for (PlayoutDataSinkList::const_iterator it = playout_sinks_.begin(); | 122 for (PlayoutDataSinkList::const_iterator it = playout_sinks_.begin(); |
| 122 it != playout_sinks_.end(); ++it) { | 123 it != playout_sinks_.end(); ++it) { |
| 123 (*it)->OnPlayoutData(audio_bus, sample_rate, audio_delay_milliseconds); | 124 (*it)->OnPlayoutData(audio_bus, sample_rate, audio_delay_milliseconds, |
| 125 skipped_frames); |
| 124 } | 126 } |
| 125 } | 127 } |
| 126 | 128 |
| 127 void WebRtcAudioDeviceImpl::RemoveAudioRenderer(WebRtcAudioRenderer* renderer) { | 129 void WebRtcAudioDeviceImpl::RemoveAudioRenderer(WebRtcAudioRenderer* renderer) { |
| 128 DCHECK(main_thread_checker_.CalledOnValidThread()); | 130 DCHECK(main_thread_checker_.CalledOnValidThread()); |
| 129 base::AutoLock auto_lock(lock_); | 131 base::AutoLock auto_lock(lock_); |
| 130 DCHECK_EQ(renderer, renderer_.get()); | 132 DCHECK_EQ(renderer, renderer_.get()); |
| 131 // Notify the playout sink of the change. | 133 // Notify the playout sink of the change. |
| 132 for (PlayoutDataSinkList::const_iterator it = playout_sinks_.begin(); | 134 for (PlayoutDataSinkList::const_iterator it = playout_sinks_.begin(); |
| 133 it != playout_sinks_.end(); ++it) { | 135 it != playout_sinks_.end(); ++it) { |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 509 // If there is no capturer or there are more than one open capture devices, | 511 // If there is no capturer or there are more than one open capture devices, |
| 510 // return false. | 512 // return false. |
| 511 if (capturers_.size() != 1) | 513 if (capturers_.size() != 1) |
| 512 return false; | 514 return false; |
| 513 | 515 |
| 514 return capturers_.back()->GetPairedOutputParameters( | 516 return capturers_.back()->GetPairedOutputParameters( |
| 515 session_id, output_sample_rate, output_frames_per_buffer); | 517 session_id, output_sample_rate, output_frames_per_buffer); |
| 516 } | 518 } |
| 517 | 519 |
| 518 } // namespace content | 520 } // namespace content |
| OLD | NEW |