Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(447)

Unified Diff: media/audio/win/waveout_output_win.cc

Issue 115523010: Always clear callback after WaveOut Stop(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixes. Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 47d4fa65053a157a3466680b50ef4b81ca8991a5..0f54817b14ac3d3b577513282e2ba1718cc13c9f 100644
--- a/media/audio/win/waveout_output_win.cc
+++ b/media/audio/win/waveout_output_win.cc
@@ -248,39 +248,25 @@ void PCMWaveOutAudioOutputStream::Stop() {
state_ = PCMA_STOPPING;
base::subtle::MemoryBarrier();
- // Stop watching for buffer event, wait till all the callbacks are complete.
- // Should be done before ::waveOutReset() call to avoid race condition when
- // callback that is currently active and already checked that stream is still
- // being played calls ::waveOutWrite() after ::waveOutReset() returns, later
- // causing ::waveOutClose() to fail with WAVERR_STILLPLAYING.
- // TODO(enal): that delays actual stopping of playback. Alternative can be
- // to call ::waveOutReset() twice, once before
- // ::UnregisterWaitEx() and once after.
+ // Stop watching for buffer event, waits until outstanding callbacks finish.
if (waiting_handle_) {
- if (!::UnregisterWaitEx(waiting_handle_, INVALID_HANDLE_VALUE)) {
- state_ = PCMA_PLAYING;
- HandleError(MMSYSERR_ERROR);
- return;
- }
+ if (!::UnregisterWaitEx(waiting_handle_, INVALID_HANDLE_VALUE))
+ HandleError(::GetLastError());
waiting_handle_ = NULL;
}
// Stop playback.
MMRESULT res = ::waveOutReset(waveout_);
- if (res != MMSYSERR_NOERROR) {
- state_ = PCMA_PLAYING;
+ if (res != MMSYSERR_NOERROR)
HandleError(res);
- return;
- }
// Wait for lock to ensure all outstanding callbacks have completed.
base::AutoLock auto_lock(lock_);
// waveOutReset() leaves buffers in the unpredictable state, causing
// problems if we want to close, release, or reuse them. Fix the states.
- for (int ix = 0; ix != num_buffers_; ++ix) {
+ for (int ix = 0; ix != num_buffers_; ++ix)
GetBuffer(ix)->dwFlags = WHDR_PREPARED;
- }
// Don't use callback after Stop().
callback_ = NULL;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698