| 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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 } | 43 } |
| 44 | 44 |
| 45 int32_t WebRtcAudioDeviceImpl::Release() { | 45 int32_t WebRtcAudioDeviceImpl::Release() { |
| 46 DCHECK(thread_checker_.CalledOnValidThread()); | 46 DCHECK(thread_checker_.CalledOnValidThread()); |
| 47 int ret = base::subtle::Barrier_AtomicIncrement(&ref_count_, -1); | 47 int ret = base::subtle::Barrier_AtomicIncrement(&ref_count_, -1); |
| 48 if (ret == 0) { | 48 if (ret == 0) { |
| 49 delete this; | 49 delete this; |
| 50 } | 50 } |
| 51 return ret; | 51 return ret; |
| 52 } | 52 } |
| 53 int WebRtcAudioDeviceImpl::CaptureData(const std::vector<int>& channels, | 53 int WebRtcAudioDeviceImpl::OnData(const int16* audio_data, |
| 54 const int16* audio_data, | 54 int sample_rate, |
| 55 int sample_rate, | 55 int number_of_channels, |
| 56 int number_of_channels, | 56 int number_of_frames, |
| 57 int number_of_frames, | 57 const std::vector<int>& channels, |
| 58 int audio_delay_milliseconds, | 58 int audio_delay_milliseconds, |
| 59 int current_volume, | 59 int current_volume, |
| 60 bool need_audio_processing, | 60 bool need_audio_processing, |
| 61 bool key_pressed) { | 61 bool key_pressed) { |
| 62 int total_delay_ms = 0; | 62 int total_delay_ms = 0; |
| 63 { | 63 { |
| 64 base::AutoLock auto_lock(lock_); | 64 base::AutoLock auto_lock(lock_); |
| 65 // Return immediately when not recording or |channels| is empty. | 65 // Return immediately when not recording or |channels| is empty. |
| 66 // See crbug.com/274017: renderer crash dereferencing invalid channels[0]. | 66 // See crbug.com/274017: renderer crash dereferencing invalid channels[0]. |
| 67 if (!recording_ || channels.empty()) | 67 if (!recording_ || channels.empty()) |
| 68 return 0; | 68 return 0; |
| 69 | 69 |
| 70 // Store the reported audio delay locally. | 70 // Store the reported audio delay locally. |
| 71 input_delay_ms_ = audio_delay_milliseconds; | 71 input_delay_ms_ = audio_delay_milliseconds; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 99 audio_buffer += samples_per_10_msec * number_of_channels; | 99 audio_buffer += samples_per_10_msec * number_of_channels; |
| 100 | 100 |
| 101 // The latest non-zero new microphone level will be returned. | 101 // The latest non-zero new microphone level will be returned. |
| 102 if (new_mic_level) | 102 if (new_mic_level) |
| 103 new_volume = new_mic_level; | 103 new_volume = new_mic_level; |
| 104 } | 104 } |
| 105 | 105 |
| 106 return new_volume; | 106 return new_volume; |
| 107 } | 107 } |
| 108 | 108 |
| 109 void WebRtcAudioDeviceImpl::SetCaptureFormat( | 109 void WebRtcAudioDeviceImpl::OnSetFormat( |
| 110 const media::AudioParameters& params) { | 110 const media::AudioParameters& params) { |
| 111 DVLOG(1) << "WebRtcAudioDeviceImpl::SetCaptureFormat()"; | 111 DVLOG(1) << "WebRtcAudioDeviceImpl::OnSetFormat()"; |
| 112 } | 112 } |
| 113 | 113 |
| 114 void WebRtcAudioDeviceImpl::RenderData(uint8* audio_data, | 114 void WebRtcAudioDeviceImpl::RenderData(uint8* audio_data, |
| 115 int number_of_channels, | 115 int number_of_channels, |
| 116 int number_of_frames, | 116 int number_of_frames, |
| 117 int audio_delay_milliseconds) { | 117 int audio_delay_milliseconds) { |
| 118 DCHECK_LE(number_of_frames, output_buffer_size()); | 118 DCHECK_LE(number_of_frames, output_buffer_size()); |
| 119 { | 119 { |
| 120 base::AutoLock auto_lock(lock_); | 120 base::AutoLock auto_lock(lock_); |
| 121 DCHECK(audio_transport_callback_); | 121 DCHECK(audio_transport_callback_); |
| (...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 for (CapturerList::const_iterator iter = capturers_.begin(); | 440 for (CapturerList::const_iterator iter = capturers_.begin(); |
| 441 iter != capturers_.end(); ++iter) { | 441 iter != capturers_.end(); ++iter) { |
| 442 if (!(*iter)->device_id().empty()) | 442 if (!(*iter)->device_id().empty()) |
| 443 return *iter; | 443 return *iter; |
| 444 } | 444 } |
| 445 | 445 |
| 446 return NULL; | 446 return NULL; |
| 447 } | 447 } |
| 448 | 448 |
| 449 } // namespace content | 449 } // namespace content |
| OLD | NEW |