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

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

Issue 8588030: Refactor the Get*Hardware* routines a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' 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 "base/win/windows_version.h" 9 #include "base/win/windows_version.h"
10 #include "content/common/view_messages.h" 10 #include "content/renderer/media/audio_hardware.h"
11 #include "content/renderer/render_thread_impl.h" 11 #include "content/renderer/render_thread_impl.h"
12 #include "media/audio/audio_util.h" 12 #include "media/audio/audio_util.h"
13 13
14 static const int64 kMillisecondsBetweenProcessCalls = 5000; 14 static const int64 kMillisecondsBetweenProcessCalls = 5000;
15 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome"; 15 static const char kVersion[] = "WebRTC AudioDevice 1.0.0.Chrome";
16 16
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() 17 WebRtcAudioDeviceImpl::WebRtcAudioDeviceImpl()
27 : ref_count_(0), 18 : ref_count_(0),
28 render_loop_(base::MessageLoopProxy::current()), 19 render_loop_(base::MessageLoopProxy::current()),
29 audio_transport_callback_(NULL), 20 audio_transport_callback_(NULL),
30 input_buffer_size_(0), 21 input_buffer_size_(0),
31 output_buffer_size_(0), 22 output_buffer_size_(0),
32 input_channels_(0), 23 input_channels_(0),
33 output_channels_(0), 24 output_channels_(0),
34 input_sample_rate_(0), 25 input_sample_rate_(0),
35 output_sample_rate_(0), 26 output_sample_rate_(0),
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 return 0; 274 return 0;
284 275
285 DCHECK(!audio_input_device_); 276 DCHECK(!audio_input_device_);
286 DCHECK(!audio_output_device_); 277 DCHECK(!audio_output_device_);
287 DCHECK(!input_buffer_.get()); 278 DCHECK(!input_buffer_.get());
288 DCHECK(!output_buffer_.get()); 279 DCHECK(!output_buffer_.get());
289 280
290 // Ask the browser for the default audio output hardware sample-rate. 281 // Ask the browser for the default audio output hardware sample-rate.
291 // This request is based on a synchronous IPC message. 282 // This request is based on a synchronous IPC message.
292 int output_sample_rate = 283 int output_sample_rate =
293 static_cast<int>(AudioDevice::GetAudioHardwareSampleRate()); 284 static_cast<int>(audio_hardware::GetOutputSampleRate());
294 DVLOG(1) << "Audio output hardware sample rate: " << output_sample_rate; 285 DVLOG(1) << "Audio output hardware sample rate: " << output_sample_rate;
295 286
296 // Ask the browser for the default audio input hardware sample-rate. 287 // Ask the browser for the default audio input hardware sample-rate.
297 // This request is based on a synchronous IPC message. 288 // This request is based on a synchronous IPC message.
298 int input_sample_rate = GetAudioInputHardwareSampleRate(); 289 int input_sample_rate =
290 static_cast<int>(audio_hardware::GetInputSampleRate());
299 DVLOG(1) << "Audio input hardware sample rate: " << input_sample_rate; 291 DVLOG(1) << "Audio input hardware sample rate: " << input_sample_rate;
300 292
301 int input_channels = 0; 293 int input_channels = 0;
302 int output_channels = 0; 294 int output_channels = 0;
303 295
304 size_t input_buffer_size = 0; 296 size_t input_buffer_size = 0;
305 size_t output_buffer_size = 0; 297 size_t output_buffer_size = 0;
306 298
307 // Windows 299 // Windows
308 #if defined(OS_WIN) 300 #if defined(OS_WIN)
(...skipping 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 } 965 }
974 966
975 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const { 967 int32_t WebRtcAudioDeviceImpl::GetLoudspeakerStatus(bool* enabled) const {
976 NOTIMPLEMENTED(); 968 NOTIMPLEMENTED();
977 return -1; 969 return -1;
978 } 970 }
979 971
980 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) { 972 void WebRtcAudioDeviceImpl::SetSessionId(int session_id) {
981 session_id_ = session_id; 973 session_id_ = session_id;
982 } 974 }
OLDNEW
« no previous file with comments | « content/renderer/media/audio_hardware.cc ('k') | content/renderer/media/webrtc_audio_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698