diff --git a/src/contrib/waveout/WaveOut.cpp b/src/contrib/waveout/WaveOut.cpp index 098aa0486..9d8f7008b 100644 --- a/src/contrib/waveout/WaveOut.cpp +++ b/src/contrib/waveout/WaveOut.cpp @@ -145,11 +145,11 @@ unsigned long WaveOut::ThreadProc(void) { while(m_Playing && this->m_pCallback) { - AutoLock lock(&m_AudioLock); - - while( (m_Buffers[m_ActiveBuffer].dwFlags & WHDR_INQUEUE) && m_Playing ) + AutoLock lock(&m_AudioLock); + + while(this->m_Buffers && ((m_Buffers[m_ActiveBuffer].dwFlags & WHDR_INQUEUE) && m_Playing )) { - if(WaitForSingleObject(m_hEvent, m_Interval) == WAIT_OBJECT_0) + if(WaitForSingleObject(m_hEvent, m_Interval) == WAIT_OBJECT_0) { ResetEvent(m_hEvent); } @@ -157,7 +157,7 @@ unsigned long WaveOut::ThreadProc(void) if(m_Playing) { - if(m_pCallback->GetBuffer((float*)m_Buffers[m_ActiveBuffer].lpData, m_BlockSize)) + if(m_pCallback->GetBuffer((float*)m_Buffers[m_ActiveBuffer].lpData, m_BlockSize)) { m_Buffers[m_ActiveBuffer].dwUser = m_ActiveBuffer; waveOutWrite(m_waveHandle, &m_Buffers[m_ActiveBuffer], sizeof(WAVEHDR)); diff --git a/src/core/audio/AudioStream.cpp b/src/core/audio/AudioStream.cpp index 20bc14cdc..02bfe58da 100644 --- a/src/core/audio/AudioStream.cpp +++ b/src/core/audio/AudioStream.cpp @@ -30,8 +30,8 @@ AudioStream::AudioStream(IAudioSource* source, IAudioOutput* output, Transport* AudioStream::~AudioStream() { - this->audioSource->Destroy(); this->output->Destroy(); + this->audioSource->Destroy(); } bool AudioStream::SetVolumeScale(float scale) @@ -42,7 +42,7 @@ bool AudioStream::SetVolumeScale(float scale) bool AudioStream::GetBuffer(float * pAudioBuffer, unsigned long NumSamples) { - AutoLock t(&this->lock); + boost::mutex::scoped_lock lock(this->mutex); if (this->isFinished) { @@ -233,7 +233,7 @@ unsigned long AudioStream::GetPosition() const bool AudioStream::SetPosition(unsigned long MS) { - AutoLock t(&this->lock); + boost::mutex::scoped_lock lock(this->mutex); if(this->fadeState != FadeStateNone) { diff --git a/src/core/audio/AudioStream.h b/src/core/audio/AudioStream.h index d9b61a848..c2b486509 100644 --- a/src/core/audio/AudioStream.h +++ b/src/core/audio/AudioStream.h @@ -1,8 +1,10 @@ #pragma once +#include +#include + #include #include -#include namespace musik { namespace core { namespace audio { @@ -49,7 +51,7 @@ private: bool isLast; // This can probably be removed once we have private: unsigned long channels; -private: CriticalSection lock; +private: boost::mutex mutex; ///////////////////////////////////////// // Pending stuff diff --git a/src/core/audio/CriticalSection.h b/src/core/audio/CriticalSection.h deleted file mode 100644 index f3d058732..000000000 --- a/src/core/audio/CriticalSection.h +++ /dev/null @@ -1,47 +0,0 @@ -#pragma once - -class CriticalSection -{ -protected: - HANDLE mutex; - -public: - CriticalSection() - { - this->mutex = CreateMutex(NULL, false, NULL); - } - - ~CriticalSection() - { - CloseHandle(this->mutex); - } - - void Lock() - { - WaitForSingleObject(this->mutex, INFINITE); - } - - void Unlock() - { - ReleaseMutex(this->mutex); - } -}; - -class AutoLock -{ -private: - CriticalSection * CS; - -public: - - AutoLock(CriticalSection *aCS) - { - this->CS = aCS; - this->CS->Lock(); - } - - ~AutoLock() - { - this->CS->Unlock(); - } -}; diff --git a/src/core/core.vcproj b/src/core/core.vcproj index bd4f666fc..753255427 100644 --- a/src/core/core.vcproj +++ b/src/core/core.vcproj @@ -489,10 +489,6 @@ RelativePath=".\audio\AudioStream.h" > - -