OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "media/audio/win/waveout_output_win.h" | 5 #include "media/audio/win/waveout_output_win.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <mmsystem.h> | 8 #include <mmsystem.h> |
9 #pragma comment(lib, "winmm.lib") | 9 #pragma comment(lib, "winmm.lib") |
10 | 10 |
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
277 HandleError(res); | 277 HandleError(res); |
278 return; | 278 return; |
279 } | 279 } |
280 | 280 |
281 // waveOutReset() leaves buffers in the unpredictable state, causing | 281 // waveOutReset() leaves buffers in the unpredictable state, causing |
282 // problems if we want to close, release, or reuse them. Fix the states. | 282 // problems if we want to close, release, or reuse them. Fix the states. |
283 for (int ix = 0; ix != num_buffers_; ++ix) { | 283 for (int ix = 0; ix != num_buffers_; ++ix) { |
284 GetBuffer(ix)->dwFlags = WHDR_PREPARED; | 284 GetBuffer(ix)->dwFlags = WHDR_PREPARED; |
285 } | 285 } |
286 | 286 |
287 // Don't use callback after Stop(). | 287 // Don't use callback after Stop(). Wait for lock to ensure all outstanding |
288 // callbacks have completed. | |
289 base::AutoLock auto_lock(lock_); | |
Chris Rogers
2012/11/15 22:49:30
maybe this auto_lock should be moved up to just ab
DaleCurtis
2012/11/15 22:58:23
Done.
| |
288 callback_ = NULL; | 290 callback_ = NULL; |
289 | 291 |
290 state_ = PCMA_READY; | 292 state_ = PCMA_READY; |
291 } | 293 } |
292 | 294 |
293 // We can Close in any state except that trying to close a stream that is | 295 // We can Close in any state except that trying to close a stream that is |
294 // playing Windows generates an error. We cannot propagate it to the source, | 296 // playing Windows generates an error. We cannot propagate it to the source, |
295 // as callback_ is set to NULL. Just print it and hope somebody somehow | 297 // as callback_ is set to NULL. Just print it and hope somebody somehow |
296 // will find it... | 298 // will find it... |
297 void PCMWaveOutAudioOutputStream::Close() { | 299 void PCMWaveOutAudioOutputStream::Close() { |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
404 buffer, | 406 buffer, |
405 sizeof(WAVEHDR)); | 407 sizeof(WAVEHDR)); |
406 if (result != MMSYSERR_NOERROR) | 408 if (result != MMSYSERR_NOERROR) |
407 stream->HandleError(result); | 409 stream->HandleError(result); |
408 stream->pending_bytes_ += buffer->dwBufferLength; | 410 stream->pending_bytes_ += buffer->dwBufferLength; |
409 } | 411 } |
410 } | 412 } |
411 } | 413 } |
412 | 414 |
413 } // namespace media | 415 } // namespace media |
OLD | NEW |