summaryrefslogtreecommitdiff
path: root/Source/Core/AudioCommon/Src/OpenALStream.cpp
diff options
context:
space:
mode:
authorayuanx <ayuanx@gmail.com>2009-12-20 13:54:14 +0000
committerayuanx <ayuanx@gmail.com>2009-12-20 13:54:14 +0000
commitc3b196541de486507f97d917058a67ea52c368dd (patch)
treeff156b870ee69aefbec81ce307d804205e223f9f /Source/Core/AudioCommon/Src/OpenALStream.cpp
parent51163196d3e5faad9edaf9dc863ea7454b236a5d (diff)
Added volume control for OpenAL, also improved its performance a bit, but don't expect too much.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4712 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core/AudioCommon/Src/OpenALStream.cpp')
-rw-r--r--Source/Core/AudioCommon/Src/OpenALStream.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/Source/Core/AudioCommon/Src/OpenALStream.cpp b/Source/Core/AudioCommon/Src/OpenALStream.cpp
index 009369757c..1b2363888d 100644
--- a/Source/Core/AudioCommon/Src/OpenALStream.cpp
+++ b/Source/Core/AudioCommon/Src/OpenALStream.cpp
@@ -20,6 +20,9 @@
#if defined HAVE_OPENAL && HAVE_OPENAL
+//
+// AyuanX: Spec says OpenAL1.1 is thread safe already
+//
bool OpenALStream::Start()
{
ALDeviceList *pDeviceList = NULL;
@@ -68,8 +71,6 @@ void OpenALStream::Stop()
// kick the thread if it's waiting
soundSyncEvent.Set();
-// AyuanX: Spec says OpenAL1.1 is thread safe already
-// soundCriticalSection.Enter();
delete thread;
thread = NULL;
@@ -78,6 +79,7 @@ void OpenALStream::Stop()
// Clean up buffers and sources
alDeleteSources(1, &uiSource);
+ uiSource = 0;
alDeleteBuffers(OAL_NUM_BUFFERS, uiBuffers);
ALCcontext *pContext = alcGetCurrentContext();
@@ -86,11 +88,18 @@ void OpenALStream::Stop()
alcMakeContextCurrent(NULL);
alcDestroyContext(pContext);
alcCloseDevice(pDevice);
-// soundCriticalSection.Leave();
soundSyncEvent.Shutdown();
}
+void OpenALStream::SetVolume(int volume)
+{
+ fVolume = (float)volume / 100.0f;
+
+ if (uiSource)
+ alSourcef(uiSource, AL_GAIN, fVolume);
+}
+
void OpenALStream::Update()
{
soundSyncEvent.Set();
@@ -100,7 +109,6 @@ void OpenALStream::Clear(bool mute)
{
m_muted = mute;
-// soundCriticalSection.Enter();
if(m_muted)
{
alSourceStop(uiSource);
@@ -109,7 +117,6 @@ void OpenALStream::Clear(bool mute)
{
alSourcePlay(uiSource);
}
-// soundCriticalSection.Leave();
}
THREAD_RETURN OpenALStream::ThreadFunc(void* args)
@@ -146,14 +153,13 @@ void OpenALStream::SoundLoop()
while (!threadData)
{
-// soundCriticalSection.Enter();
if (iBuffersProcessed == iBuffersFilled)
{
alGetSourcei(uiSource, AL_BUFFERS_PROCESSED, &iBuffersProcessed);
iBuffersFilled = 0;
}
int numSamples = m_mixer->GetNumSamples();
- numSamples &= ~0x400;
+ numSamples &= ~0x100;
if (iBuffersProcessed && numSamples)
{
@@ -177,7 +183,6 @@ void OpenALStream::SoundLoop()
if (state != AL_PLAYING)
alSourcePlay(uiSource);
}
-// soundCriticalSection.Leave();
soundSyncEvent.Wait();
}
}