2009-03-27 15:24:22 +00:00
|
|
|
// Copyright (C) 2003-2009 Dolphin Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official SVN repository and contact information can be found at
|
|
|
|
// http://code.google.com/p/dolphin-emu/
|
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
#include "aldlist.h"
|
2009-03-28 17:18:34 +00:00
|
|
|
#include "OpenALStream.h"
|
2009-03-27 15:24:22 +00:00
|
|
|
|
|
|
|
#define AUDIO_NUMBUFFERS (4)
|
|
|
|
|
|
|
|
bool OpenALStream::Start()
|
|
|
|
{
|
2009-03-30 14:22:31 +00:00
|
|
|
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;
|
2009-03-27 15:24:22 +00:00
|
|
|
}
|
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
void OpenALStream::Stop()
|
2009-03-27 15:24:22 +00:00
|
|
|
{
|
2009-03-30 14:22:31 +00:00
|
|
|
ALCcontext *pContext;
|
|
|
|
ALCdevice *pDevice;
|
2009-03-27 15:24:22 +00:00
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
delete thread;
|
2009-03-27 15:24:22 +00:00
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
pContext = alcGetCurrentContext();
|
|
|
|
pDevice = alcGetContextsDevice(pContext);
|
2009-03-27 15:24:22 +00:00
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
alcMakeContextCurrent(NULL);
|
|
|
|
alcDestroyContext(pContext);
|
|
|
|
alcCloseDevice(pDevice);
|
2009-03-27 15:24:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void OpenALStream::Update()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2009-03-30 14:22:31 +00:00
|
|
|
// The audio thread.
|
2009-03-30 19:47:41 +00:00
|
|
|
THREAD_RETURN OpenALStream::ThreadFunc(void* args)
|
2009-03-30 14:22:31 +00:00
|
|
|
{
|
|
|
|
(reinterpret_cast<OpenALStream *>(args))->SoundLoop();
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OpenALStream::SoundLoop()
|
2009-03-27 15:24:22 +00:00
|
|
|
{
|
|
|
|
|
2009-03-28 08:57:34 +00:00
|
|
|
}
|