mirror of
https://github.com/clangen/musikcube.git
synced 2024-10-02 04:52:32 +00:00
Rough night, found and fixed another deadlock.
This commit is contained in:
parent
916823000c
commit
c364175f75
@ -56,7 +56,7 @@ WaveOut::~WaveOut() {
|
||||
}
|
||||
|
||||
void WaveOut::Destroy() {
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock2(this->outputDeviceMutex);
|
||||
|
||||
/* reset playback immediately. this will invalidate all pending
|
||||
@ -73,8 +73,12 @@ void WaveOut::Destroy() {
|
||||
waveOutClose(this->waveHandle);
|
||||
this->waveHandle = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
this->ClearBufferQueue();
|
||||
}
|
||||
|
||||
delete this;
|
||||
}
|
||||
@ -98,14 +102,19 @@ void WaveOut::SetVolume(double volume) {
|
||||
}
|
||||
|
||||
void WaveOut::Stop() {
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock2(this->outputDeviceMutex);
|
||||
|
||||
if (this->waveHandle != NULL) {
|
||||
waveOutReset(this->waveHandle);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
boost::recursive_mutex::scoped_lock lock1(this->bufferQueueMutex);
|
||||
this->ClearBufferQueue();
|
||||
}
|
||||
}
|
||||
|
||||
void WaveOut::ClearBufferQueue() {
|
||||
@ -150,7 +159,7 @@ void WaveOut::StartWaveOutThread() {
|
||||
void WaveOut::StopWaveOutThread() {
|
||||
if (this->threadHandle != NULL) {
|
||||
PostThreadMessage(this->threadId, WM_QUIT, 0, 0);
|
||||
WaitForSingleObject(this->threadHandle, 5000);
|
||||
WaitForSingleObject(this->threadHandle, INFINITE);
|
||||
this->threadHandle = NULL;
|
||||
this->threadId = 0;
|
||||
}
|
||||
@ -202,6 +211,7 @@ void WaveOut::SetFormat(IBuffer *buffer) {
|
||||
this->currentSampleRate = buffer->SampleRate();
|
||||
|
||||
this->Stop();
|
||||
this->StopWaveOutThread();
|
||||
this->StartWaveOutThread();
|
||||
|
||||
/* reset, and configure speaker output */
|
||||
|
Loading…
Reference in New Issue
Block a user