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 "content/common/view_messages.h" | 9 #include "content/common/view_messages.h" |
10 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
166 samples_per_sec, | 166 samples_per_sec, |
167 input_delay_ms_ + output_delay_ms_, | 167 input_delay_ms_ + output_delay_ms_, |
168 0, // clock_drift | 168 0, // clock_drift |
169 0, // current_mic_level | 169 0, // current_mic_level |
170 new_mic_level); // not used | 170 new_mic_level); // not used |
171 accumulated_audio_samples += samples_per_10_msec; | 171 accumulated_audio_samples += samples_per_10_msec; |
172 audio_byte_buffer += bytes_per_10_msec; | 172 audio_byte_buffer += bytes_per_10_msec; |
173 } | 173 } |
174 } | 174 } |
175 | 175 |
176 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) { | 176 void WebRtcAudioDeviceImpl::OnDeviceStarted(const std::string& device_uid) { |
177 VLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")"; | 177 VLOG(1) << "OnDeviceStarted (device_uid=" << device_uid << ")"; |
178 // -1 is an invalid device index. Do nothing if a valid device has | 178 // Empty string is an invalid device id. Do nothing if a valid device has |
179 // been started. Otherwise update the |recording_| state to false. | 179 // been started. Otherwise update the |recording_| state to false. |
180 if (device_index != -1) | 180 if (!device_uid.empty()) |
181 return; | 181 return; |
182 | 182 |
183 base::AutoLock auto_lock(lock_); | 183 base::AutoLock auto_lock(lock_); |
184 if (recording_) | 184 if (recording_) |
185 recording_ = false; | 185 recording_ = false; |
186 } | 186 } |
187 | 187 |
188 void WebRtcAudioDeviceImpl::OnDeviceStopped() { | 188 void WebRtcAudioDeviceImpl::OnDeviceStopped() { |
189 VLOG(1) << "OnDeviceStopped"; | 189 VLOG(1) << "OnDeviceStopped"; |
190 base::AutoLock auto_lock(lock_); | 190 base::AutoLock auto_lock(lock_); |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
359 // Use different buffer sizes depending on the current hardware sample rate. | 359 // Use different buffer sizes depending on the current hardware sample rate. |
360 if (output_sample_rate == 48000) { | 360 if (output_sample_rate == 48000) { |
361 input_buffer_size = 480; | 361 input_buffer_size = 480; |
362 output_buffer_size = 480; | 362 output_buffer_size = 480; |
363 } else { | 363 } else { |
364 // We do run at 44.1kHz at the actual audio layer, but ask for frames | 364 // We do run at 44.1kHz at the actual audio layer, but ask for frames |
365 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. | 365 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine. |
366 input_buffer_size = 440; | 366 input_buffer_size = 440; |
367 output_buffer_size = 440; | 367 output_buffer_size = 440; |
368 } | 368 } |
369 #elif defined(OS_LINUX) || defined(OS_OPENBSD) | 369 #elif defined(OS_LINUX) |
370 if (output_sample_rate != 48000) { | 370 if (output_sample_rate != 48000) { |
371 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; | 371 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; |
372 return -1; | 372 return -1; |
373 } | 373 } |
374 input_channels = 1; | 374 input_channels = 2; |
scherkus (not reviewing)
2011/11/16 01:20:40
was this change intentional?
henrika (OOO until Aug 14)
2011/11/16 13:24:02
Same question.
no longer working on chromium
2011/11/16 17:45:48
Yes. The testing shows that stereo is more widely
no longer working on chromium
2011/11/16 17:45:48
See comment above.
| |
375 output_channels = 1; | 375 output_channels = 1; |
376 | 376 |
377 // Based on tests using the current ALSA implementation in Chrome, we have | 377 // Based on tests using the current ALSA implementation in Chrome, we have |
378 // found that the best combination is 20ms on the input side and 10ms on the | 378 // found that the best combination is 20ms on the input side and 10ms on the |
379 // output side. | 379 // output side. |
380 // TODO(henrika): It might be possible to reduce the input buffer | 380 // TODO(henrika): It might be possible to reduce the input buffer |
381 // size and reduce the delay even more. | 381 // size and reduce the delay even more. |
382 input_buffer_size = 2 * 480; | 382 input_buffer_size = 2 * 480; |
383 output_buffer_size = 480; | 383 output_buffer_size = 480; |
384 #else | 384 #else |
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
944 } | 944 } |
945 | 945 |
946 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { | 946 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { |
947 NOTIMPLEMENTED(); | 947 NOTIMPLEMENTED(); |
948 return -1; | 948 return -1; |
949 } | 949 } |
950 | 950 |
951 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { | 951 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { |
952 session_id_ = session_id; | 952 session_id_ = session_id; |
953 } | 953 } |
OLD | NEW |