dynamic OpenAL DLL loading

git-svn-id: https://svn.code.sf.net/p/vbam/code/trunk@189 a31d4220-a93d-0410-bf67-fe4944624d44
This commit is contained in:
spacy51 2007-12-12 18:04:26 +00:00
parent 74d3361b31
commit bb250f3e7d
10 changed files with 729 additions and 96 deletions

448
src/win32/LoadOAL.cpp Normal file
View File

@ -0,0 +1,448 @@
/*
* Copyright (c) 2006, Creative Labs Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided
* that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this list of conditions and
* the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice, this list of conditions
* and the following disclaimer in the documentation and/or other materials provided with the distribution.
* * Neither the name of Creative Labs Inc. nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
* TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include "windows.h"
#include "LoadOAL.h"
HINSTANCE g_hOpenALDLL = NULL;
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable)
{
if (!lpOALFnTable)
return AL_FALSE;
if (szOALFullPathName)
g_hOpenALDLL = LoadLibrary(szOALFullPathName);
else
g_hOpenALDLL = LoadLibrary("openal32.dll");
if (!g_hOpenALDLL)
return AL_FALSE;
memset(lpOALFnTable, 0, sizeof(OPENALFNTABLE));
// Get function pointers
lpOALFnTable->alEnable = (LPALENABLE)GetProcAddress(g_hOpenALDLL, "alEnable");
if (lpOALFnTable->alEnable == NULL)
{
OutputDebugString("Failed to retrieve 'alEnable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDisable = (LPALDISABLE)GetProcAddress(g_hOpenALDLL, "alDisable");
if (lpOALFnTable->alDisable == NULL)
{
OutputDebugString("Failed to retrieve 'alDisable' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsEnabled = (LPALISENABLED)GetProcAddress(g_hOpenALDLL, "alIsEnabled");
if (lpOALFnTable->alIsEnabled == NULL)
{
OutputDebugString("Failed to retrieve 'alIsEnabled' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBoolean = (LPALGETBOOLEAN)GetProcAddress(g_hOpenALDLL, "alGetBoolean");
if (lpOALFnTable->alGetBoolean == NULL)
{
OutputDebugString("Failed to retrieve 'alGetBoolean' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetInteger = (LPALGETINTEGER)GetProcAddress(g_hOpenALDLL, "alGetInteger");
if (lpOALFnTable->alGetInteger == NULL)
{
OutputDebugString("Failed to retrieve 'alGetInteger' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloat = (LPALGETFLOAT)GetProcAddress(g_hOpenALDLL, "alGetFloat");
if (lpOALFnTable->alGetFloat == NULL)
{
OutputDebugString("Failed to retrieve 'alGetFloat' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDouble = (LPALGETDOUBLE)GetProcAddress(g_hOpenALDLL, "alGetDouble");
if (lpOALFnTable->alGetDouble == NULL)
{
OutputDebugString("Failed to retrieve 'alGetDouble' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBooleanv = (LPALGETBOOLEANV)GetProcAddress(g_hOpenALDLL, "alGetBooleanv");
if (lpOALFnTable->alGetBooleanv == NULL)
{
OutputDebugString("Failed to retrieve 'alGetBooleanv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetIntegerv = (LPALGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alGetIntegerv");
if (lpOALFnTable->alGetIntegerv == NULL)
{
OutputDebugString("Failed to retrieve 'alGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetFloatv = (LPALGETFLOATV)GetProcAddress(g_hOpenALDLL, "alGetFloatv");
if (lpOALFnTable->alGetFloatv == NULL)
{
OutputDebugString("Failed to retrieve 'alGetFloatv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetDoublev = (LPALGETDOUBLEV)GetProcAddress(g_hOpenALDLL, "alGetDoublev");
if (lpOALFnTable->alGetDoublev == NULL)
{
OutputDebugString("Failed to retrieve 'alGetDoublev' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetString = (LPALGETSTRING)GetProcAddress(g_hOpenALDLL, "alGetString");
if (lpOALFnTable->alGetString == NULL)
{
OutputDebugString("Failed to retrieve 'alGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetError = (LPALGETERROR)GetProcAddress(g_hOpenALDLL, "alGetError");
if (lpOALFnTable->alGetError == NULL)
{
OutputDebugString("Failed to retrieve 'alGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsExtensionPresent = (LPALISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alIsExtensionPresent");
if (lpOALFnTable->alIsExtensionPresent == NULL)
{
OutputDebugString("Failed to retrieve 'alIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetProcAddress = (LPALGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alGetProcAddress");
if (lpOALFnTable->alGetProcAddress == NULL)
{
OutputDebugString("Failed to retrieve 'alGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetEnumValue = (LPALGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alGetEnumValue");
if (lpOALFnTable->alGetEnumValue == NULL)
{
OutputDebugString("Failed to retrieve 'alGetEnumValue' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListeneri = (LPALLISTENERI)GetProcAddress(g_hOpenALDLL, "alListeneri");
if (lpOALFnTable->alListeneri == NULL)
{
OutputDebugString("Failed to retrieve 'alListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerf = (LPALLISTENERF)GetProcAddress(g_hOpenALDLL, "alListenerf");
if (lpOALFnTable->alListenerf == NULL)
{
OutputDebugString("Failed to retrieve 'alListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListener3f = (LPALLISTENER3F)GetProcAddress(g_hOpenALDLL, "alListener3f");
if (lpOALFnTable->alListener3f == NULL)
{
OutputDebugString("Failed to retrieve 'alListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alListenerfv = (LPALLISTENERFV)GetProcAddress(g_hOpenALDLL, "alListenerfv");
if (lpOALFnTable->alListenerfv == NULL)
{
OutputDebugString("Failed to retrieve 'alListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListeneri = (LPALGETLISTENERI)GetProcAddress(g_hOpenALDLL, "alGetListeneri");
if (lpOALFnTable->alGetListeneri == NULL)
{
OutputDebugString("Failed to retrieve 'alGetListeneri' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerf =(LPALGETLISTENERF)GetProcAddress(g_hOpenALDLL, "alGetListenerf");
if (lpOALFnTable->alGetListenerf == NULL)
{
OutputDebugString("Failed to retrieve 'alGetListenerf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListener3f = (LPALGETLISTENER3F)GetProcAddress(g_hOpenALDLL, "alGetListener3f");
if (lpOALFnTable->alGetListener3f == NULL)
{
OutputDebugString("Failed to retrieve 'alGetListener3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetListenerfv = (LPALGETLISTENERFV)GetProcAddress(g_hOpenALDLL, "alGetListenerfv");
if (lpOALFnTable->alGetListenerfv == NULL)
{
OutputDebugString("Failed to retrieve 'alGetListenerfv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenSources = (LPALGENSOURCES)GetProcAddress(g_hOpenALDLL, "alGenSources");
if (lpOALFnTable->alGenSources == NULL)
{
OutputDebugString("Failed to retrieve 'alGenSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteSources = (LPALDELETESOURCES)GetProcAddress(g_hOpenALDLL, "alDeleteSources");
if (lpOALFnTable->alDeleteSources == NULL)
{
OutputDebugString("Failed to retrieve 'alDeleteSources' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsSource = (LPALISSOURCE)GetProcAddress(g_hOpenALDLL, "alIsSource");
if (lpOALFnTable->alIsSource == NULL)
{
OutputDebugString("Failed to retrieve 'alIsSource' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcei = (LPALSOURCEI)GetProcAddress(g_hOpenALDLL, "alSourcei");
if (lpOALFnTable->alSourcei == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcef = (LPALSOURCEF)GetProcAddress(g_hOpenALDLL, "alSourcef");
if (lpOALFnTable->alSourcef == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSource3f = (LPALSOURCE3F)GetProcAddress(g_hOpenALDLL, "alSource3f");
if (lpOALFnTable->alSource3f == NULL)
{
OutputDebugString("Failed to retrieve 'alSource3f' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcefv = (LPALSOURCEFV)GetProcAddress(g_hOpenALDLL, "alSourcefv");
if (lpOALFnTable->alSourcefv == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcei = (LPALGETSOURCEI)GetProcAddress(g_hOpenALDLL, "alGetSourcei");
if (lpOALFnTable->alGetSourcei == NULL)
{
OutputDebugString("Failed to retrieve 'alGetSourcei' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcef = (LPALGETSOURCEF)GetProcAddress(g_hOpenALDLL, "alGetSourcef");
if (lpOALFnTable->alGetSourcef == NULL)
{
OutputDebugString("Failed to retrieve 'alGetSourcef' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetSourcefv = (LPALGETSOURCEFV)GetProcAddress(g_hOpenALDLL, "alGetSourcefv");
if (lpOALFnTable->alGetSourcefv == NULL)
{
OutputDebugString("Failed to retrieve 'alGetSourcefv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlayv = (LPALSOURCEPLAYV)GetProcAddress(g_hOpenALDLL, "alSourcePlayv");
if (lpOALFnTable->alSourcePlayv == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcePlayv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStopv = (LPALSOURCESTOPV)GetProcAddress(g_hOpenALDLL, "alSourceStopv");
if (lpOALFnTable->alSourceStopv == NULL)
{
OutputDebugString("Failed to retrieve 'alSourceStopv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePlay = (LPALSOURCEPLAY)GetProcAddress(g_hOpenALDLL, "alSourcePlay");
if (lpOALFnTable->alSourcePlay == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcePlay' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourcePause = (LPALSOURCEPAUSE)GetProcAddress(g_hOpenALDLL, "alSourcePause");
if (lpOALFnTable->alSourcePause == NULL)
{
OutputDebugString("Failed to retrieve 'alSourcePause' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceStop = (LPALSOURCESTOP)GetProcAddress(g_hOpenALDLL, "alSourceStop");
if (lpOALFnTable->alSourceStop == NULL)
{
OutputDebugString("Failed to retrieve 'alSourceStop' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGenBuffers = (LPALGENBUFFERS)GetProcAddress(g_hOpenALDLL, "alGenBuffers");
if (lpOALFnTable->alGenBuffers == NULL)
{
OutputDebugString("Failed to retrieve 'alGenBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDeleteBuffers = (LPALDELETEBUFFERS)GetProcAddress(g_hOpenALDLL, "alDeleteBuffers");
if (lpOALFnTable->alDeleteBuffers == NULL)
{
OutputDebugString("Failed to retrieve 'alDeleteBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alIsBuffer = (LPALISBUFFER)GetProcAddress(g_hOpenALDLL, "alIsBuffer");
if (lpOALFnTable->alIsBuffer == NULL)
{
OutputDebugString("Failed to retrieve 'alIsBuffer' function address\n");
return AL_FALSE;
}
lpOALFnTable->alBufferData = (LPALBUFFERDATA)GetProcAddress(g_hOpenALDLL, "alBufferData");
if (lpOALFnTable->alBufferData == NULL)
{
OutputDebugString("Failed to retrieve 'alBufferData' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferi = (LPALGETBUFFERI)GetProcAddress(g_hOpenALDLL, "alGetBufferi");
if (lpOALFnTable->alGetBufferi == NULL)
{
OutputDebugString("Failed to retrieve 'alGetBufferi' function address\n");
return AL_FALSE;
}
lpOALFnTable->alGetBufferf = (LPALGETBUFFERF)GetProcAddress(g_hOpenALDLL, "alGetBufferf");
if (lpOALFnTable->alGetBufferf == NULL)
{
OutputDebugString("Failed to retrieve 'alGetBufferf' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceQueueBuffers = (LPALSOURCEQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceQueueBuffers");
if (lpOALFnTable->alSourceQueueBuffers == NULL)
{
OutputDebugString("Failed to retrieve 'alSourceQueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alSourceUnqueueBuffers = (LPALSOURCEUNQUEUEBUFFERS)GetProcAddress(g_hOpenALDLL, "alSourceUnqueueBuffers");
if (lpOALFnTable->alSourceUnqueueBuffers == NULL)
{
OutputDebugString("Failed to retrieve 'alSourceUnqueueBuffers' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDistanceModel = (LPALDISTANCEMODEL)GetProcAddress(g_hOpenALDLL, "alDistanceModel");
if (lpOALFnTable->alDistanceModel == NULL)
{
OutputDebugString("Failed to retrieve 'alDistanceModel' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerFactor = (LPALDOPPLERFACTOR)GetProcAddress(g_hOpenALDLL, "alDopplerFactor");
if (lpOALFnTable->alDopplerFactor == NULL)
{
OutputDebugString("Failed to retrieve 'alDopplerFactor' function address\n");
return AL_FALSE;
}
lpOALFnTable->alDopplerVelocity = (LPALDOPPLERVELOCITY)GetProcAddress(g_hOpenALDLL, "alDopplerVelocity");
if (lpOALFnTable->alDopplerVelocity == NULL)
{
OutputDebugString("Failed to retrieve 'alDopplerVelocity' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetString = (LPALCGETSTRING)GetProcAddress(g_hOpenALDLL, "alcGetString");
if (lpOALFnTable->alcGetString == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetString' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetIntegerv = (LPALCGETINTEGERV)GetProcAddress(g_hOpenALDLL, "alcGetIntegerv");
if (lpOALFnTable->alcGetIntegerv == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetIntegerv' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcOpenDevice = (LPALCOPENDEVICE)GetProcAddress(g_hOpenALDLL, "alcOpenDevice");
if (lpOALFnTable->alcOpenDevice == NULL)
{
OutputDebugString("Failed to retrieve 'alcOpenDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCloseDevice = (LPALCCLOSEDEVICE)GetProcAddress(g_hOpenALDLL, "alcCloseDevice");
if (lpOALFnTable->alcCloseDevice == NULL)
{
OutputDebugString("Failed to retrieve 'alcCloseDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcCreateContext = (LPALCCREATECONTEXT)GetProcAddress(g_hOpenALDLL, "alcCreateContext");
if (lpOALFnTable->alcCreateContext == NULL)
{
OutputDebugString("Failed to retrieve 'alcCreateContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcMakeContextCurrent = (LPALCMAKECONTEXTCURRENT)GetProcAddress(g_hOpenALDLL, "alcMakeContextCurrent");
if (lpOALFnTable->alcMakeContextCurrent == NULL)
{
OutputDebugString("Failed to retrieve 'alcMakeContextCurrent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcProcessContext = (LPALCPROCESSCONTEXT)GetProcAddress(g_hOpenALDLL, "alcProcessContext");
if (lpOALFnTable->alcProcessContext == NULL)
{
OutputDebugString("Failed to retrieve 'alcProcessContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetCurrentContext = (LPALCGETCURRENTCONTEXT)GetProcAddress(g_hOpenALDLL, "alcGetCurrentContext");
if (lpOALFnTable->alcGetCurrentContext == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetCurrentContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetContextsDevice = (LPALCGETCONTEXTSDEVICE)GetProcAddress(g_hOpenALDLL, "alcGetContextsDevice");
if (lpOALFnTable->alcGetContextsDevice == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetContextsDevice' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcSuspendContext = (LPALCSUSPENDCONTEXT)GetProcAddress(g_hOpenALDLL, "alcSuspendContext");
if (lpOALFnTable->alcSuspendContext == NULL)
{
OutputDebugString("Failed to retrieve 'alcSuspendContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcDestroyContext = (LPALCDESTROYCONTEXT)GetProcAddress(g_hOpenALDLL, "alcDestroyContext");
if (lpOALFnTable->alcDestroyContext == NULL)
{
OutputDebugString("Failed to retrieve 'alcDestroyContext' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetError = (LPALCGETERROR)GetProcAddress(g_hOpenALDLL, "alcGetError");
if (lpOALFnTable->alcGetError == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetError' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcIsExtensionPresent = (LPALCISEXTENSIONPRESENT)GetProcAddress(g_hOpenALDLL, "alcIsExtensionPresent");
if (lpOALFnTable->alcIsExtensionPresent == NULL)
{
OutputDebugString("Failed to retrieve 'alcIsExtensionPresent' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetProcAddress = (LPALCGETPROCADDRESS)GetProcAddress(g_hOpenALDLL, "alcGetProcAddress");
if (lpOALFnTable->alcGetProcAddress == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetProcAddress' function address\n");
return AL_FALSE;
}
lpOALFnTable->alcGetEnumValue = (LPALCGETENUMVALUE)GetProcAddress(g_hOpenALDLL, "alcGetEnumValue");
if (lpOALFnTable->alcGetEnumValue == NULL)
{
OutputDebugString("Failed to retrieve 'alcGetEnumValue' function address\n");
return AL_FALSE;
}
return AL_TRUE;
}
ALvoid UnloadOAL10Library()
{
// Unload the dll
if (g_hOpenALDLL)
{
FreeLibrary(g_hOpenALDLL);
g_hOpenALDLL = NULL;
}
}

164
src/win32/LoadOAL.h Normal file
View File

@ -0,0 +1,164 @@
#include <al.h>
#include <alc.h>
// Open AL Function table definition
#ifndef _OPENALFNTABLE
#define _OPENALFNTABLE
// AL 1.0 did not define the ALchar and ALCchar types, so define them here
// if they don't exist
#ifndef ALchar
#define ALchar char
#endif
#ifndef ALCchar
#define ALCchar char
#endif
// Complete list of functions available in AL 1.0 implementations
typedef void (ALAPIENTRY *LPALENABLE)( ALenum capability );
typedef void (ALAPIENTRY *LPALDISABLE)( ALenum capability );
typedef ALboolean (ALAPIENTRY *LPALISENABLED)( ALenum capability );
typedef const ALchar* (ALAPIENTRY *LPALGETSTRING)( ALenum param );
typedef void (ALAPIENTRY *LPALGETBOOLEANV)( ALenum param, ALboolean* data );
typedef void (ALAPIENTRY *LPALGETINTEGERV)( ALenum param, ALint* data );
typedef void (ALAPIENTRY *LPALGETFLOATV)( ALenum param, ALfloat* data );
typedef void (ALAPIENTRY *LPALGETDOUBLEV)( ALenum param, ALdouble* data );
typedef ALboolean (ALAPIENTRY *LPALGETBOOLEAN)( ALenum param );
typedef ALint (ALAPIENTRY *LPALGETINTEGER)( ALenum param );
typedef ALfloat (ALAPIENTRY *LPALGETFLOAT)( ALenum param );
typedef ALdouble (ALAPIENTRY *LPALGETDOUBLE)( ALenum param );
typedef ALenum (ALAPIENTRY *LPALGETERROR)( void );
typedef ALboolean (ALAPIENTRY *LPALISEXTENSIONPRESENT)(const ALchar* extname );
typedef void* (ALAPIENTRY *LPALGETPROCADDRESS)( const ALchar* fname );
typedef ALenum (ALAPIENTRY *LPALGETENUMVALUE)( const ALchar* ename );
typedef void (ALAPIENTRY *LPALLISTENERF)( ALenum param, ALfloat value );
typedef void (ALAPIENTRY *LPALLISTENER3F)( ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
typedef void (ALAPIENTRY *LPALLISTENERFV)( ALenum param, const ALfloat* values );
typedef void (ALAPIENTRY *LPALLISTENERI)( ALenum param, ALint value );
typedef void (ALAPIENTRY *LPALGETLISTENERF)( ALenum param, ALfloat* value );
typedef void (ALAPIENTRY *LPALGETLISTENER3F)( ALenum param, ALfloat *value1, ALfloat *value2, ALfloat *value3 );
typedef void (ALAPIENTRY *LPALGETLISTENERFV)( ALenum param, ALfloat* values );
typedef void (ALAPIENTRY *LPALGETLISTENERI)( ALenum param, ALint* value );
typedef void (ALAPIENTRY *LPALGENSOURCES)( ALsizei n, ALuint* sources );
typedef void (ALAPIENTRY *LPALDELETESOURCES)( ALsizei n, const ALuint* sources );
typedef ALboolean (ALAPIENTRY *LPALISSOURCE)( ALuint sid );
typedef void (ALAPIENTRY *LPALSOURCEF)( ALuint sid, ALenum param, ALfloat value);
typedef void (ALAPIENTRY *LPALSOURCE3F)( ALuint sid, ALenum param, ALfloat value1, ALfloat value2, ALfloat value3 );
typedef void (ALAPIENTRY *LPALSOURCEFV)( ALuint sid, ALenum param, const ALfloat* values );
typedef void (ALAPIENTRY *LPALSOURCEI)( ALuint sid, ALenum param, ALint value);
typedef void (ALAPIENTRY *LPALGETSOURCEF)( ALuint sid, ALenum param, ALfloat* value );
typedef void (ALAPIENTRY *LPALGETSOURCE3F)( ALuint sid, ALenum param, ALfloat* value1, ALfloat* value2, ALfloat* value3);
typedef void (ALAPIENTRY *LPALGETSOURCEFV)( ALuint sid, ALenum param, ALfloat* values );
typedef void (ALAPIENTRY *LPALGETSOURCEI)( ALuint sid, ALenum param, ALint* value );
typedef void (ALAPIENTRY *LPALSOURCEPLAYV)( ALsizei ns, const ALuint *sids );
typedef void (ALAPIENTRY *LPALSOURCESTOPV)( ALsizei ns, const ALuint *sids );
typedef void (ALAPIENTRY *LPALSOURCEREWINDV)( ALsizei ns, const ALuint *sids );
typedef void (ALAPIENTRY *LPALSOURCEPAUSEV)( ALsizei ns, const ALuint *sids );
typedef void (ALAPIENTRY *LPALSOURCEPLAY)( ALuint sid );
typedef void (ALAPIENTRY *LPALSOURCESTOP)( ALuint sid );
typedef void (ALAPIENTRY *LPALSOURCEREWIND)( ALuint sid );
typedef void (ALAPIENTRY *LPALSOURCEPAUSE)( ALuint sid );
typedef void (ALAPIENTRY *LPALSOURCEQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, const ALuint *bids );
typedef void (ALAPIENTRY *LPALSOURCEUNQUEUEBUFFERS)(ALuint sid, ALsizei numEntries, ALuint *bids );
typedef void (ALAPIENTRY *LPALGENBUFFERS)( ALsizei n, ALuint* buffers );
typedef void (ALAPIENTRY *LPALDELETEBUFFERS)( ALsizei n, const ALuint* buffers );
typedef ALboolean (ALAPIENTRY *LPALISBUFFER)( ALuint bid );
typedef void (ALAPIENTRY *LPALBUFFERDATA)( ALuint bid, ALenum format, const ALvoid* data, ALsizei size, ALsizei freq );
typedef void (ALAPIENTRY *LPALGETBUFFERF)( ALuint bid, ALenum param, ALfloat* value );
typedef void (ALAPIENTRY *LPALGETBUFFERI)( ALuint bid, ALenum param, ALint* value );
typedef void (ALAPIENTRY *LPALDOPPLERFACTOR)( ALfloat value );
typedef void (ALAPIENTRY *LPALDOPPLERVELOCITY)( ALfloat value );
typedef void (ALAPIENTRY *LPALDISTANCEMODEL)( ALenum distanceModel );
typedef ALCcontext * (ALCAPIENTRY *LPALCCREATECONTEXT) (ALCdevice *device, const ALCint *attrlist);
typedef ALCboolean (ALCAPIENTRY *LPALCMAKECONTEXTCURRENT)( ALCcontext *context );
typedef void (ALCAPIENTRY *LPALCPROCESSCONTEXT)( ALCcontext *context );
typedef void (ALCAPIENTRY *LPALCSUSPENDCONTEXT)( ALCcontext *context );
typedef void (ALCAPIENTRY *LPALCDESTROYCONTEXT)( ALCcontext *context );
typedef ALCcontext * (ALCAPIENTRY *LPALCGETCURRENTCONTEXT)( ALCvoid );
typedef ALCdevice * (ALCAPIENTRY *LPALCGETCONTEXTSDEVICE)( ALCcontext *context );
typedef ALCdevice * (ALCAPIENTRY *LPALCOPENDEVICE)( const ALCchar *devicename );
typedef ALCboolean (ALCAPIENTRY *LPALCCLOSEDEVICE)( ALCdevice *device );
typedef ALCenum (ALCAPIENTRY *LPALCGETERROR)( ALCdevice *device );
typedef ALCboolean (ALCAPIENTRY *LPALCISEXTENSIONPRESENT)( ALCdevice *device, const ALCchar *extname );
typedef void * (ALCAPIENTRY *LPALCGETPROCADDRESS)(ALCdevice *device, const ALCchar *funcname );
typedef ALCenum (ALCAPIENTRY *LPALCGETENUMVALUE)(ALCdevice *device, const ALCchar *enumname );
typedef const ALCchar* (ALCAPIENTRY *LPALCGETSTRING)( ALCdevice *device, ALCenum param );
typedef void (ALCAPIENTRY *LPALCGETINTEGERV)( ALCdevice *device, ALCenum param, ALCsizei size, ALCint *dest );
typedef struct
{
LPALENABLE alEnable;
LPALDISABLE alDisable;
LPALISENABLED alIsEnabled;
LPALGETBOOLEAN alGetBoolean;
LPALGETINTEGER alGetInteger;
LPALGETFLOAT alGetFloat;
LPALGETDOUBLE alGetDouble;
LPALGETBOOLEANV alGetBooleanv;
LPALGETINTEGERV alGetIntegerv;
LPALGETFLOATV alGetFloatv;
LPALGETDOUBLEV alGetDoublev;
LPALGETSTRING alGetString;
LPALGETERROR alGetError;
LPALISEXTENSIONPRESENT alIsExtensionPresent;
LPALGETPROCADDRESS alGetProcAddress;
LPALGETENUMVALUE alGetEnumValue;
LPALLISTENERI alListeneri;
LPALLISTENERF alListenerf;
LPALLISTENER3F alListener3f;
LPALLISTENERFV alListenerfv;
LPALGETLISTENERI alGetListeneri;
LPALGETLISTENERF alGetListenerf;
LPALGETLISTENER3F alGetListener3f;
LPALGETLISTENERFV alGetListenerfv;
LPALGENSOURCES alGenSources;
LPALDELETESOURCES alDeleteSources;
LPALISSOURCE alIsSource;
LPALSOURCEI alSourcei;
LPALSOURCEF alSourcef;
LPALSOURCE3F alSource3f;
LPALSOURCEFV alSourcefv;
LPALGETSOURCEI alGetSourcei;
LPALGETSOURCEF alGetSourcef;
LPALGETSOURCEFV alGetSourcefv;
LPALSOURCEPLAYV alSourcePlayv;
LPALSOURCESTOPV alSourceStopv;
LPALSOURCEPLAY alSourcePlay;
LPALSOURCEPAUSE alSourcePause;
LPALSOURCESTOP alSourceStop;
LPALGENBUFFERS alGenBuffers;
LPALDELETEBUFFERS alDeleteBuffers;
LPALISBUFFER alIsBuffer;
LPALBUFFERDATA alBufferData;
LPALGETBUFFERI alGetBufferi;
LPALGETBUFFERF alGetBufferf;
LPALSOURCEQUEUEBUFFERS alSourceQueueBuffers;
LPALSOURCEUNQUEUEBUFFERS alSourceUnqueueBuffers;
LPALDISTANCEMODEL alDistanceModel;
LPALDOPPLERFACTOR alDopplerFactor;
LPALDOPPLERVELOCITY alDopplerVelocity;
LPALCGETSTRING alcGetString;
LPALCGETINTEGERV alcGetIntegerv;
LPALCOPENDEVICE alcOpenDevice;
LPALCCLOSEDEVICE alcCloseDevice;
LPALCCREATECONTEXT alcCreateContext;
LPALCMAKECONTEXTCURRENT alcMakeContextCurrent;
LPALCPROCESSCONTEXT alcProcessContext;
LPALCGETCURRENTCONTEXT alcGetCurrentContext;
LPALCGETCONTEXTSDEVICE alcGetContextsDevice;
LPALCSUSPENDCONTEXT alcSuspendContext;
LPALCDESTROYCONTEXT alcDestroyContext;
LPALCGETERROR alcGetError;
LPALCISEXTENSIONPRESENT alcIsExtensionPresent;
LPALCGETPROCADDRESS alcGetProcAddress;
LPALCGETENUMVALUE alcGetEnumValue;
} OPENALFNTABLE, *LPOPENALFNTABLE;
#endif
ALboolean LoadOAL10Library(char *szOALFullPathName, LPOPENALFNTABLE lpOALFnTable);
ALvoid UnloadOAL10Library();

View File

@ -1980,8 +1980,8 @@ void MainWnd::OnUpdateOutputapiDirectsound(CCmdUI *pCmdUI)
void MainWnd::OnOutputapiOpenal() void MainWnd::OnOutputapiOpenal()
{ {
#ifndef NO_OAL #ifndef NO_OAL
if( theApp.audioAPI != OPENAL ) { if( theApp.audioAPI != OPENAL_SOUND ) {
theApp.audioAPI = OPENAL; theApp.audioAPI = OPENAL_SOUND;
systemSoundShutdown(); systemSoundShutdown();
systemSoundInit(); systemSoundInit();
} }
@ -1991,7 +1991,7 @@ void MainWnd::OnOutputapiOpenal()
void MainWnd::OnUpdateOutputapiOpenal(CCmdUI *pCmdUI) void MainWnd::OnUpdateOutputapiOpenal(CCmdUI *pCmdUI)
{ {
#ifndef NO_OAL #ifndef NO_OAL
pCmdUI->SetCheck( ( theApp.audioAPI == OPENAL ) ? 1 : 0 ); pCmdUI->SetCheck( ( theApp.audioAPI == OPENAL_SOUND ) ? 1 : 0 );
#endif #endif
} }

View File

@ -9,7 +9,7 @@
// OpenAL // OpenAL
#include <al.h> #include <al.h>
#include <alc.h> #include <alc.h>
#pragma comment( lib, "OpenAL32.lib" ) #include "LoadOAL.h"
// OALConfig dialog // OALConfig dialog
@ -35,7 +35,7 @@ void OALConfig::DoDataExchange(CDataExchange* pDX)
if( !pDX->m_bSaveAndValidate ) { if( !pDX->m_bSaveAndValidate ) {
// enumerate devices // enumerate devices
const ALchar *devices = NULL; const ALchar *devices = NULL;
devices = alcGetString( NULL, ALC_DEVICE_SPECIFIER ); devices = ALFunction.alcGetString( NULL, ALC_DEVICE_SPECIFIER );
if( strlen( devices ) ) { if( strlen( devices ) ) {
while( *devices ) { while( *devices ) {
cbDevice.AddString( devices ); cbDevice.AddString( devices );
@ -54,6 +54,11 @@ BOOL OALConfig::OnInitDialog()
{ {
CDialog::OnInitDialog(); CDialog::OnInitDialog();
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
return false;
}
return TRUE; return TRUE;
} }

View File

@ -3,6 +3,11 @@
#pragma once #pragma once
#include "afxwin.h" #include "afxwin.h"
// OpenAL
#include <al.h>
#include <alc.h>
#include "LoadOAL.h"
// OALConfig dialog // OALConfig dialog
@ -24,6 +29,7 @@ protected:
DECLARE_MESSAGE_MAP() DECLARE_MESSAGE_MAP()
private: private:
CComboBox cbDevice; CComboBox cbDevice;
OPENALFNTABLE ALFunction;
public: public:
CString selectedDevice; CString selectedDevice;
}; };

View File

@ -25,7 +25,7 @@
// OpenAL // OpenAL
#include <al.h> #include <al.h>
#include <alc.h> #include <alc.h>
#pragma comment( lib, "OpenAL32.lib" ) #include "LoadOAL.h"
// Windows // Windows
#include <windows.h> // for 'Sleep' function #include <windows.h> // for 'Sleep' function
@ -60,6 +60,7 @@ public:
void write(); // write the emulated sound to the secondary sound buffer void write(); // write the emulated sound to the secondary sound buffer
private: private:
OPENALFNTABLE ALFunction;
bool initialized; bool initialized;
bool buffersLoaded; bool buffersLoaded;
ALCdevice *device; ALCdevice *device;
@ -89,26 +90,28 @@ OpenAL::OpenAL()
OpenAL::~OpenAL() OpenAL::~OpenAL()
{ {
alSourceStop( source ); if( !initialized ) return;
assert( AL_NO_ERROR == alGetError() );
alSourcei( source, AL_BUFFER, 0 ); ALFunction.alSourceStop( source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alDeleteSources( 1, &source ); ALFunction.alSourcei( source, AL_BUFFER, 0 );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alDeleteBuffers( NBUFFERS, buffer ); ALFunction.alDeleteSources( 1, &source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alcMakeContextCurrent( NULL ); ALFunction.alDeleteBuffers( NBUFFERS, buffer );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alcDestroyContext( context ); ALFunction.alcMakeContextCurrent( NULL );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alcCloseDevice( device ); ALFunction.alcDestroyContext( context );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
ALFunction.alcCloseDevice( device );
assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
#ifdef LOGALL #ifdef LOGALL
@ -116,8 +119,8 @@ void OpenAL::debugState()
{ {
ALint value = 0; ALint value = 0;
alGetSourcei( source, AL_SOURCE_STATE, &value ); ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &value );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
winlog( " soundPaused = %i\n", soundPaused ); winlog( " soundPaused = %i\n", soundPaused );
winlog( " Source:\n" ); winlog( " Source:\n" );
@ -142,12 +145,12 @@ void OpenAL::debugState()
} }
alGetSourcei( source, AL_BUFFERS_QUEUED, &value ); ALFunction.alGetSourcei( source, AL_BUFFERS_QUEUED, &value );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
winlog( " Buffers in queue: %i\n", value ); winlog( " Buffers in queue: %i\n", value );
alGetSourcei( source, AL_BUFFERS_PROCESSED, &value ); ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &value );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
winlog( " Buffers processed: %i\n", value ); winlog( " Buffers processed: %i\n", value );
} }
#endif #endif
@ -158,24 +161,29 @@ bool OpenAL::init()
winlog( "OpenAL::init\n" ); winlog( "OpenAL::init\n" );
assert( initialized == false ); assert( initialized == false );
if( !LoadOAL10Library( NULL, &ALFunction ) ) {
systemMessage( IDS_OAL_NODLL, "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org" );
return false;
}
if( theApp.oalDevice ) { if( theApp.oalDevice ) {
device = alcOpenDevice( theApp.oalDevice ); device = ALFunction.alcOpenDevice( theApp.oalDevice );
} else { } else {
device = alcOpenDevice( NULL ); device = ALFunction.alcOpenDevice( NULL );
} }
assert( device != NULL ); assert( device != NULL );
context = alcCreateContext( device, NULL ); context = ALFunction.alcCreateContext( device, NULL );
assert( context != NULL ); assert( context != NULL );
ALCboolean retVal = alcMakeContextCurrent( context ); ALCboolean retVal = ALFunction.alcMakeContextCurrent( context );
assert( ALC_TRUE == retVal ); assert( ALC_TRUE == retVal );
alGenBuffers( NBUFFERS, buffer ); ALFunction.alGenBuffers( NBUFFERS, buffer );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alGenSources( 1, &source ); ALFunction.alGenSources( 1, &source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
freq = 44100 / soundQuality; freq = 44100 / soundQuality;
// calculate the number of samples per frame first // calculate the number of samples per frame first
@ -191,18 +199,18 @@ bool OpenAL::init()
void OpenAL::resume() void OpenAL::resume()
{ {
if( !initialized ) return;
winlog( "OpenAL::resume\n" ); winlog( "OpenAL::resume\n" );
assert( initialized );
if( !buffersLoaded ) return; if( !buffersLoaded ) return;
debugState(); debugState();
ALint sourceState = 0; ALint sourceState = 0;
alGetSourcei( source, AL_SOURCE_STATE, &sourceState ); ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
if( sourceState != AL_PLAYING ) { if( sourceState != AL_PLAYING ) {
alSourcePlay( source ); ALFunction.alSourcePlay( source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
debugState(); debugState();
} }
@ -210,18 +218,18 @@ void OpenAL::resume()
void OpenAL::pause() void OpenAL::pause()
{ {
if( !initialized ) return;
winlog( "OpenAL::pause\n" ); winlog( "OpenAL::pause\n" );
assert( initialized );
if( !buffersLoaded ) return; if( !buffersLoaded ) return;
debugState(); debugState();
ALint sourceState = 0; ALint sourceState = 0;
alGetSourcei( source, AL_SOURCE_STATE, &sourceState ); ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
if( sourceState == AL_PLAYING ) { if( sourceState == AL_PLAYING ) {
alSourcePause( source ); ALFunction.alSourcePause( source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
debugState(); debugState();
} }
@ -229,17 +237,17 @@ void OpenAL::pause()
void OpenAL::reset() void OpenAL::reset()
{ {
if( !initialized ) return;
winlog( "OpenAL::reset\n" ); winlog( "OpenAL::reset\n" );
assert( initialized );
if( !buffersLoaded ) return; if( !buffersLoaded ) return;
debugState(); debugState();
ALint sourceState = 0; ALint sourceState = 0;
alGetSourcei( source, AL_SOURCE_STATE, &sourceState ); ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
if( sourceState != AL_STOPPED ) { if( sourceState != AL_STOPPED ) {
alSourceStop( source ); ALFunction.alSourceStop( source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
debugState(); debugState();
} }
@ -247,8 +255,8 @@ void OpenAL::reset()
void OpenAL::write() void OpenAL::write()
{ {
if( !initialized ) return;
winlog( "OpenAL::write\n" ); winlog( "OpenAL::write\n" );
assert( initialized );
debugState(); debugState();
@ -260,19 +268,19 @@ void OpenAL::write()
winlog( " initial buffer filling\n" ); winlog( " initial buffer filling\n" );
for( int i = 0 ; i < NBUFFERS ; i++ ) { for( int i = 0 ; i < NBUFFERS ; i++ ) {
// filling the buffers explicitly with silence would be cleaner... // filling the buffers explicitly with silence would be cleaner...
alBufferData( buffer[i], AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq ); ALFunction.alBufferData( buffer[i], AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
alSourceQueueBuffers( source, NBUFFERS, buffer ); ALFunction.alSourceQueueBuffers( source, NBUFFERS, buffer );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
buffersLoaded = true; buffersLoaded = true;
} else { } else {
// ==normal buffer refreshing== // ==normal buffer refreshing==
nBuffersProcessed = 0; nBuffersProcessed = 0;
alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed ); ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
if( !speedup && synchronize && !theApp.throttle ) { if( !speedup && synchronize && !theApp.throttle ) {
// wait until at least one buffer has finished // wait until at least one buffer has finished
@ -281,8 +289,8 @@ void OpenAL::write()
// wait for about half the time one buffer needs to finish // wait for about half the time one buffer needs to finish
// unoptimized: ( sourceBufferLen * 1000 ) / ( freq * 2 * 2 ) * 1/2 // unoptimized: ( sourceBufferLen * 1000 ) / ( freq * 2 * 2 ) * 1/2
Sleep( soundBufferLen / ( freq >> 7 ) ); Sleep( soundBufferLen / ( freq >> 7 ) );
alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed ); ALFunction.alGetSourcei( source, AL_BUFFERS_PROCESSED, &nBuffersProcessed );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
} else { } else {
if( nBuffersProcessed == 0 ) return; if( nBuffersProcessed == 0 ) return;
@ -292,23 +300,23 @@ void OpenAL::write()
// tempBuffer contains the Buffer ID for the unqueued Buffer // tempBuffer contains the Buffer ID for the unqueued Buffer
tempBuffer = 0; tempBuffer = 0;
alSourceUnqueueBuffers( source, 1, &tempBuffer ); ALFunction.alSourceUnqueueBuffers( source, 1, &tempBuffer );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
alBufferData( tempBuffer, AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq ); ALFunction.alBufferData( tempBuffer, AL_FORMAT_STEREO16, soundFinalWave, soundBufferLen, freq );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
// refill buffer // refill buffer
alSourceQueueBuffers( source, 1, &tempBuffer ); ALFunction.alSourceQueueBuffers( source, 1, &tempBuffer );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
// start playing the source if necessary // start playing the source if necessary
alGetSourcei( source, AL_SOURCE_STATE, &sourceState ); ALFunction.alGetSourcei( source, AL_SOURCE_STATE, &sourceState );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
if( !soundPaused && ( sourceState != AL_PLAYING ) ) { if( !soundPaused && ( sourceState != AL_PLAYING ) ) {
alSourcePlay( source ); ALFunction.alSourcePlay( source );
assert( AL_NO_ERROR == alGetError() ); assert( AL_NO_ERROR == ALFunction.alGetError() );
} }
} }

View File

@ -23,7 +23,7 @@
enum AUDIO_API { enum AUDIO_API {
DIRECTSOUND DIRECTSOUND
#ifndef NO_OAL #ifndef NO_OAL
, OPENAL , OPENAL_SOUND
#endif #endif
}; };

View File

@ -1214,7 +1214,7 @@ bool systemSoundInit()
theApp.sound = newDirectSound(); theApp.sound = newDirectSound();
break; break;
#ifndef NO_OAL #ifndef NO_OAL
case OPENAL: case OPENAL_SOUND:
theApp.sound = newOpenAL(); theApp.sound = newOpenAL();
break; break;
#endif #endif
@ -1431,7 +1431,7 @@ void VBA::loadSettings()
audioAPI = (AUDIO_API)regQueryDwordValue( "audioAPI", DIRECTSOUND ); audioAPI = (AUDIO_API)regQueryDwordValue( "audioAPI", DIRECTSOUND );
if( ( audioAPI != DIRECTSOUND ) if( ( audioAPI != DIRECTSOUND )
#ifndef NO_OAL #ifndef NO_OAL
&& ( audioAPI != OPENAL ) && ( audioAPI != OPENAL_SOUND )
#endif #endif
) { ) {
audioAPI = DIRECTSOUND; audioAPI = DIRECTSOUND;

View File

@ -69,31 +69,6 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
#pragma code_page(1252) #pragma code_page(1252)
#endif //_WIN32 #endif //_WIN32
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""resource2.h""\0"
END
3 TEXTINCLUDE
BEGIN
"#include ""vba.rc2""\0"
END
#endif // APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Dialog // Dialog
@ -1499,6 +1474,31 @@ END
#endif // APSTUDIO_INVOKED #endif // APSTUDIO_INVOKED
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"#include ""resource2.h""\0"
END
3 TEXTINCLUDE
BEGIN
"#include ""vba.rc2""\0"
END
#endif // APSTUDIO_INVOKED
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
// //
// Menu // Menu
@ -2201,6 +2201,7 @@ BEGIN
IDS_REGISTRY "VisualBoyAdvance no longer uses the registry to store its settings. Your previous settings have been exported into the file: %s" IDS_REGISTRY "VisualBoyAdvance no longer uses the registry to store its settings. Your previous settings have been exported into the file: %s"
IDS_MOVIE_PLAY "Playing a movie will load a save state which may erase your previous battery saves. Please be sure to have a saved state if you don't want to loose any previous data." IDS_MOVIE_PLAY "Playing a movie will load a save state which may erase your previous battery saves. Please be sure to have a saved state if you don't want to loose any previous data."
IDS_OAL_NODEVICE "There are no sound devices present on this system." IDS_OAL_NODEVICE "There are no sound devices present on this system."
IDS_OAL_NODLL "OpenAL32.dll could not be found on your system. Please install the runtime from http://openal.org"
END END
#endif // English (U.S.) resources #endif // English (U.S.) resources

View File

@ -382,6 +382,7 @@
#define IDS_MOVIE_PLAY 1138 #define IDS_MOVIE_PLAY 1138
#define IDS_OAL_NODEVICE 1139 #define IDS_OAL_NODEVICE 1139
#define IDC_VIEWER 1140 #define IDC_VIEWER 1140
#define IDS_OAL_NODLL 1140
#define IDC_ADDRESSES 1141 #define IDC_ADDRESSES 1141
#define IDC_GO 1143 #define IDC_GO 1143
#define IDC_8_BIT 1144 #define IDC_8_BIT 1144