diff options
author | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:34:24 +0000 |
---|---|---|
committer | cpu@chromium.org <cpu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-18 22:34:24 +0000 |
commit | 5f3e6942ba82da6dfe02fe6f35d2919995bfcb81 (patch) | |
tree | a7ca48a7dca2d322eee91abdb6aa9dbc9a15d318 /media/audio/win/waveout_output_win.cc | |
parent | 8b6ff019c982f3929cf09b7090c9ec38c2751fc1 (diff) | |
download | chromium_src-5f3e6942ba82da6dfe02fe6f35d2919995bfcb81.zip chromium_src-5f3e6942ba82da6dfe02fe6f35d2919995bfcb81.tar.gz chromium_src-5f3e6942ba82da6dfe02fe6f35d2919995bfcb81.tar.bz2 |
Possible deadlock in PCM audio Start() method
- Implement Alpha's idea of pausing the device while we queue the first two packets.
- This way we don't risk the chance to enter the callback from two threads at the same time.
TEST=unit test added
BUG=19276
Review URL: http://codereview.chromium.org/173022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@23668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/win/waveout_output_win.cc')
-rw-r--r-- | media/audio/win/waveout_output_win.cc | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc index 40d17d3..44bfb73 100644 --- a/media/audio/win/waveout_output_win.cc +++ b/media/audio/win/waveout_output_win.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -153,16 +153,26 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) { buffer = GetNextBuffer(buffer); } buffer = buffer_; - - // Send the buffers to the audio driver. + MMRESULT result = ::waveOutPause(waveout_); + if (result != MMSYSERR_NOERROR) { + HandleError(result); + return; + } + // Send the buffers to the audio driver. Note that the device is paused + // so we avoid entering the callback method while still here. for (int ix = 0; ix != kNumBuffers; ++ix) { - MMRESULT result = ::waveOutWrite(waveout_, buffer, sizeof(WAVEHDR)); + result = ::waveOutWrite(waveout_, buffer, sizeof(WAVEHDR)); if (result != MMSYSERR_NOERROR) { HandleError(result); break; } buffer = GetNextBuffer(buffer); } + result = ::waveOutRestart(waveout_); + if (result != MMSYSERR_NOERROR) { + HandleError(result); + return; + } } // Stopping is tricky. First, no buffer should be locked by the audio driver |