Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(816)

Side by Side Diff: content/renderer/media/webrtc_audio_device_impl.cc

Issue 8491044: Link things together and enable the device selection for linux and mac. (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: enable the device selection for linux and mac Created 9 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/browser/renderer_host/media/audio_input_device_manager.h"
9 #include "content/common/view_messages.h" 10 #include "content/common/view_messages.h"
10 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
11 #include "media/audio/audio_util.h" 12 #include "media/audio/audio_util.h"
12 13
13 static const int64 kMillisecondsBetweenProcessCalls = 5000; 14 static const int64 kMillisecondsBetweenProcessCalls = 5000;
14 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome"; 15 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome";
15 16
16 static int GetAudioInputHardwareSampleRate() { 17 static int GetAudioInputHardwareSampleRate() {
17 static double input_sample_rate = 0; 18 static double input_sample_rate = 0;
18 if (!input_sample_rate) { 19 if (!input_sample_rate) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 samples_per_sec, 167 samples_per_sec,
167 input_delay_ms_ + output_delay_ms_, 168 input_delay_ms_ + output_delay_ms_,
168 0, // clock_drift 169 0, // clock_drift
169 0, // current_mic_level 170 0, // current_mic_level
170 new_mic_level); // not used 171 new_mic_level); // not used
171 accumulated_audio_samples += samples_per_10_msec; 172 accumulated_audio_samples += samples_per_10_msec;
172 audio_byte_buffer += bytes_per_10_msec; 173 audio_byte_buffer += bytes_per_10_msec;
173 } 174 }
174 } 175 }
175 176
176 void WebRtcAudioDeviceImpl::OnDeviceStarted(int device_index) { 177 void WebRtcAudioDeviceImpl::OnDeviceStarted(const std::string& device_uid) {
177 VLOG(1) << "OnDeviceStarted (device_index=" << device_index << ")"; 178 VLOG(1) << "OnDeviceStarted (device_uid=" << device_uid << ")";
178 // -1 is an invalid device index. Do nothing if a valid device has 179 // -1 is an invalid device index. Do nothing if a valid device has
179 // been started. Otherwise update the |recording_| state to false. 180 // been started. Otherwise update the |recording_| state to false.
180 if (device_index != -1) 181 if (device_uid != media_stream::AudioInputDeviceManager::kInvalidDeviceUId)
181 return; 182 return;
182 183
183 base::AutoLock auto_lock(lock_); 184 base::AutoLock auto_lock(lock_);
184 if (recording_) 185 if (recording_)
185 recording_ = false; 186 recording_ = false;
186 } 187 }
187 188
188 void WebRtcAudioDeviceImpl::OnDeviceStopped() { 189 void WebRtcAudioDeviceImpl::OnDeviceStopped() {
189 VLOG(1) << "OnDeviceStopped"; 190 VLOG(1) << "OnDeviceStopped";
190 base::AutoLock auto_lock(lock_); 191 base::AutoLock auto_lock(lock_);
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 // We do run at 44.1kHz at the actual audio layer, but ask for frames 365 // 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. 366 // at 44.0kHz to ensure that we can feed them to the webrtc::VoiceEngine.
366 input_buffer_size = 440; 367 input_buffer_size = 440;
367 output_buffer_size = 440; 368 output_buffer_size = 440;
368 } 369 }
369 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 370 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
370 if (output_sample_rate != 48000) { 371 if (output_sample_rate != 48000) {
371 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux."; 372 DLOG(ERROR) << "Only 48kHz sample rate is supported on Linux.";
372 return -1; 373 return -1;
373 } 374 }
374 input_channels = 1; 375 input_channels = 2;
375 output_channels = 1; 376 output_channels = 1;
376 377
377 // Based on tests using the current ALSA implementation in Chrome, we have 378 // 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 379 // found that the best combination is 20ms on the input side and 10ms on the
379 // output side. 380 // output side.
380 // TODO(henrika): It might be possible to reduce the input buffer 381 // TODO(henrika): It might be possible to reduce the input buffer
381 // size and reduce the delay even more. 382 // size and reduce the delay even more.
382 input_buffer_size = 2 * 480; 383 input_buffer_size = 2 * 480;
383 output_buffer_size = 480; 384 output_buffer_size = 480;
384 #else 385 #else
(...skipping 559 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 } 945 }
945 946
946 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { 947 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const {
947 NOTIMPLEMENTED(); 948 NOTIMPLEMENTED();
948 return -1; 949 return -1;
949 } 950 }
950 951
951 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { 952 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) {
952 session_id_ = session_id; 953 session_id_ = session_id;
953 } 954 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698