mirror of
https://github.com/clangen/musikcube.git
synced 2024-12-29 18:14:16 +00:00
- Replaced Win32 threads in core::audio with Boost.Thread
- Fixed crash on exit in WaveOut plugin (closes issue #8)
This commit is contained in:
parent
f75b471093
commit
da1d52c197
@ -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));
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -1,8 +1,10 @@
|
||||
#pragma once
|
||||
|
||||
#include <boost/thread/thread.hpp>
|
||||
#include <boost/thread/mutex.hpp>
|
||||
|
||||
#include <core/audio/IAudioCallBack.h>
|
||||
#include <core/audio/AudioPacketizer.h>
|
||||
#include <core/audio/CriticalSection.h>
|
||||
|
||||
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
|
||||
|
@ -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();
|
||||
}
|
||||
};
|
@ -489,10 +489,6 @@
|
||||
RelativePath=".\audio\AudioStream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\audio\CriticalSection.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\audio\IAudioCallback.h"
|
||||
>
|
||||
|
Loading…
Reference in New Issue
Block a user