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

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: Plumb. 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" 11 #include "content/renderer/media/renderer_audio_hardware_config.h"
12 #include "content/renderer/media/renderer_audio_output_device.h" 12 #include "content/renderer/media/renderer_audio_output_device.h"
13 #include "content/renderer/media/webrtc_audio_device_impl.h" 13 #include "content/renderer/media/webrtc_audio_device_impl.h"
14 #include "content/renderer/render_thread_impl.h"
14 #include "media/audio/audio_util.h" 15 #include "media/audio/audio_util.h"
15 #include "media/audio/sample_rates.h" 16 #include "media/audio/sample_rates.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 // RendererAudioHardwareConfig::GetOutputSampleRate() asks the audio layer
28 // for its current sample rate (set by the user) on Windows and Mac OS X. 30 // for its current sample rate (set by the user) on Windows and Mac OS X.
29 // The listed rates below adds restrictions and Initialize() 31 // The listed rates below adds restrictions and Initialize()
30 // will fail if the user selects any rate outside these ranges. 32 // will fail if the user selects 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
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 browser for the default audio output hardware sample-rate.
108 // This request is based on a synchronous IPC message. 110 // This request is based on a synchronous IPC message.
henrika (OOO until Aug 14) 2013/01/29 10:46:49 Guess this comment is not 100% any longer since we
DaleCurtis 2013/01/30 01:31:06 Done.
109 int sample_rate = GetAudioOutputSampleRate(); 111 RendererAudioHardwareConfig* hardware_config =
112 RenderThreadImpl::current()->GetAudioHardwareConfig();
113 int sample_rate = hardware_config->GetOutputSampleRate();
110 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate; 114 DVLOG(1) << "Audio output hardware sample rate: " << sample_rate;
111 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate", 115 UMA_HISTOGRAM_ENUMERATION("WebRTC.AudioOutputSampleRate",
112 sample_rate, media::kUnexpectedAudioSampleRate); 116 sample_rate, media::kUnexpectedAudioSampleRate);
113 117
114 // Verify that the reported output hardware sample rate is supported 118 // Verify that the reported output hardware sample rate is supported
115 // on the current platform. 119 // on the current platform.
116 if (std::find(&kValidOutputRates[0], 120 if (std::find(&kValidOutputRates[0],
117 &kValidOutputRates[0] + arraysize(kValidOutputRates), 121 &kValidOutputRates[0] + arraysize(kValidOutputRates),
118 sample_rate) == 122 sample_rate) ==
119 &kValidOutputRates[arraysize(kValidOutputRates)]) { 123 &kValidOutputRates[arraysize(kValidOutputRates)]) {
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 params_.bits_per_sample() / 8); 301 params_.bits_per_sample() / 8);
298 return audio_bus->frames(); 302 return audio_bus->frames();
299 } 303 }
300 304
301 void WebRtcAudioRenderer::OnRenderError() { 305 void WebRtcAudioRenderer::OnRenderError() {
302 NOTIMPLEMENTED(); 306 NOTIMPLEMENTED();
303 LOG(ERROR) << "OnRenderError()"; 307 LOG(ERROR) << "OnRenderError()";
304 } 308 }
305 309
306 } // namespace content 310 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698