From caf1395f5ebb906524176a0b82971b7b7ed71264 Mon Sep 17 00:00:00 2001 From: nakeee Date: Mon, 30 Mar 2009 20:25:36 +0000 Subject: [PATCH] Fixing compile without openal git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2810 8ced0084-cf51-0410-be5f-012b33b47a6e --- Source/Core/AudioCommon/Src/AudioCommon.cpp | 1 + Source/Core/AudioCommon/Src/OpenALStream.cpp | 32 +++++++++++++++++--- Source/Core/AudioCommon/Src/OpenALStream.h | 7 ++++- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/Source/Core/AudioCommon/Src/AudioCommon.cpp b/Source/Core/AudioCommon/Src/AudioCommon.cpp index 8e25561a5d..196ca37fdb 100644 --- a/Source/Core/AudioCommon/Src/AudioCommon.cpp +++ b/Source/Core/AudioCommon/Src/AudioCommon.cpp @@ -28,6 +28,7 @@ namespace AudioCommon { if (!mixer) mixer = new CMixer(); + std::string backend = ac_Config.sBackend; if (backend == BACKEND_DIRECTSOUND && DSound::isValid()) soundStream = new DSound(mixer, g_dspInitialize.hWnd); if (backend == BACKEND_AOSOUND && AOSound::isValid()) soundStream = new AOSound(mixer); diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp index dda870cee1..29b5f8f08d 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.cpp +++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp @@ -26,7 +26,7 @@ bool OpenALStream::Start() ALCcontext *pContext = NULL; ALCdevice *pDevice = NULL; bool bReturn = false; - + pDeviceList = new ALDeviceList(); if ((pDeviceList) && (pDeviceList->GetNumDevices())) { @@ -43,10 +43,18 @@ bool OpenALStream::Start() else { alcCloseDevice(pDevice); + PanicAlert("OpenAL: can't create context for device %s", pDevice); } + } else { + PanicAlert("OpenAL: can't open device %s", pDevice); } + + delete pDeviceList; + } else { + PanicAlert("OpenAL: can't find sound devices"); } + return bReturn; } @@ -55,22 +63,29 @@ void OpenALStream::Stop() ALCcontext *pContext; ALCdevice *pDevice; + soundCriticalSection.Enter(); + threadData = 1; + // kick the thread if it's waiting + soundSyncEvent.Set(); + soundCriticalSection.Leave(); delete thread; - + pContext = alcGetCurrentContext(); pDevice = alcGetContextsDevice(pContext); alcMakeContextCurrent(NULL); alcDestroyContext(pContext); alcCloseDevice(pDevice); + + soundSyncEvent.Shutdown(); + thread = NULL; } void OpenALStream::Update() { - + soundSyncEvent.Set(); } -// The audio thread. THREAD_RETURN OpenALStream::ThreadFunc(void* args) { (reinterpret_cast(args))->SoundLoop(); @@ -79,5 +94,14 @@ THREAD_RETURN OpenALStream::ThreadFunc(void* args) void OpenALStream::SoundLoop() { + while (!threadData) { + soundCriticalSection.Enter(); + // Add sound playing here + // m_mixer->Mix(realtimeBuffer, numBytesToRender >> 2); + soundCriticalSection.Leave(); + + if (!threadData) + soundSyncEvent.Wait(); + } } diff --git a/Source/Core/AudioCommon/Src/OpenALStream.h b/Source/Core/AudioCommon/Src/OpenALStream.h index 129da8a27b..f773ec53b9 100644 --- a/Source/Core/AudioCommon/Src/OpenALStream.h +++ b/Source/Core/AudioCommon/Src/OpenALStream.h @@ -24,9 +24,13 @@ #if defined HAVE_OPENAL && HAVE_OPENAL +#ifdef _WIN32 #include "../../../../Externals/OpenAL/include/al.h" #include "../../../../Externals/OpenAL/include/alc.h" - +#else +#include "AL/al.h" +#include "AL/alc.h" +#endif // WIN32 // public use #define SFX_MAX_SOURCE 1 #endif @@ -53,6 +57,7 @@ private: Common::CriticalSection soundCriticalSection; Common::Event soundSyncEvent; #else +public: OpenALStream(CMixer *mixer, void *hWnd = NULL): SoundStream(mixer) {} #endif // HAVE_OPENAL };