Commit 50c219e6 authored by tommi's avatar tommi Committed by Commit bot

Add support for 24kHz audio sample rate and remove the validation check

in webrtc. Our resampler is capable of handling any sample rates.

This has been reviewed here:
https://codereview.chromium.org/548503002/

BUG=411241
TBR=xians,dalecurtis
NOTRY=true

Review URL: https://codereview.chromium.org/554733002

Cr-Commit-Position: refs/heads/master@{#293773}
parent 677b469f
...@@ -23,22 +23,6 @@ namespace content { ...@@ -23,22 +23,6 @@ namespace content {
namespace { namespace {
// Supported hardware sample rates for input and output sides.
#if defined(OS_WIN) || defined(OS_MACOSX)
// media::GetAudioInputHardwareSampleRate() asks the audio layer
// for its current sample rate (set by the user) on Windows and Mac OS X.
// The listed rates below adds restrictions and WebRtcAudioDeviceImpl::Init()
// will fail if the user selects any rate outside these ranges.
const int kValidInputRates[] =
{192000, 96000, 48000, 44100, 32000, 16000, 8000};
#elif defined(OS_LINUX) || defined(OS_OPENBSD)
const int kValidInputRates[] = {48000, 44100};
#elif defined(OS_ANDROID)
const int kValidInputRates[] = {48000, 44100};
#else
const int kValidInputRates[] = {44100};
#endif
// Time constant for AudioPowerMonitor. See AudioPowerMonitor ctor comments // Time constant for AudioPowerMonitor. See AudioPowerMonitor ctor comments
// for semantics. This value was arbitrarily chosen, but seems to work well. // for semantics. This value was arbitrarily chosen, but seems to work well.
const int kPowerMonitorTimeConstantMs = 10; const int kPowerMonitorTimeConstantMs = 10;
...@@ -196,17 +180,6 @@ bool WebRtcAudioCapturer::Initialize() { ...@@ -196,17 +180,6 @@ bool WebRtcAudioCapturer::Initialize() {
device_info_.device.input.sample_rate); device_info_.device.input.sample_rate);
} }
// Verify that the reported input hardware sample rate is supported
// on the current platform.
if (std::find(&kValidInputRates[0],
&kValidInputRates[0] + arraysize(kValidInputRates),
device_info_.device.input.sample_rate) ==
&kValidInputRates[arraysize(kValidInputRates)]) {
DLOG(ERROR) << device_info_.device.input.sample_rate
<< " is not a supported input rate.";
return false;
}
// Create and configure the default audio capturing source. // Create and configure the default audio capturing source.
SetCapturerSource(AudioDeviceFactory::NewInputDevice(render_view_id_), SetCapturerSource(AudioDeviceFactory::NewInputDevice(render_view_id_),
channel_layout, channel_layout,
......
...@@ -29,24 +29,6 @@ namespace content { ...@@ -29,24 +29,6 @@ namespace content {
namespace { namespace {
// Supported hardware sample rates for output sides.
#if defined(OS_WIN) || defined(OS_MACOSX)
// AudioHardwareConfig::GetOutputSampleRate() asks the audio layer for its
// current sample rate (set by the user) on Windows and Mac OS X. The listed
// rates below adds restrictions and Initialize() will fail if the user selects
// any rate outside these ranges.
const int kValidOutputRates[] = {96000, 48000, 44100, 32000, 16000};
#elif defined(OS_LINUX) || defined(OS_OPENBSD)
const int kValidOutputRates[] = {48000, 44100};
#elif defined(OS_ANDROID)
// TODO(leozwang): We want to use native sampling rate on Android to achieve
// low latency, currently 16000 is used to work around audio problem on some
// Android devices.
const int kValidOutputRates[] = {48000, 44100, 16000};
#else
const int kValidOutputRates[] = {44100};
#endif
// This is a simple wrapper class that's handed out to users of a shared // This is a simple wrapper class that's handed out to users of a shared
// WebRtcAudioRenderer instance. This class maintains the per-user 'playing' // WebRtcAudioRenderer instance. This class maintains the per-user 'playing'
// and 'started' states to avoid problems related to incorrect usage which // and 'started' states to avoid problems related to incorrect usage which
...@@ -254,16 +236,6 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) { ...@@ -254,16 +236,6 @@ bool WebRtcAudioRenderer::Initialize(WebRtcAudioRendererSource* source) {
sample_rate); sample_rate);
} }
// Verify that the reported output hardware sample rate is supported
// on the current platform.
if (std::find(&kValidOutputRates[0],
&kValidOutputRates[0] + arraysize(kValidOutputRates),
sample_rate) ==
&kValidOutputRates[arraysize(kValidOutputRates)]) {
DLOG(ERROR) << sample_rate << " is not a supported output rate.";
return false;
}
// Set up audio parameters for the source, i.e., the WebRTC client. // Set up audio parameters for the source, i.e., the WebRTC client.
// The WebRTC client only supports multiples of 10ms as buffer size where // The WebRTC client only supports multiples of 10ms as buffer size where
......
...@@ -44,6 +44,9 @@ bool ToAudioSampleRate(int sample_rate, AudioSampleRate* asr) { ...@@ -44,6 +44,9 @@ bool ToAudioSampleRate(int sample_rate, AudioSampleRate* asr) {
case 192000: case 192000:
*asr = k192000Hz; *asr = k192000Hz;
return true; return true;
case 24000:
*asr = k24000Hz;
return true;
} }
return false; return false;
} }
......
...@@ -23,8 +23,9 @@ enum AudioSampleRate { ...@@ -23,8 +23,9 @@ enum AudioSampleRate {
k88200Hz = 8, k88200Hz = 8,
k176400Hz = 9, k176400Hz = 9,
k192000Hz = 10, k192000Hz = 10,
k24000Hz = 11,
// Must always equal the largest value ever reported: // Must always equal the largest value ever reported:
kAudioSampleRateMax = k192000Hz, kAudioSampleRateMax = k24000Hz,
}; };
// Helper method to convert integral values to their respective enum values, // Helper method to convert integral values to their respective enum values,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment