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

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

Issue 11880009: Introduce AudioHardwareConfig for renderer side audio device info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Style nits. Created 7 years, 10 months 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_renderer.h" 5 #include "content/renderer/media/webrtc_audio_renderer.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "base/metrics/histogram.h" 8 #include "base/metrics/histogram.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #include "content/renderer/media/audio_device_factory.h" 10 #include "content/renderer/media/audio_device_factory.h"
11 #include "content/renderer/media/audio_hardware.h"
12 #include "content/renderer/media/renderer_audio_output_device.h" 11 #include "content/renderer/media/renderer_audio_output_device.h"
13 #include "content/renderer/media/webrtc_audio_device_impl.h" 12 #include "content/renderer/media/webrtc_audio_device_impl.h"
13 #include "content/renderer/render_thread_impl.h"
14 #include "media/audio/audio_util.h" 14 #include "media/audio/audio_util.h"
15 #include "media/audio/sample_rates.h" 15 #include "media/audio/sample_rates.h"
16 #include "media/base/audio_hardware_config.h"
17
16 #if defined(OS_WIN) 18 #if defined(OS_WIN)
17 #include "base/win/windows_version.h" 19 #include "base/win/windows_version.h"
18 #include "media/audio/win/core_audio_util_win.h" 20 #include "media/audio/win/core_audio_util_win.h"
19 #endif 21 #endif
20 22
21 namespace content { 23 namespace content {
22 24
23 namespace { 25 namespace {
24 26
25 // Supported hardware sample rates for output sides. 27 // Supported hardware sample rates for output sides.
26 #if defined(OS_WIN) || defined(OS_MACOSX) 28 #if defined(OS_WIN) || defined(OS_MACOSX)
27 // media::GetAudioOutputHardwareSampleRate() asks the audio layer 29 // AudioHardwareConfig::GetOutputSampleRate() asks the audio layer for its
28 // for its current sample rate (set by the user) on Windows and Mac OS X. 30 // current sample rate (set by the user) on Windows and Mac OS X. The listed
29 // The listed rates below adds restrictions and Initialize() 31 // rates below adds restrictions and Initialize() will fail if the user selects
30 // will fail if the user selects any rate outside these ranges. 32 // any rate outside these ranges.
31 int kValidOutputRates[] = {96000, 48000, 44100}; 33 int kValidOutputRates[] = {96000, 48000, 44100};
32 #elif defined(OS_LINUX) || defined(OS_OPENBSD) 34 #elif defined(OS_LINUX) || defined(OS_OPENBSD)
33 int kValidOutputRates[] = {48000, 44100}; 35 int kValidOutputRates[] = {48000, 44100};
34 #elif defined(OS_ANDROID) 36 #elif defined(OS_ANDROID)
35 // On Android, the most popular sampling rate is 16000. 37 // On Android, the most popular sampling rate is 16000.
36 int kValidOutputRates[] = {48000, 44100, 16000}; 38 int kValidOutputRates[] = {48000, 44100, 16000};
37 #else 39 #else
38 int kValidOutputRates[] = {44100}; 40 int kValidOutputRates[] = {44100};
39 #endif 41 #endif
40 42
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { 99 bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
98 base::AutoLock auto_lock(lock_); 100 base::AutoLock auto_lock(lock_);
99 DCHECK_EQ(state_, UNINITIALIZED); 101 DCHECK_EQ(state_, UNINITIALIZED);
100 DCHECK(source); 102 DCHECK(source);
101 DCHECK(!sink_); 103 DCHECK(!sink_);
102 DCHECK(!source_); 104 DCHECK(!source_);
103 105
104 sink_ = AudioDeviceFactory::NewOutputDevice(); 106 sink_ = AudioDeviceFactory::NewOutputDevice();
105 DCHECK(sink_); 107 DCHECK(sink_);
106 108
107 // Ask the browser for the default audio output hardware sample-rate. 109 // Ask the renderer for the default audio output hardware sample-rate.
108 // This request is based on a synchronous IPC message. 110 media::AudioHardwareConfig* hardware_config =
109 int sample_rate = GetAudioOutputSampleRate(); 111 RenderThreadImpl::current()->GetAudioHardwareConfig();
112 int sample_rate = hardware_config->GetOutputSampleRate();
110 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate; 113 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate;
111 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate", 114 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate",
112 sample_rate, media::kUnexpectedAudioSampleRate); 115 sample_rate, media::kUnexpectedAudioSampleRate);
113 116
114 // Verify that the reported output hardware sample rate is supported 117 // Verify that the reported output hardware sample rate is supported
115 // on the current platform. 118 // on the current platform.
116 if (std::find(&kValidOutputRates[0], 119 if (std::find(&kValidOutputRates[0],
117 &kValidOutputRates[0] + arraysize(kValidOutputRates), 120 &kValidOutputRates[0] + arraysize(kValidOutputRates),
118 sample_rate) == 121 sample_rate) ==
119 &kValidOutputRates[arraysize(kValidOutputRates)]) { 122 &kValidOutputRates[arraysize(kValidOutputRates)]) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 params_.bits_per_sample() / 8); 300 params_.bits_per_sample() / 8);
298 return audio_bus->frames(); 301 return audio_bus->frames();
299 } 302 }
300 303
301 void WebRtcAudioRenderer::OnRenderError() { 304 void WebRtcAudioRenderer::OnRenderError() {
302 NOTIMPLEMENTED(); 305 NOTIMPLEMENTED();
303 LOG(ERROR) << "OnRenderError()"; 306 LOG(ERROR) << "OnRenderError()";
304 } 307 }
305 308
306 } // namespace content 309 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc_audio_device_unittest.cc ('k') | content/renderer/pepper/pepper_platform_audio_output_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698