Thread safe.

PS: The OpenAL is a mess.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4710 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
ayuanx
2009-12-18 19:52:04 +00:00
parent 97090337e3
commit 7b6a0f9b72
4 changed files with 48 additions and 39 deletions

View File

@ -49,16 +49,13 @@ void AOSound::SoundLoop()
while (!threadData)
{
soundCriticalSection.Enter();
m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
soundCriticalSection.Enter();
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
soundCriticalSection.Leave();
if (! threadData)
soundSyncEvent.Wait();
soundSyncEvent.Wait();
}
ao_close(device);
device = NULL;
}
void *soundThread(void *args)
@ -84,19 +81,23 @@ void AOSound::Update()
void AOSound::Stop()
{
soundCriticalSection.Enter();
threadData = 1;
soundSyncEvent.Set();
soundCriticalSection.Leave();
delete thread;
soundCriticalSection.Enter();
delete thread;
thread = NULL;
ao_shutdown();
ao_close(device);
device = NULL;
soundCriticalSection.Leave();
soundSyncEvent.Shutdown();
}
AOSound::~AOSound() {
// FIXME: crashes dolphin
// ao_shutdown();
AOSound::~AOSound()
{
}
#endif