summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 20:06:13 +0000
committerenal@chromium.org <enal@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-01-11 20:06:13 +0000
commit567be9397b8e21f7a672676d9b2ce9094ed34ea8 (patch)
treeb3a9896bdd407284476710a1de56358c78f99e0d /media
parent9b9132764e73e69d9cc940dd485b52e00cf68fd4 (diff)
downloadchromium_src-567be9397b8e21f7a672676d9b2ce9094ed34ea8.zip
chromium_src-567be9397b8e21f7a672676d9b2ce9094ed34ea8.tar.gz
chromium_src-567be9397b8e21f7a672676d9b2ce9094ed34ea8.tar.bz2
Add CHECKs to find root cause of Windows-only crash.
Checks are temporary and would be in canary only. For gory details please see original bug 108685. BUG=109757 Review URL: http://codereview.chromium.org/9147039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media')
-rw-r--r--media/audio/win/waveout_output_win.cc33
-rw-r--r--media/audio/win/waveout_output_win.h5
2 files changed, 30 insertions, 8 deletions
diff --git a/media/audio/win/waveout_output_win.cc b/media/audio/win/waveout_output_win.cc
index 148983e..14605e9 100644
--- a/media/audio/win/waveout_output_win.cc
+++ b/media/audio/win/waveout_output_win.cc
@@ -87,7 +87,8 @@ PCMWaveOutAudioOutputStream::PCMWaveOutAudioOutputStream(
buffer_size_(params.GetPacketSize()),
volume_(1),
channels_(params.channels),
- pending_bytes_(0) {
+ pending_bytes_(0),
+ thread_id_(GetCurrentThreadId()) {
format_.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
format_.Format.nChannels = params.channels;
format_.Format.nSamplesPerSec = params.sample_rate;
@@ -112,6 +113,7 @@ PCMWaveOutAudioOutputStream::~PCMWaveOutAudioOutputStream() {
}
bool PCMWaveOutAudioOutputStream::Open() {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
if (state_ != PCMA_BRAND_NEW)
return false;
if (BufferSize() * num_buffers_ > kMaxOpenBufferSize)
@@ -145,6 +147,7 @@ bool PCMWaveOutAudioOutputStream::Open() {
}
void PCMWaveOutAudioOutputStream::SetupBuffers() {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
buffers_.reset(new char[BufferSize() * num_buffers_]);
for (int ix = 0; ix != num_buffers_; ++ix) {
WAVEHDR* buffer = GetBuffer(ix);
@@ -161,6 +164,7 @@ void PCMWaveOutAudioOutputStream::SetupBuffers() {
}
void PCMWaveOutAudioOutputStream::FreeBuffers() {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
for (int ix = 0; ix != num_buffers_; ++ix) {
::waveOutUnprepareHeader(waveout_, GetBuffer(ix), sizeof(WAVEHDR));
}
@@ -171,6 +175,7 @@ void PCMWaveOutAudioOutputStream::FreeBuffers() {
// this then we would always get the driver callback when it is about to run
// samples and that would leave too little time to react.
void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
if (state_ != PCMA_READY)
return;
callback_ = callback;
@@ -185,6 +190,8 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
INFINITE,
WT_EXECUTEDEFAULT);
if (!waiting_handle) {
+ volatile DWORD code = GetLastError();
+ CHECK(false);
HandleError(MMSYSERR_ERROR);
return;
}
@@ -212,6 +219,7 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
MMRESULT result = ::waveOutPause(waveout_);
if (result != MMSYSERR_NOERROR) {
+ CHECK(false);
HandleError(result);
return;
}
@@ -221,12 +229,14 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
for (int ix = 0; ix != num_buffers_; ++ix) {
result = ::waveOutWrite(waveout_, GetBuffer(ix), sizeof(WAVEHDR));
if (result != MMSYSERR_NOERROR) {
+ CHECK(false);
HandleError(result);
break;
}
}
result = ::waveOutRestart(waveout_);
if (result != MMSYSERR_NOERROR) {
+ CHECK(false);
HandleError(result);
return;
}
@@ -240,6 +250,7 @@ void PCMWaveOutAudioOutputStream::Start(AudioSourceCallback* callback) {
// should be under its own lock, and checking the liveness and
// acquiring the lock on stream should be done atomically.
void PCMWaveOutAudioOutputStream::Stop() {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
if (state_ != PCMA_PLAYING)
return;
state_ = PCMA_STOPPING;
@@ -248,6 +259,7 @@ void PCMWaveOutAudioOutputStream::Stop() {
// Stop playback.
MMRESULT res = ::waveOutReset(waveout_);
if (res != MMSYSERR_NOERROR) {
+ CHECK(false);
state_ = PCMA_PLAYING;
HandleError(res);
return;
@@ -267,6 +279,8 @@ void PCMWaveOutAudioOutputStream::Stop() {
if (waiting_handle) {
BOOL unregister = UnregisterWaitEx(waiting_handle, INVALID_HANDLE_VALUE);
if (!unregister) {
+ volatile DWORD code = GetLastError();
+ CHECK(false);
state_ = PCMA_PLAYING;
HandleError(MMSYSERR_ERROR);
}
@@ -283,15 +297,17 @@ void PCMWaveOutAudioOutputStream::Stop() {
// as callback_ is set to NULL. Just print it and hope somebody somehow
// will find it...
void PCMWaveOutAudioOutputStream::Close() {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
Stop(); // Just to be sure. No-op if not playing.
if (waveout_) {
MMRESULT res = ::waveOutClose(waveout_);
- // The callback was cleared by the call to Stop(), so there's no point in
- // calling HandleError at this point. Also, even though waveOutClose might
- // fail, we do not want to attempt to close the handle again, so we always
- // transfer to the closed state and NULL the handle. Moreover, we must
- // always call ReleaseOutputStream().
- DLOG_IF(ERROR, res != MMSYSERR_NOERROR) << "waveOutClose() failed";
+ if (res != MMSYSERR_NOERROR) {
+ CHECK(false);
+ HandleError(res);
+ }
+ // Even though waveOutClose might fail, we do not want to attempt to close
+ // the handle again, so we always transfer to the closed state and NULL the
+ // handle. Moreover, we must always call ReleaseOutputStream().
state_ = PCMA_CLOSED;
waveout_ = NULL;
FreeBuffers();
@@ -303,18 +319,21 @@ void PCMWaveOutAudioOutputStream::Close() {
}
void PCMWaveOutAudioOutputStream::SetVolume(double volume) {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
if (!waveout_)
return;
volume_ = static_cast<float>(volume);
}
void PCMWaveOutAudioOutputStream::GetVolume(double* volume) {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
if (!waveout_)
return;
*volume = volume_;
}
void PCMWaveOutAudioOutputStream::HandleError(MMRESULT error) {
+ CHECK_EQ(thread_id_, GetCurrentThreadId());
DLOG(WARNING) << "PCMWaveOutAudio error " << error;
if (callback_)
callback_->OnError(this, error);
diff --git a/media/audio/win/waveout_output_win.h b/media/audio/win/waveout_output_win.h
index e7cb4ed..03e019c 100644
--- a/media/audio/win/waveout_output_win.h
+++ b/media/audio/win/waveout_output_win.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Copyright (c) 2012 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.
@@ -129,6 +129,9 @@ class PCMWaveOutAudioOutputStream : public AudioOutputStream {
// Lock used to avoid the conflict when callbacks are called simultaneously.
base::Lock lock_;
+ // Temporary here, for CHECK().
+ DWORD thread_id_;
+
DISALLOW_COPY_AND_ASSIGN(PCMWaveOutAudioOutputStream);
};