Use a better name for the device list init function and make it static

This commit is contained in:
Chris Robinson 2007-11-15 01:34:57 -08:00
parent f3d9421e90
commit 059a312c24

View File

@ -43,8 +43,6 @@
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// FUNCTION PROTOTYPES // FUNCTION PROTOTYPES
void fill_device_list();
void alc_alsa_init(BackendFuncs *func_list); void alc_alsa_init(BackendFuncs *func_list);
void alc_oss_init(BackendFuncs *func_list); void alc_oss_init(BackendFuncs *func_list);
void alcDSoundInit(BackendFuncs *func_list); void alcDSoundInit(BackendFuncs *func_list);
@ -200,6 +198,18 @@ static ALCenum g_eLastContextError = ALC_NO_ERROR;
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
// ALC Related helper functions // ALC Related helper functions
static void InitAL(void)
{
static int done = 0;
if(!done)
{
int i;
for(i = 0;BackendList[i].Init;i++)
BackendList[i].Init(&BackendList[i].Funcs);
done = 1;
}
}
ALCchar *AppendDeviceList(char *name) ALCchar *AppendDeviceList(char *name)
{ {
static int pos; static int pos;
@ -367,7 +377,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcCaptureOpenDevice(const ALCchar *deviceName, AL
ALCdevice *pDevice = NULL; ALCdevice *pDevice = NULL;
ALCint i; ALCint i;
fill_device_list(); InitAL();
pDevice = malloc(sizeof(ALCdevice)); pDevice = malloc(sizeof(ALCdevice));
if (pDevice) if (pDevice)
@ -503,7 +513,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
{ {
const ALCchar *value = NULL; const ALCchar *value = NULL;
fill_device_list(); InitAL();
switch (param) switch (param)
{ {
@ -581,7 +591,7 @@ ALCAPI const ALCchar* ALCAPIENTRY alcGetString(ALCdevice *pDevice,ALCenum param)
*/ */
ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data) ALCAPI ALCvoid ALCAPIENTRY alcGetIntegerv(ALCdevice *device,ALCenum param,ALsizei size,ALCint *data)
{ {
fill_device_list(); InitAL();
if ((device)&&(device->IsCaptureDevice)) if ((device)&&(device->IsCaptureDevice))
{ {
@ -992,7 +1002,7 @@ ALCAPI ALCdevice* ALCAPIENTRY alcOpenDevice(const ALCchar *deviceName)
ALCdevice *device; ALCdevice *device;
ALint i; ALint i;
fill_device_list(); InitAL();
device = malloc(sizeof(ALCdevice)); device = malloc(sizeof(ALCdevice));
if (device) if (device)
@ -1078,19 +1088,3 @@ ALCAPI ALCboolean ALCAPIENTRY alcCloseDevice(ALCdevice *pDevice)
return bReturn; return bReturn;
} }
/////////////////////////////////////////////////////// ///////////////////////////////////////////////////////
///////////////////////////////////////////////////////
// ALC Device Specific Functions
void fill_device_list()
{
static int done = 0;
if(!done)
{
int i;
for(i = 0;BackendList[i].Init;i++)
BackendList[i].Init(&BackendList[i].Funcs);
done = 1;
}
}