| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/win/windows_version.h" | 9 #include "base/win/windows_version.h" |
| 10 #include "content/renderer/media/audio_hardware.h" | 10 #include "content/renderer/media/audio_hardware.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 samples_per_sec, | 158 samples_per_sec, |
| 159 input_delay_ms_ + output_delay_ms_, | 159 input_delay_ms_ + output_delay_ms_, |
| 160 0, // clock_drift | 160 0, // clock_drift |
| 161 0, // current_mic_level | 161 0, // current_mic_level |
| 162 new_mic_level); // not used | 162 new_mic_level); // not used |
| 163 accumulated_audio_samples += samples_per_10_msec; | 163 accumulated_audio_samples += samples_per_10_msec; |
| 164 audio_byte_buffer += bytes_per_10_msec; | 164 audio_byte_buffer += bytes_per_10_msec; |
| 165 } | 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) { | 168 void WebRtcAudioDeviceImpl::OnDeviceStarted(const std::string& device_id) { |
| 169 DVLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")"; | 169 VLOG(1) << "OnDeviceStarted (device_id=" << device_id << ")"; |
| 170 // -1 is an invalid device index. Do nothing if a valid device has | 170 // Empty string is an invalid device id. Do nothing if a valid device has |
| 171 // been started. Otherwise update the |recording_| state to false. | 171 // been started. Otherwise update the |recording_| state to false. |
| 172 if (device_index != -1) | 172 if (!device_id.empty()) |
| 173 return; | 173 return; |
| 174 | 174 |
| 175 base::AutoLock auto_lock(lock_); | 175 base::AutoLock auto_lock(lock_); |
| 176 if (recording_) | 176 if (recording_) |
| 177 recording_ = false; | 177 recording_ = false; |
| 178 } | 178 } |
| 179 | 179 |
| 180 void WebRtcAudioDeviceImpl::OnDeviceStopped() { | 180 void WebRtcAudioDeviceImpl::OnDeviceStopped() { |
| 181 DVLOG(1) << "OnDeviceStopped"; | 181 DVLOG(1) << "OnDeviceStopped"; |
| 182 base::AutoLock auto_lock(lock_); | 182 base::AutoLock auto_lock(lock_); |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 391 // We do run at 44.1kHz at the actual audio layer, but ask for frames | 391 // We do run at 44.1kHz at the actual audio layer, but ask for frames |
| 392 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. | 392 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. |
| 393 output_buffer_size = 440; | 393 output_buffer_size = 440; |
| 394 } | 394 } |
| 395 // Linux | 395 // Linux |
| 396 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 396 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
| 397 if (output_sample_rate != 48000) { | 397 if (output_sample_rate != 48000) { |
| 398 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; | 398 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; |
| 399 return -1; | 399 return -1; |
| 400 } | 400 } |
| 401 input_channels = 1; | 401 input_channels = 2; |
| 402 output_channels = 1; | 402 output_channels = 1; |
| 403 | 403 |
| 404 // Based on tests using the current ALSA implementation in Chrome, we have | 404 // Based on tests using the current ALSA implementation in Chrome, we have |
| 405 // found that the best combination is 20ms on the input side and 10ms on the | 405 // found that the best combination is 20ms on the input side and 10ms on the |
| 406 // output side. | 406 // output side. |
| 407 // TODO(henrika): It might be possible to reduce the input buffer | 407 // TODO(henrika): It might be possible to reduce the input buffer |
| 408 // size and reduce the delay even more. | 408 // size and reduce the delay even more. |
| 409 input_buffer_size = 2 * 480; | 409 input_buffer_size = 2 * 480; |
| 410 output_buffer_size = 480; | 410 output_buffer_size = 480; |
| 411 #else | 411 #else |
| (...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 } | 965 } |
| 966 | 966 |
| 967 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { | 967 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { |
| 968 NOTIMPLEMENTED(); | 968 NOTIMPLEMENTED(); |
| 969 return -1; | 969 return -1; |
| 970 } | 970 } |
| 971 | 971 |
| 972 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { | 972 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { |
| 973 session_id_ = session_id; | 973 session_id_ = session_id; |
| 974 } | 974 } |
| OLD | NEW |