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/common/view_messages.h" | 10 #include "content/common/view_messages.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 samples_per_sec, | 167 samples_per_sec, |
168 input_delay_ms_ + output_delay_ms_, | 168 input_delay_ms_ + output_delay_ms_, |
169 0, // clock_drift | 169 0, // clock_drift |
170 0, // current_mic_level | 170 0, // current_mic_level |
171 new_mic_level); // not used | 171 new_mic_level); // not used |
172 accumulated_audio_samples += samples_per_10_msec; | 172 accumulated_audio_samples += samples_per_10_msec; |
173 audio_byte_buffer += bytes_per_10_msec; | 173 audio_byte_buffer += bytes_per_10_msec; |
174 } | 174 } |
175 } | 175 } |
176 | 176 |
177 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) { | 177 void WebRtcAudioDeviceImpl::OnDeviceStarted(const std::string& device_id) { |
178 DVLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")"; | 178 VLOG(1) << "OnDeviceStarted (device_id=" << device_id << ")"; |
179 // -1 is an invalid device index. Do nothing if a valid device has | 179 // Empty string is an invalid device id. Do nothing if a valid device has |
180 // been started. Otherwise update the |recording_| state to false. | 180 // been started. Otherwise update the |recording_| state to false. |
181 if (device_index != -1) | 181 if (!device_id.empty()) |
182 return; | 182 return; |
183 | 183 |
184 base::AutoLock auto_lock(lock_); | 184 base::AutoLock auto_lock(lock_); |
185 if (recording_) | 185 if (recording_) |
186 recording_ = false; | 186 recording_ = false; |
187 } | 187 } |
188 | 188 |
189 void WebRtcAudioDeviceImpl::OnDeviceStopped() { | 189 void WebRtcAudioDeviceImpl::OnDeviceStopped() { |
190 DVLOG(1) << "OnDeviceStopped"; | 190 DVLOG(1) << "OnDeviceStopped"; |
191 base::AutoLock auto_lock(lock_); | 191 base::AutoLock auto_lock(lock_); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
399 // We do run at 44.1kHz at the actual audio layer, but ask for frames | 399 // We do run at 44.1kHz at the actual audio layer, but ask for frames |
400 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. | 400 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. |
401 output_buffer_size = 440; | 401 output_buffer_size = 440; |
402 } | 402 } |
403 // Linux | 403 // Linux |
404 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 404 #elif defined(OS_LINUX) || defined(OS_OPENBSD) |
405 if (output_sample_rate != 48000) { | 405 if (output_sample_rate != 48000) { |
406 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; | 406 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; |
407 return -1; | 407 return -1; |
408 } | 408 } |
409 input_channels = 1; | 409 input_channels = 2; |
410 output_channels = 1; | 410 output_channels = 1; |
411 | 411 |
412 // Based on tests using the current ALSA implementation in Chrome, we have | 412 // Based on tests using the current ALSA implementation in Chrome, we have |
413 // found that the best combination is 20ms on the input side and 10ms on the | 413 // found that the best combination is 20ms on the input side and 10ms on the |
414 // output side. | 414 // output side. |
415 // TODO(henrika): It might be possible to reduce the input buffer | 415 // TODO(henrika): It might be possible to reduce the input buffer |
416 // size and reduce the delay even more. | 416 // size and reduce the delay even more. |
417 input_buffer_size = 2 * 480; | 417 input_buffer_size = 2 * 480; |
418 output_buffer_size = 480; | 418 output_buffer_size = 480; |
419 #else | 419 #else |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 } | 973 } |
974 | 974 |
975 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { | 975 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { |
976 NOTIMPLEMENTED(); | 976 NOTIMPLEMENTED(); |
977 return -1; | 977 return -1; |
978 } | 978 } |
979 | 979 |
980 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { | 980 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { |
981 session_id_ = session_id; | 981 session_id_ = session_id; |
982 } | 982 } |
OLD | NEW |