| Index: media/audio/audio_manager_base.cc
|
| diff --git a/media/audio/audio_manager_base.cc b/media/audio/audio_manager_base.cc
|
| index 1beee2fc31226214bb964bcd49e25d4b2413442d..6b1fa928a4d74808c58b673b51f9bffe45375952 100644
|
| --- a/media/audio/audio_manager_base.cc
|
| +++ b/media/audio/audio_manager_base.cc
|
| @@ -160,41 +160,53 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
|
| #else
|
| DCHECK(message_loop_->BelongsToCurrentThread());
|
|
|
| - AudioOutputDispatchersMap::iterator it = output_dispatchers_.find(params);
|
| + bool use_audio_output_resampler =
|
| + !CommandLine::ForCurrentProcess()->HasSwitch(
|
| + switches::kDisableAudioOutputResampler) &&
|
| + params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY;
|
| +
|
| + // If we're not using AudioOutputResampler our output parameters are the same
|
| + // as our input parameters.
|
| + AudioParameters output_params = params;
|
| + if (use_audio_output_resampler) {
|
| + output_params = GetPreferredLowLatencyOutputStreamParameters(params);
|
| +
|
| + // Ensure we only pass on valid output parameters.
|
| + if (!output_params.IsValid()) {
|
| + // We've received invalid audio output parameters, so switch to a mock
|
| + // output device based on the input parameters. This may happen if the OS
|
| + // provided us junk values for the hardware configuration.
|
| + LOG(ERROR) << "Invalid audio output parameters received; using fake "
|
| + << "audio path. Channels: " << output_params.channels() << ", "
|
| + << "Sample Rate: " << output_params.sample_rate() << ", "
|
| + << "Bits Per Sample: " << output_params.bits_per_sample()
|
| + << ", Frames Per Buffer: "
|
| + << output_params.frames_per_buffer();
|
| +
|
| + // Tell the AudioManager to create a fake output device.
|
| + output_params = AudioParameters(
|
| + AudioParameters::AUDIO_FAKE, params.channel_layout(),
|
| + params.sample_rate(), params.bits_per_sample(),
|
| + params.frames_per_buffer());
|
| + }
|
| + }
|
| +
|
| + std::pair<AudioParameters, AudioParameters> dispatcher_key =
|
| + std::make_pair(params, output_params);
|
| + AudioOutputDispatchersMap::iterator it =
|
| + output_dispatchers_.find(dispatcher_key);
|
| if (it != output_dispatchers_.end())
|
| return new AudioOutputProxy(it->second);
|
|
|
| base::TimeDelta close_delay =
|
| base::TimeDelta::FromSeconds(kStreamCloseDelaySeconds);
|
|
|
| - const CommandLine* cmd_line = CommandLine::ForCurrentProcess();
|
| - if (!cmd_line->HasSwitch(switches::kDisableAudioOutputResampler) &&
|
| - params.format() == AudioParameters::AUDIO_PCM_LOW_LATENCY) {
|
| - AudioParameters output_params =
|
| - GetPreferredLowLatencyOutputStreamParameters(params);
|
| -
|
| - // Ensure we only pass on valid output parameters.
|
| - if (output_params.IsValid()) {
|
| - scoped_refptr<AudioOutputDispatcher> dispatcher =
|
| - new AudioOutputResampler(this, params, output_params, close_delay);
|
| - output_dispatchers_[params] = dispatcher;
|
| - return new AudioOutputProxy(dispatcher);
|
| - }
|
| -
|
| - // We've received invalid audio output parameters, so switch to a mock
|
| - // output device based on the input parameters. This may happen if the OS
|
| - // provided us junk values for the hardware configuration.
|
| - LOG(ERROR) << "Invalid audio output parameters received; using fake audio "
|
| - << "path. Channels: " << output_params.channels() << ", "
|
| - << "Sample Rate: " << output_params.sample_rate() << ", "
|
| - << "Bits Per Sample: " << output_params.bits_per_sample()
|
| - << ", Frames Per Buffer: " << output_params.frames_per_buffer();
|
| -
|
| - // Passing AUDIO_FAKE tells the AudioManager to create a fake output device.
|
| - output_params = AudioParameters(
|
| - AudioParameters::AUDIO_FAKE, params.channel_layout(),
|
| - params.sample_rate(), params.bits_per_sample(),
|
| - params.frames_per_buffer());
|
| + if (use_audio_output_resampler &&
|
| + output_params.format() != AudioParameters::AUDIO_FAKE) {
|
| + scoped_refptr<AudioOutputDispatcher> dispatcher =
|
| + new AudioOutputResampler(this, params, output_params, close_delay);
|
| + output_dispatchers_[dispatcher_key] = dispatcher;
|
| + return new AudioOutputProxy(dispatcher);
|
| }
|
|
|
| #if defined(ENABLE_AUDIO_MIXER)
|
| @@ -204,14 +216,14 @@ AudioOutputStream* AudioManagerBase::MakeAudioOutputStreamProxy(
|
| if (cmd_line->HasSwitch(switches::kEnableAudioMixer)) {
|
| scoped_refptr<AudioOutputDispatcher> dispatcher =
|
| new AudioOutputMixer(this, params, close_delay);
|
| - output_dispatchers_[params] = dispatcher;
|
| + output_dispatchers_[dispatcher_key] = dispatcher;
|
| return new AudioOutputProxy(dispatcher);
|
| }
|
| #endif
|
|
|
| scoped_refptr<AudioOutputDispatcher> dispatcher =
|
| new AudioOutputDispatcherImpl(this, params, close_delay);
|
| - output_dispatchers_[params] = dispatcher;
|
| + output_dispatchers_[dispatcher_key] = dispatcher;
|
| return new AudioOutputProxy(dispatcher);
|
| #endif // defined(OS_IOS)
|
| }
|
|
|