mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-01 17:58:29 +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)
|
while(m_Playing && this->m_pCallback)
|
||||||
{
|
{
|
||||||
AutoLock lock(&m_AudioLock);
|
AutoLock lock(&m_AudioLock);
|
||||||
|
|
||||||
while( (m_Buffers[m_ActiveBuffer].dwFlags & WHDR_INQUEUE) && m_Playing )
|
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);
|
ResetEvent(m_hEvent);
|
||||||
}
|
}
|
||||||
@ -157,7 +157,7 @@ unsigned long WaveOut::ThreadProc(void)
|
|||||||
|
|
||||||
if(m_Playing)
|
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;
|
m_Buffers[m_ActiveBuffer].dwUser = m_ActiveBuffer;
|
||||||
waveOutWrite(m_waveHandle, &m_Buffers[m_ActiveBuffer], sizeof(WAVEHDR));
|
waveOutWrite(m_waveHandle, &m_Buffers[m_ActiveBuffer], sizeof(WAVEHDR));
|
||||||
|
@ -30,8 +30,8 @@ AudioStream::AudioStream(IAudioSource* source, IAudioOutput* output, Transport*
|
|||||||
|
|
||||||
AudioStream::~AudioStream()
|
AudioStream::~AudioStream()
|
||||||
{
|
{
|
||||||
this->audioSource->Destroy();
|
|
||||||
this->output->Destroy();
|
this->output->Destroy();
|
||||||
|
this->audioSource->Destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool AudioStream::SetVolumeScale(float scale)
|
bool AudioStream::SetVolumeScale(float scale)
|
||||||
@ -42,7 +42,7 @@ bool AudioStream::SetVolumeScale(float scale)
|
|||||||
|
|
||||||
bool AudioStream::GetBuffer(float * pAudioBuffer, unsigned long NumSamples)
|
bool AudioStream::GetBuffer(float * pAudioBuffer, unsigned long NumSamples)
|
||||||
{
|
{
|
||||||
AutoLock t(&this->lock);
|
boost::mutex::scoped_lock lock(this->mutex);
|
||||||
|
|
||||||
if (this->isFinished)
|
if (this->isFinished)
|
||||||
{
|
{
|
||||||
@ -233,7 +233,7 @@ unsigned long AudioStream::GetPosition() const
|
|||||||
|
|
||||||
bool AudioStream::SetPosition(unsigned long MS)
|
bool AudioStream::SetPosition(unsigned long MS)
|
||||||
{
|
{
|
||||||
AutoLock t(&this->lock);
|
boost::mutex::scoped_lock lock(this->mutex);
|
||||||
|
|
||||||
if(this->fadeState != FadeStateNone)
|
if(this->fadeState != FadeStateNone)
|
||||||
{
|
{
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <boost/thread/thread.hpp>
|
||||||
|
#include <boost/thread/mutex.hpp>
|
||||||
|
|
||||||
#include <core/audio/IAudioCallBack.h>
|
#include <core/audio/IAudioCallBack.h>
|
||||||
#include <core/audio/AudioPacketizer.h>
|
#include <core/audio/AudioPacketizer.h>
|
||||||
#include <core/audio/CriticalSection.h>
|
|
||||||
|
|
||||||
namespace musik { namespace core { namespace audio {
|
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: unsigned long channels;
|
||||||
|
|
||||||
private: CriticalSection lock;
|
private: boost::mutex mutex;
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// Pending stuff
|
// 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"
|
RelativePath=".\audio\AudioStream.h"
|
||||||
>
|
>
|
||||||
</File>
|
</File>
|
||||||
<File
|
|
||||||
RelativePath=".\audio\CriticalSection.h"
|
|
||||||
>
|
|
||||||
</File>
|
|
||||||
<File
|
<File
|
||||||
RelativePath=".\audio\IAudioCallback.h"
|
RelativePath=".\audio\IAudioCallback.h"
|
||||||
>
|
>
|
||||||
|
Loading…
Reference in New Issue
Block a user