Chromium Code Reviews| Index: media/audio/audio_output_resampler.cc |
| diff --git a/media/audio/audio_output_resampler.cc b/media/audio/audio_output_resampler.cc |
| index baad88a0f7d427157651872dbb5de2f31d5788b0..17f43c23abc36bdf095c4ee767c83f608825fbf8 100644 |
| --- a/media/audio/audio_output_resampler.cc |
| +++ b/media/audio/audio_output_resampler.cc |
| @@ -11,6 +11,7 @@ |
| #include "base/message_loop.h" |
| #include "base/metrics/histogram.h" |
| #include "base/time.h" |
| +#include "build/build_config.h" |
| #include "media/audio/audio_io.h" |
| #include "media/audio/audio_output_dispatcher_impl.h" |
| #include "media/audio/audio_output_proxy.h" |
| @@ -20,6 +21,10 @@ |
| #include "media/base/limits.h" |
| #include "media/base/media_switches.h" |
| +#if defined(OS_WIN) |
| +#include "media/audio/win/core_audio_util_win.h" |
| +#endif |
| + |
| namespace media { |
| class OnMoreDataConverter |
| @@ -72,6 +77,10 @@ class OnMoreDataConverter |
| // parameters. |
| AudioConverter audio_converter_; |
| + // If we're using WaveOut on Windows' we always have to wait for DataReady() |
| + // before calling |source_callback_|. |
| + bool waveout_wait_hack_; |
| + |
| DISALLOW_COPY_AND_ASSIGN(OnMoreDataConverter); |
| }; |
| @@ -278,10 +287,17 @@ OnMoreDataConverter::OnMoreDataConverter(const AudioParameters& input_params, |
| : source_callback_(NULL), |
| source_bus_(NULL), |
| input_bytes_per_second_(input_params.GetBytesPerSecond()), |
| - audio_converter_(input_params, output_params, false) { |
| + audio_converter_(input_params, output_params, false), |
| + waveout_wait_hack_(false) { |
| io_ratio_ = |
| static_cast<double>(input_params.GetBytesPerSecond()) / |
| output_params.GetBytesPerSecond(); |
| + |
| +#if defined(OS_WIN) |
| + waveout_wait_hack_ = |
| + output_params.format() == AudioParameters::AUDIO_PCM_LINEAR || |
| + !CoreAudioUtil::IsSupported(); |
| +#endif |
| } |
| OnMoreDataConverter::~OnMoreDataConverter() {} |
| @@ -340,6 +356,9 @@ double OnMoreDataConverter::ProvideInput(AudioBus* dest, |
| io_ratio_ * (current_buffers_state_.total_bytes() + |
| buffer_delay.InSecondsF() * input_bytes_per_second_); |
| + if (waveout_wait_hack_) |
| + source_callback_->WaitTillDataReady(); |
|
Chris Rogers
2012/11/22 00:39:46
I'm really not too crazy about this, although I un
DaleCurtis
2012/11/22 00:53:58
Yes that's the problem. A FIFO won't help w/o acc
|
| + |
| // Retrieve data from the original callback. |
| int frames = source_callback_->OnMoreIOData( |
| source_bus_, dest, new_buffers_state); |