summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/Src/OpenALStream.cpp
diff options
context:
space:
mode:
authorhyperiris <hyperiris@gmail.com>2009-03-30 14:22:31 +0000
committerhyperiris <hyperiris@gmail.com>2009-03-30 14:22:31 +0000
commitd9e0e89725b47c66d8f73494ef4b65f83e499132 (patch)
tree361299dd2e07983dc51027dde9ed2ea79383cb7f /Source/Core/AudioCommon/Src/OpenALStream.cpp
parentb2ed842e03a3109a953b62e879d22e53f00451f5 (diff)
OpenAL: continue work on it
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@2799 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon/Src/OpenALStream.cpp')
-rw-r--r--Source/Core/AudioCommon/Src/OpenALStream.cpp56
1 files changed, 48 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp
index 66dd9b8807..2c95b4eec5 100644
--- a/Source/Core/AudioCommon/Src/OpenALStream.cpp
+++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp
@@ -15,25 +15,54 @@
// Official SVN repository and contact information can be found at
// http://code.google.com/p/dolphin-emu/
-
+#include "aldlist.h"
#include "OpenALStream.h"
#define AUDIO_NUMBUFFERS (4)
-
bool OpenALStream::Start()
{
- return false;
+ ALDeviceList *pDeviceList = NULL;
+ ALCcontext *pContext = NULL;
+ ALCdevice *pDevice = NULL;
+ bool bReturn = false;
+
+ pDeviceList = new ALDeviceList();
+ if ((pDeviceList) && (pDeviceList->GetNumDevices()))
+ {
+ pDevice = alcOpenDevice(pDeviceList->GetDeviceName(pDeviceList->GetDefaultDevice()));
+ if (pDevice)
+ {
+ pContext = alcCreateContext(pDevice, NULL);
+ if (pContext)
+ {
+ alcMakeContextCurrent(pContext);
+ thread = new Common::Thread(OpenALStream::ThreadFunc, (void *)this);
+ bReturn = true;
+ }
+ else
+ {
+ alcCloseDevice(pDevice);
+ }
+ }
+ delete pDeviceList;
+ }
+ return bReturn;
}
-void OpenALStream::SoundLoop()
+void OpenALStream::Stop()
{
+ ALCcontext *pContext;
+ ALCdevice *pDevice;
-}
+ delete thread;
-void OpenALStream::Stop()
-{
+ pContext = alcGetCurrentContext();
+ pDevice = alcGetContextsDevice(pContext);
+ alcMakeContextCurrent(NULL);
+ alcDestroyContext(pContext);
+ alcCloseDevice(pDevice);
}
void OpenALStream::Update()
@@ -41,7 +70,18 @@ void OpenALStream::Update()
}
-void OpenALStream::SoundThread()
+// The audio thread.
+#ifdef _WIN32
+DWORD WINAPI OpenALStream::ThreadFunc(void* args)
+#else
+void* OpenALStream::soundThread(void* args)
+#endif
+{
+ (reinterpret_cast<OpenALStream *>(args))->SoundLoop();
+ return 0;
+}
+
+void OpenALStream::SoundLoop()
{
}