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" | |
11 #include "content/renderer/render_thread_impl.h" | 10 #include "content/renderer/render_thread_impl.h" |
12 #include "media/audio/audio_util.h" | 11 #include "media/audio/audio_util.h" |
13 | 12 |
14 static const int64 kMillisecondsBetweenProcessCalls = 5000; | 13 static const int64 kMillisecondsBetweenProcessCalls = 5000; |
15 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome"; | 14 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome"; |
16 | 15 |
17 static int GetAudioInputHardwareSampleRate() { | |
18 static double input_sample_rate = 0; | |
19 if (!input_sample_rate) { | |
20 RenderThreadImpl::current()->Send( | |
21 new ViewHostMsg_GetHardwareInputSampleRate(&input_sample_rate)); | |
22 } | |
23 return static_cast<int>(input_sample_rate); | |
24 } | |
25 | |
26 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() | 16 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl() |
27 : ref_count_(0), | 17 : ref_count_(0), |
28 render_loop_(base::MessageLoopProxy::current()), | 18 render_loop_(base::MessageLoopProxy::current()), |
29 audio_transport_callback_(NULL), | 19 audio_transport_callback_(NULL), |
30 input_buffer_size_(0), | 20 input_buffer_size_(0), |
31 output_buffer_size_(0), | 21 output_buffer_size_(0), |
32 input_channels_(0), | 22 input_channels_(0), |
33 output_channels_(0), | 23 output_channels_(0), |
34 input_sample_rate_(0), | 24 input_sample_rate_(0), |
35 output_sample_rate_(0), | 25 output_sample_rate_(0), |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 return 0; | 273 return 0; |
284 | 274 |
285 DCHECK(!audio_input_device_); | 275 DCHECK(!audio_input_device_); |
286 DCHECK(!audio_output_device_); | 276 DCHECK(!audio_output_device_); |
287 DCHECK(!input_buffer_.get()); | 277 DCHECK(!input_buffer_.get()); |
288 DCHECK(!output_buffer_.get()); | 278 DCHECK(!output_buffer_.get()); |
289 | 279 |
290 // Ask the browser for the default audio output hardware sample-rate. | 280 // Ask the browser for the default audio output hardware sample-rate. |
291 // This request is based on a synchronous IPC message. | 281 // This request is based on a synchronous IPC message. |
292 int output_sample_rate = | 282 int output_sample_rate = |
293 static_cast<int>(AudioDevice::GetAudioHardwareSampleRate()); | 283 static_cast<int>(AudioHardware::GetOutputSampleRate()); |
294 DVLOG(1) << "Audio output hardware sample rate: " << output_sample_rate; | 284 DVLOG(1) << "Audio output hardware sample rate: " << output_sample_rate; |
295 | 285 |
296 // Ask the browser for the default audio input hardware sample-rate. | 286 // Ask the browser for the default audio input hardware sample-rate. |
297 // This request is based on a synchronous IPC message. | 287 // This request is based on a synchronous IPC message. |
298 int input_sample_rate = GetAudioInputHardwareSampleRate(); | 288 int input_sample_rate = static_cast<int>(AudioHardware::GetInputSampleRate()); |
299 DVLOG(1) << "Audio input hardware sample rate: " << input_sample_rate; | 289 DVLOG(1) << "Audio input hardware sample rate: " << input_sample_rate; |
300 | 290 |
301 int input_channels = 0; | 291 int input_channels = 0; |
302 int output_channels = 0; | 292 int output_channels = 0; |
303 | 293 |
304 size_t input_buffer_size = 0; | 294 size_t input_buffer_size = 0; |
305 size_t output_buffer_size = 0; | 295 size_t output_buffer_size = 0; |
306 | 296 |
307 // Windows | 297 // Windows |
308 #if defined(OS_WIN) | 298 #if defined(OS_WIN) |
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
973 } | 963 } |
974 | 964 |
975 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { | 965 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { |
976 NOTIMPLEMENTED(); | 966 NOTIMPLEMENTED(); |
977 return -1; | 967 return -1; |
978 } | 968 } |
979 | 969 |
980 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { | 970 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { |
981 session_id_ = session_id; | 971 session_id_ = session_id; |
982 } | 972 } |
OLD | NEW |