summaryrefslogtreecommitdiffstats
path: root/media/audio/win/waveout_output_win.cc
diff options
context:
space:
mode:
authorrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 23:40:54 +0000
committerrvargas@chromium.org <rvargas@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-06-13 23:40:54 +0000
commit9bd6cd7d9487db53b2a918fa042c8e1f6357d8c4 (patch)
treec2609bcd2703b796f544201f19e3cca04ff2ab93 /media/audio/win/waveout_output_win.cc
parent0432016b1a94a57871a1d29b5ebc6e4adb537055 (diff)
downloadchromium_src-9bd6cd7d9487db53b2a918fa042c8e1f6357d8c4.zip
chromium_src-9bd6cd7d9487db53b2a918fa042c8e1f6357d8c4.tar.gz
chromium_src-9bd6cd7d9487db53b2a918fa042c8e1f6357d8c4.tar.bz2
Media: Don't use a scoped handle for a wait object.
BUG=132586 TEST=none Review URL: https://chromiumcodereview.appspot.com/10543149 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142024 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/audio/win/waveout_output_win.cc')
-rw-r--r--media/audio/win/waveout_output_win.cc32
1 files changed, 14 insertions, 18 deletions
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc
index 248992c..75bfed4 100644
--- a/media/audio/win/waveout_output_win.cc
+++ b/media/audio/win/waveout_output_win.cc
@@ -89,7 +89,8 @@ PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream(
buffer_size_(params.GetBytesPerBuffer()),
volume_(1),
channels_(params.channels()),
- pending_bytes_(0) {
+ pending_bytes_(0),
+ waiting_handle_(NULL) {
format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
format_.Format.nChannels = params.channels();
format_.Format.nSamplesPerSec = params.sample_rate();
@@ -186,19 +187,15 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
}
// Start watching for buffer events.
- {
- HANDLE waiting_handle = NULL;
- ::RegisterWaitForSingleObject(&waiting_handle,
- buffer_event_.Get(),
- &BufferCallback,
- this,
- INFINITE,
- WT_EXECUTEDEFAULT);
- if (!waiting_handle) {
- HandleError(MMSYSERR_ERROR);
- return;
- }
- waiting_handle_.Set(waiting_handle);
+ if (!::RegisterWaitForSingleObject(&waiting_handle_,
+ buffer_event_.Get(),
+ &BufferCallback,
+ this,
+ INFINITE,
+ WT_EXECUTEDEFAULT)) {
+ HandleError(MMSYSERR_ERROR);
+ waiting_handle_ = NULL;
+ return;
}
state_ = PCMA_PLAYING;
@@ -263,14 +260,13 @@ void PCMWaveOutAudioOutputStream::Stop() {
// TODO(enal): that delays actual stopping of playback. Alternative can be
// to call ::waveOutReset() twice, once before
// ::UnregisterWaitEx() and once after.
- HANDLE waiting_handle = waiting_handle_.Take();
- if (waiting_handle) {
- BOOL unregister = ::UnregisterWaitEx(waiting_handle, INVALID_HANDLE_VALUE);
- if (!unregister) {
+ if (waiting_handle_) {
+ if (!::UnregisterWaitEx(waiting_handle_, INVALID_HANDLE_VALUE)) {
state_ = PCMA_PLAYING;
HandleError(MMSYSERR_ERROR);
return;
}
+ waiting_handle_ = NULL;
}
// Stop playback.