Index: media/audio/win/waveout_output_win.cc |
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc |
index 5e56169a4db67d213a21e086f34777681de1209e..f18b2fa4287dc59c01ed21596f6c6fbb07d28c18 100644 |
--- a/media/audio/win/waveout_output_win.cc |
+++ b/media/audio/win/waveout_output_win.cc |
@@ -76,7 +76,6 @@ inline WAVEHDR* PCMWaveOutAudioOutputStream::GetBuffer(int n) const { |
return reinterpret_cast<WAVEHDR*>(&buffers_[n * BufferSize()]); |
} |
- |
PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream( |
AudioManagerWin* manager, const AudioParameters& params, int num_buffers, |
UINT device_id) |
@@ -342,6 +341,13 @@ void PCMWaveOutAudioOutputStream::QueueNextPacket(WAVEHDR *buffer) { |
// return to us how many bytes were used. |
// TODO(fbarchard): Handle used 0 by queueing more. |
+ // HACK: Yield if Read() is called too often. On older platforms which are |
+ // still using the WaveOut backend, we run into synchronization issues where |
+ // the renderer has not finished filling the shared memory when Read() is |
+ // called. Reading too early will lead to clicks and pops. See issues: |
+ // http://crbug.com/161307 and http://crbug.com/61022 |
+ callback_->WaitTillDataReady(); |
+ |
// TODO(sergeyu): Specify correct hardware delay for AudioBuffersState. |
int frames_filled = callback_->OnMoreData( |
audio_bus_.get(), AudioBuffersState(pending_bytes_, 0)); |