Always use "OpenAL Soft" for the short device enumeration list

This commit is contained in:
Chris Robinson 2012-02-20 20:45:22 -08:00
parent d24ada7ab7
commit e2ccc6f98e
15 changed files with 7 additions and 104 deletions

View File

@ -327,14 +327,12 @@ static const ALCchar alcErrOutOfMemory[] = "Out of Memory";
/* Device lists. Sizes only include the first ending null character, not the
* second */
static ALCchar *alcDeviceList;
static size_t alcDeviceListSize;
static const ALCchar alcDefaultName[] = "OpenAL Soft\0";
static ALCchar *alcAllDeviceList;
static size_t alcAllDeviceListSize;
static ALCchar *alcCaptureDeviceList;
static size_t alcCaptureDeviceListSize;
/* Default is always the first in the list */
static ALCchar *alcDefaultDeviceSpecifier;
static ALCchar *alcDefaultAllDeviceSpecifier;
static ALCchar *alcCaptureDefaultDeviceSpecifier;
@ -758,8 +756,6 @@ static void ProbeList(ALCchar **list, size_t *listsize, enum DevProbe type)
UnlockLists();
}
static void ProbeDeviceList(void)
{ ProbeList(&alcDeviceList, &alcDeviceListSize, DEVICE_PROBE); }
static void ProbeAllDeviceList(void)
{ ProbeList(&alcAllDeviceList, &alcAllDeviceListSize, ALL_DEVICE_PROBE); }
static void ProbeCaptureDeviceList(void)
@ -791,7 +787,6 @@ static void AppendList(const ALCchar *name, ALCchar **List, size_t *ListSize)
void Append##type##List(const ALCchar *name) \
{ AppendList(name, &alc##type##List, &alc##type##ListSize); }
DECL_APPEND_LIST_FUNC(Device)
DECL_APPEND_LIST_FUNC(AllDevice)
DECL_APPEND_LIST_FUNC(CaptureDevice)
@ -1626,7 +1621,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcCaptureOpenDevice(const ALCchar *deviceName,
return NULL;
}
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, "openal soft") == 0 || strcasecmp(deviceName, "openal-soft") == 0))
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0))
deviceName = NULL;
device = calloc(1, sizeof(ALCdevice));
@ -1835,16 +1830,13 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum para
break;
case ALC_DEVICE_SPECIFIER:
if(VerifyDevice(pDevice))
if(!VerifyDevice(pDevice))
value = alcDefaultName;
else
{
value = pDevice->szDeviceName;
ALCdevice_DecRef(pDevice);
}
else
{
ProbeDeviceList();
value = alcDeviceList;
}
break;
case ALC_ALL_DEVICES_SPECIFIER:
@ -1867,18 +1859,7 @@ ALC_API const ALCchar* ALC_APIENTRY alcGetString(ALCdevice *pDevice,ALCenum para
/* Default devices are always first in the list */
case ALC_DEFAULT_DEVICE_SPECIFIER:
if(!alcDeviceList)
ProbeDeviceList();
pDevice = VerifyDevice(pDevice);
free(alcDefaultDeviceSpecifier);
alcDefaultDeviceSpecifier = strdup(alcDeviceList ? alcDeviceList : "");
if(!alcDefaultDeviceSpecifier)
alcSetError(pDevice, ALC_OUT_OF_MEMORY);
value = alcDefaultDeviceSpecifier;
if(pDevice) ALCdevice_DecRef(pDevice);
value = alcDefaultName;
break;
case ALC_DEFAULT_ALL_DEVICES_SPECIFIER:
@ -2419,7 +2400,7 @@ ALC_API ALCdevice* ALC_APIENTRY alcOpenDevice(const ALCchar *deviceName)
return NULL;
}
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, "openal soft") == 0 || strcasecmp(deviceName, "openal-soft") == 0))
if(deviceName && (!deviceName[0] || strcasecmp(deviceName, alcDefaultName) == 0 || strcasecmp(deviceName, "openal-soft") == 0))
deviceName = NULL;
device = calloc(1, sizeof(ALCdevice)+sizeof(ALeffectslot));
@ -2784,15 +2765,11 @@ static void ReleaseALC(void)
{
ALCdevice *dev;
free(alcDeviceList); alcDeviceList = NULL;
alcDeviceListSize = 0;
free(alcAllDeviceList); alcAllDeviceList = NULL;
alcAllDeviceListSize = 0;
free(alcCaptureDeviceList); alcCaptureDeviceList = NULL;
alcCaptureDeviceListSize = 0;
free(alcDefaultDeviceSpecifier);
alcDefaultDeviceSpecifier = NULL;
free(alcDefaultAllDeviceSpecifier);
alcDefaultAllDeviceSpecifier = NULL;
free(alcCaptureDefaultDeviceSpecifier);

View File

@ -1117,10 +1117,6 @@ void alc_alsa_probe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(alsaDevice);
break;
case ALL_DEVICE_PROBE:
for(i = 0;i < numDevNames;++i)
free(allDevNameMap[i].device);

View File

@ -668,9 +668,6 @@ void alc_ca_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(ca_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(ca_device);
break;

View File

@ -929,10 +929,6 @@ void alcDSoundProbe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(dsDevice);
break;
case ALL_DEVICE_PROBE:
for(i = 0;i < NumPlaybackDevices;++i)
free(PlaybackDeviceList[i].name);

View File

@ -987,10 +987,6 @@ void alcMMDevApiProbe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(mmDevice);
break;
case ALL_DEVICE_PROBE:
req.FinishedEvt = CreateEvent(NULL, FALSE, FALSE, NULL);
if(req.FinishedEvt == NULL)

View File

@ -152,9 +152,6 @@ void alc_null_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(nullDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(nullDevice);
break;

View File

@ -410,9 +410,6 @@ void alc_opensl_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(opensl_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(opensl_device);
break;

View File

@ -500,16 +500,6 @@ void alc_oss_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
#endif
AppendDeviceList(oss_device);
}
break;
case ALL_DEVICE_PROBE:
{
#ifdef HAVE_STAT

View File

@ -438,9 +438,6 @@ void alc_pa_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(pa_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(pa_device);
break;

View File

@ -1365,33 +1365,10 @@ void alc_pulse_deinit(void) //{{{
void alc_pulse_probe(enum DevProbe type) //{{{
{
pa_threaded_mainloop *loop;
ALuint i;
switch(type)
{
case DEVICE_PROBE:
if((loop=pa_threaded_mainloop_new()) &&
pa_threaded_mainloop_start(loop) >= 0)
{
pa_context *context;
pa_threaded_mainloop_lock(loop);
context = connect_context(loop, AL_FALSE);
if(context)
{
AppendDeviceList(pulse_device);
pa_context_disconnect(context);
pa_context_unref(context);
}
pa_threaded_mainloop_unlock(loop);
pa_threaded_mainloop_stop(loop);
}
if(loop)
pa_threaded_mainloop_free(loop);
break;
case ALL_DEVICE_PROBE:
for(i = 0;i < numDevNames;++i)
{

View File

@ -357,9 +357,6 @@ void alc_sndio_probe(enum DevProbe type)
{
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(sndio_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(sndio_device);
break;

View File

@ -268,9 +268,6 @@ void alc_solaris_probe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(solaris_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(solaris_device);
break;

View File

@ -342,9 +342,6 @@ void alc_wave_probe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(waveDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(waveDevice);
break;

View File

@ -752,12 +752,6 @@ void alcWinMMProbe(enum DevProbe type)
switch(type)
{
case DEVICE_PROBE:
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)
AppendDeviceList(woDefault);
break;
case ALL_DEVICE_PROBE:
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)

View File

@ -439,7 +439,6 @@ static __inline ALuint fastf2u(ALfloat f)
enum DevProbe {
DEVICE_PROBE,
ALL_DEVICE_PROBE,
CAPTURE_DEVICE_PROBE
};
@ -697,7 +696,6 @@ ALCcontext *GetContextRef(void);
void ALCcontext_IncRef(ALCcontext *context);
void ALCcontext_DecRef(ALCcontext *context);
void AppendDeviceList(const ALCchar *name);
void AppendAllDeviceList(const ALCchar *name);
void AppendCaptureDeviceList(const ALCchar *name);