Fixing compile without openal

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2810 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
nakeee 2009-03-30 20:25:36 +00:00
parent c3a843b5a8
commit caf1395f5e
3 changed files with 35 additions and 5 deletions

View File

@ -28,6 +28,7 @@ namespace AudioCommon
{ {
if (!mixer) if (!mixer)
mixer = new CMixer(); mixer = new CMixer();
std::string backend = ac_Config.sBackend; std::string backend = ac_Config.sBackend;
if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd); if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd);
if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer); if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer);

View File

@ -43,10 +43,18 @@ bool OpenALStream::Start()
else else
{ {
alcCloseDevice(pDevice); alcCloseDevice(pDevice);
PanicAlert("OpenAL: can't create context for device %s", pDevice);
} }
} else {
PanicAlert("OpenAL: can't open device %s", pDevice);
} }
delete pDeviceList; delete pDeviceList;
} else {
PanicAlert("OpenAL: can't find sound devices");
} }
return bReturn; return bReturn;
} }
@ -55,6 +63,11 @@ void OpenALStream::Stop()
ALCcontext *pContext; ALCcontext *pContext;
ALCdevice *pDevice; ALCdevice *pDevice;
soundCriticalSection.Enter();
threadData = 1;
// kick the thread if it's waiting
soundSyncEvent.Set();
soundCriticalSection.Leave();
delete thread; delete thread;
pContext = alcGetCurrentContext(); pContext = alcGetCurrentContext();
@ -63,14 +76,16 @@ void OpenALStream::Stop()
alcMakeContextCurrent(NULL); alcMakeContextCurrent(NULL);
alcDestroyContext(pContext); alcDestroyContext(pContext);
alcCloseDevice(pDevice); alcCloseDevice(pDevice);
soundSyncEvent.Shutdown();
thread = NULL;
} }
void OpenALStream::Update() void OpenALStream::Update()
{ {
soundSyncEvent.Set();
} }
// The audio thread.
THREAD_RETURN OpenALStream::ThreadFunc(void* args) THREAD_RETURN OpenALStream::ThreadFunc(void* args)
{ {
(reinterpret_cast<OpenALStream *>(args))->SoundLoop(); (reinterpret_cast<OpenALStream *>(args))->SoundLoop();
@ -79,5 +94,14 @@ THREAD_RETURN OpenALStream::ThreadFunc(void* args)
void OpenALStream::SoundLoop() void OpenALStream::SoundLoop()
{ {
while (!threadData) {
soundCriticalSection.Enter();
// Add sound playing here
// m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2);
soundCriticalSection.Leave();
if (!threadData)
soundSyncEvent.Wait();
}
} }

View File

@ -24,9 +24,13 @@
#if defined HAVE_OPENAL && HAVE_OPENAL #if defined HAVE_OPENAL && HAVE_OPENAL
#ifdef _WIN32
#include "../../../../Externals/OpenAL/include/al.h" #include "../../../../Externals/OpenAL/include/al.h"
#include "../../../../Externals/OpenAL/include/alc.h" #include "../../../../Externals/OpenAL/include/alc.h"
#else
#include "AL/al.h"
#include "AL/alc.h"
#endif // WIN32
// public use // public use
#define SFX_MAX_SOURCE 1 #define SFX_MAX_SOURCE 1
#endif #endif
@ -53,6 +57,7 @@ private:
Common::CriticalSection soundCriticalSection; Common::CriticalSection soundCriticalSection;
Common::Event soundSyncEvent; Common::Event soundSyncEvent;
#else #else
public:
OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {} OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {}
#endif // HAVE_OPENAL #endif // HAVE_OPENAL
}; };