summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/Src/AOSoundStream.cpp
diff options
context:
space:
mode:
authornakeee <nakeee@gmail.com>2009-03-26 09:29:14 +0000
committernakeee <nakeee@gmail.com>2009-03-26 09:29:14 +0000
commitfff663e8c714b60a4325bf420a8b0d49c126bd13 (patch)
treeb98c248c4e70e4129861531cd60d55865804acbd /Source/Core/AudioCommon/Src/AOSoundStream.cpp
parentd7038fea173f79b26e432a2fb7b82c6d23cf88ce (diff)
Attempt to move mixer to audio common, it's a bit more complicated than I expected
so please check I didn't break anything in hle git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2756 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon/Src/AOSoundStream.cpp')
-rw-r--r--Source/Core/AudioCommon/Src/AOSoundStream.cpp45
1 files changed, 24 insertions, 21 deletions
diff --git a/Source/Core/AudioCommon/Src/AOSoundStream.cpp b/Source/Core/AudioCommon/Src/AOSoundStream.cpp
index f584cb6636..fdc507f5ee 100644
--- a/Source/Core/AudioCommon/Src/AOSoundStream.cpp
+++ b/Source/Core/AudioCommon/Src/AOSoundStream.cpp
@@ -18,16 +18,18 @@
#include <string.h>
#include "AOSoundStream.h"
+#include "Mixer.h"
#if defined(HAVE_AO) && HAVE_AO
void AOSound::SoundLoop()
{
+ uint_32 numBytesToRender = 256;
ao_initialize();
default_driver = ao_default_driver_id();
format.bits = 16;
format.channels = 2;
- format.rate = sampleRate;
+ format.rate = m_mixer->GetSampleRate();
format.byte_format = AO_FMT_LITTLE;
device = ao_open_live(default_driver, &format, NULL /* no options */);
@@ -43,14 +45,21 @@ void AOSound::SoundLoop()
while (!threadData)
{
- soundCriticalSection->Enter();
+ soundCriticalSection.Enter();
- uint_32 numBytesToRender = 256;
- (*callback)(realtimeBuffer, numBytesToRender >> 2, 16, sampleRate, 2);
+ m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
ao_play(device, (char*)realtimeBuffer, numBytesToRender);
- soundCriticalSection->Leave();
- soundSyncEvent->Wait();
+
+ soundCriticalSection.Leave();
+
+ if (! threadData)
+ soundSyncEvent.Wait();
}
+
+ ao_close(device);
+ device = NULL;
+ ao_shutdown();
+
}
void *soundThread(void *args)
@@ -63,34 +72,28 @@ bool AOSound::Start()
{
memset(realtimeBuffer, 0, sizeof(realtimeBuffer));
- soundSyncEvent = new Common::Event();
- soundSyncEvent->Init();
-
- soundCriticalSection = new Common::CriticalSection(1);
-
+ soundSyncEvent.Init();
+
thread = new Common::Thread(soundThread, (void *)this);
return true;
}
void AOSound::Update()
{
- soundSyncEvent->Set();
+ soundSyncEvent.Set();
}
void AOSound::Stop()
{
- soundCriticalSection->Enter();
+ soundCriticalSection.Enter();
threadData = 1;
- soundSyncEvent->Set();
- soundCriticalSection->Leave();
- soundSyncEvent->Shutdown();
- delete soundCriticalSection;
+ soundSyncEvent.Set();
+ soundCriticalSection.Leave();
+
delete thread;
- delete soundSyncEvent;
+ thread = NULL;
+ soundSyncEvent.Shutdown();
- ao_close(device);
- device = NULL;
- ao_shutdown();
}
#endif