Use a proper enum for the probe type

This commit is contained in:
Chris Robinson
2011-06-14 04:02:58 -07:00
parent c93d7a1721
commit 53c5275aa4
15 changed files with 241 additions and 180 deletions
+1 -1
View File
@@ -66,7 +66,7 @@ typedef struct BackendInfo {
const char *name;
void (*Init)(BackendFuncs*);
void (*Deinit)(void);
void (*Probe)(int);
void (*Probe)(enum DevProbe);
BackendFuncs Funcs;
} BackendInfo;
static BackendInfo BackendList[] = {
+23 -19
View File
@@ -1031,35 +1031,39 @@ void alc_alsa_deinit(void)
}
}
void alc_alsa_probe(int type)
void alc_alsa_probe(enum DevProbe type)
{
ALuint i;
if(!alsa_load())
return;
if(type == DEVICE_PROBE)
AppendDeviceList(alsaDevice);
else if(type == ALL_DEVICE_PROBE)
switch(type)
{
for(i = 0;i < numDevNames;++i)
free(allDevNameMap[i].name);
case DEVICE_PROBE:
AppendDeviceList(alsaDevice);
break;
free(allDevNameMap);
allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames);
case ALL_DEVICE_PROBE:
for(i = 0;i < numDevNames;++i)
free(allDevNameMap[i].name);
for(i = 0;i < numDevNames;++i)
AppendAllDeviceList(allDevNameMap[i].name);
}
else if(type == CAPTURE_DEVICE_PROBE)
{
for(i = 0;i < numCaptureDevNames;++i)
free(allCaptureDevNameMap[i].name);
free(allDevNameMap);
allDevNameMap = probe_devices(SND_PCM_STREAM_PLAYBACK, &numDevNames);
free(allCaptureDevNameMap);
allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
for(i = 0;i < numDevNames;++i)
AppendAllDeviceList(allDevNameMap[i].name);
break;
for(i = 0;i < numCaptureDevNames;++i)
AppendCaptureDeviceList(allCaptureDevNameMap[i].name);
case CAPTURE_DEVICE_PROBE:
for(i = 0;i < numCaptureDevNames;++i)
free(allCaptureDevNameMap[i].name);
free(allCaptureDevNameMap);
allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames);
for(i = 0;i < numCaptureDevNames;++i)
AppendCaptureDeviceList(allCaptureDevNameMap[i].name);
break;
}
}
+12 -5
View File
@@ -324,10 +324,17 @@ void alc_ca_deinit(void)
{
}
void alc_ca_probe(int type)
void alc_ca_probe(enum DevProbe type)
{
if(type == DEVICE_PROBE)
AppendDeviceList(ca_device);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(ca_device);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(ca_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(ca_device);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+26 -19
View File
@@ -586,30 +586,37 @@ void alcDSoundDeinit(void)
}
}
void alcDSoundProbe(int type)
void alcDSoundProbe(enum DevProbe type)
{
HRESULT hr;
ALuint i;
if(!DSoundLoad()) return;
if(type == DEVICE_PROBE)
AppendDeviceList(dsDevice);
else if(type == ALL_DEVICE_PROBE)
switch(type)
{
HRESULT hr;
ALuint i;
case DEVICE_PROBE:
AppendDeviceList(dsDevice);
break;
for(i = 0;i < NumDevices;++i)
free(DeviceList[i].name);
free(DeviceList);
DeviceList = NULL;
NumDevices = 0;
case ALL_DEVICE_PROBE:
for(i = 0;i < NumDevices;++i)
free(DeviceList[i].name);
free(DeviceList);
DeviceList = NULL;
NumDevices = 0;
hr = DirectSoundEnumerateA(DSoundEnumDevices, NULL);
if(FAILED(hr))
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
else
{
for(i = 0;i < NumDevices;i++)
AppendAllDeviceList(DeviceList[i].name);
}
hr = DirectSoundEnumerateA(DSoundEnumDevices, NULL);
if(FAILED(hr))
AL_PRINT("Error enumerating DirectSound devices (%#x)!\n", (unsigned int)hr);
else
{
for(i = 0;i < NumDevices;i++)
AppendAllDeviceList(DeviceList[i].name);
}
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+1 -1
View File
@@ -70,7 +70,7 @@ void alc_loopback_deinit(void)
{
}
void alc_loopback_probe(int type)
void alc_loopback_probe(enum DevProbe type)
{
(void)type;
}
+12 -5
View File
@@ -561,12 +561,19 @@ void alcMMDevApiDeinit(void)
}
}
void alcMMDevApiProbe(int type)
void alcMMDevApiProbe(enum DevProbe type)
{
if(!MMDevApiLoad()) return;
if(type == DEVICE_PROBE)
AppendDeviceList(mmDevice);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(mmDevice);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(mmDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(mmDevice);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+12 -5
View File
@@ -173,10 +173,17 @@ void alc_null_deinit(void)
{
}
void alc_null_probe(int type)
void alc_null_probe(enum DevProbe type)
{
if(type == DEVICE_PROBE)
AppendDeviceList(nullDevice);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(nullDevice);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(nullDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(nullDevice);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+2 -2
View File
@@ -415,7 +415,7 @@ void alc_opensl_deinit(void)
{
}
void alc_opensl_probe(int type)
void alc_opensl_probe(enum DevProbe type)
{
switch(type)
{
@@ -425,7 +425,7 @@ void alc_opensl_probe(int type)
case ALL_DEVICE_PROBE:
AppendAllDeviceList(opensl_device);
break;
default:
case CAPTURE_DEVICE_PROBE:
break;
}
}
+25 -17
View File
@@ -498,30 +498,38 @@ void alc_oss_deinit(void)
{
}
void alc_oss_probe(int type)
void alc_oss_probe(enum DevProbe type)
{
if(type == DEVICE_PROBE)
switch(type)
{
case DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
struct stat buf;
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
#endif
AppendDeviceList(oss_device);
}
else if(type == ALL_DEVICE_PROBE)
{
AppendDeviceList(oss_device);
}
break;
case ALL_DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
struct stat buf;
if(stat(GetConfigValue("oss", "device", "/dev/dsp"), &buf) == 0)
#endif
AppendAllDeviceList(oss_device);
}
else if(type == CAPTURE_DEVICE_PROBE)
{
AppendAllDeviceList(oss_device);
}
break;
case CAPTURE_DEVICE_PROBE:
{
#ifdef HAVE_STAT
struct stat buf;
if(stat(GetConfigValue("oss", "capture", "/dev/dsp"), &buf) == 0)
struct stat buf;
if(stat(GetConfigValue("oss", "capture", "/dev/dsp"), &buf) == 0)
#endif
AppendCaptureDeviceList(oss_device);
AppendCaptureDeviceList(oss_device);
}
break;
}
}
+13 -7
View File
@@ -430,14 +430,20 @@ void alc_pa_deinit(void)
}
}
void alc_pa_probe(int type)
void alc_pa_probe(enum DevProbe type)
{
if(!pa_load()) return;
if(type == DEVICE_PROBE)
AppendDeviceList(pa_device);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(pa_device);
else if(type == CAPTURE_DEVICE_PROBE)
AppendCaptureDeviceList(pa_device);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(pa_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(pa_device);
break;
case CAPTURE_DEVICE_PROBE:
AppendCaptureDeviceList(pa_device);
break;
}
}
+49 -50
View File
@@ -1297,69 +1297,68 @@ void alc_pulse_deinit(void) //{{{
}
} //}}}
void alc_pulse_probe(int type) //{{{
void alc_pulse_probe(enum DevProbe type) //{{{
{
pa_threaded_mainloop *loop;
ALuint i;
if(!pulse_load()) return;
if(type == DEVICE_PROBE)
switch(type)
{
pa_threaded_mainloop *loop;
if((loop=ppa_threaded_mainloop_new()) &&
ppa_threaded_mainloop_start(loop) >= 0)
{
pa_context *context;
ppa_threaded_mainloop_lock(loop);
context = connect_context(loop, AL_TRUE);
if(context)
case DEVICE_PROBE:
if((loop=ppa_threaded_mainloop_new()) &&
ppa_threaded_mainloop_start(loop) >= 0)
{
AppendDeviceList(pulse_device);
pa_context *context;
ppa_context_disconnect(context);
ppa_context_unref(context);
ppa_threaded_mainloop_lock(loop);
context = connect_context(loop, AL_TRUE);
if(context)
{
AppendDeviceList(pulse_device);
ppa_context_disconnect(context);
ppa_context_unref(context);
}
ppa_threaded_mainloop_unlock(loop);
ppa_threaded_mainloop_stop(loop);
}
ppa_threaded_mainloop_unlock(loop);
ppa_threaded_mainloop_stop(loop);
}
if(loop)
ppa_threaded_mainloop_free(loop);
}
else if(type == ALL_DEVICE_PROBE)
{
ALuint i;
if(loop)
ppa_threaded_mainloop_free(loop);
break;
for(i = 0;i < numDevNames;++i)
{
free(allDevNameMap[i].name);
free(allDevNameMap[i].device_name);
}
free(allDevNameMap);
allDevNameMap = NULL;
numDevNames = 0;
case ALL_DEVICE_PROBE:
for(i = 0;i < numDevNames;++i)
{
free(allDevNameMap[i].name);
free(allDevNameMap[i].device_name);
}
free(allDevNameMap);
allDevNameMap = NULL;
numDevNames = 0;
probe_devices(AL_FALSE);
probe_devices(AL_FALSE);
for(i = 0;i < numDevNames;i++)
AppendAllDeviceList(allDevNameMap[i].name);
}
else if(type == CAPTURE_DEVICE_PROBE)
{
ALuint i;
for(i = 0;i < numDevNames;i++)
AppendAllDeviceList(allDevNameMap[i].name);
break;
for(i = 0;i < numCaptureDevNames;++i)
{
free(allCaptureDevNameMap[i].name);
free(allCaptureDevNameMap[i].device_name);
}
free(allCaptureDevNameMap);
allCaptureDevNameMap = NULL;
numCaptureDevNames = 0;
case CAPTURE_DEVICE_PROBE:
for(i = 0;i < numCaptureDevNames;++i)
{
free(allCaptureDevNameMap[i].name);
free(allCaptureDevNameMap[i].device_name);
}
free(allCaptureDevNameMap);
allCaptureDevNameMap = NULL;
numCaptureDevNames = 0;
probe_devices(AL_TRUE);
probe_devices(AL_TRUE);
for(i = 0;i < numCaptureDevNames;i++)
AppendCaptureDeviceList(allCaptureDevNameMap[i].name);
for(i = 0;i < numCaptureDevNames;i++)
AppendCaptureDeviceList(allCaptureDevNameMap[i].name);
break;
}
} //}}}
//}}}
+12 -5
View File
@@ -295,7 +295,7 @@ void alc_solaris_deinit(void)
{
}
void alc_solaris_probe(int type)
void alc_solaris_probe(enum DevProbe type)
{
#ifdef HAVE_STAT
struct stat buf;
@@ -303,8 +303,15 @@ void alc_solaris_probe(int type)
return;
#endif
if(type == DEVICE_PROBE)
AppendDeviceList(solaris_device);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(solaris_device);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(solaris_device);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(solaris_device);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+12 -5
View File
@@ -343,13 +343,20 @@ void alc_wave_deinit(void)
{
}
void alc_wave_probe(int type)
void alc_wave_probe(enum DevProbe type)
{
if(!ConfigValueExists("wave", "file"))
return;
if(type == DEVICE_PROBE)
AppendDeviceList(waveDevice);
else if(type == ALL_DEVICE_PROBE)
AppendAllDeviceList(waveDevice);
switch(type)
{
case DEVICE_PROBE:
AppendDeviceList(waveDevice);
break;
case ALL_DEVICE_PROBE:
AppendAllDeviceList(waveDevice);
break;
case CAPTURE_DEVICE_PROBE:
break;
}
}
+27 -25
View File
@@ -767,34 +767,36 @@ void alcWinMMDeinit()
NumCaptureDevices = 0;
}
void alcWinMMProbe(int type)
void alcWinMMProbe(enum DevProbe type)
{
ALuint i;
if(type == DEVICE_PROBE)
switch(type)
{
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)
AppendDeviceList(woDefault);
}
else if(type == ALL_DEVICE_PROBE)
{
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)
AppendAllDeviceList(woDefault);
for(i = 0;i < NumPlaybackDevices;i++)
{
if(PlaybackDeviceList[i])
AppendAllDeviceList(PlaybackDeviceList[i]);
}
}
else if(type == CAPTURE_DEVICE_PROBE)
{
ProbeCaptureDevices();
for(i = 0;i < NumCaptureDevices;i++)
{
if(CaptureDeviceList[i])
AppendCaptureDeviceList(CaptureDeviceList[i]);
}
case DEVICE_PROBE:
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)
AppendDeviceList(woDefault);
break;
case ALL_DEVICE_PROBE:
ProbePlaybackDevices();
if(NumPlaybackDevices > 0)
AppendAllDeviceList(woDefault);
for(i = 0;i < NumPlaybackDevices;i++)
{
if(PlaybackDeviceList[i])
AppendAllDeviceList(PlaybackDeviceList[i]);
}
break;
case CAPTURE_DEVICE_PROBE:
ProbeCaptureDevices();
for(i = 0;i < NumCaptureDevices;i++)
{
if(CaptureDeviceList[i])
AppendCaptureDeviceList(CaptureDeviceList[i]);
}
break;
}
}
+14 -14
View File
@@ -295,7 +295,7 @@ typedef struct {
ALCuint (*AvailableSamples)(ALCdevice*);
} BackendFuncs;
enum {
enum DevProbe {
DEVICE_PROBE,
ALL_DEVICE_PROBE,
CAPTURE_DEVICE_PROBE
@@ -303,43 +303,43 @@ enum {
void alc_alsa_init(BackendFuncs *func_list);
void alc_alsa_deinit(void);
void alc_alsa_probe(int type);
void alc_alsa_probe(enum DevProbe type);
void alc_oss_init(BackendFuncs *func_list);
void alc_oss_deinit(void);
void alc_oss_probe(int type);
void alc_oss_probe(enum DevProbe type);
void alc_solaris_init(BackendFuncs *func_list);
void alc_solaris_deinit(void);
void alc_solaris_probe(int type);
void alc_solaris_probe(enum DevProbe type);
void alcMMDevApiInit(BackendFuncs *func_list);
void alcMMDevApiDeinit(void);
void alcMMDevApiProbe(int type);
void alcMMDevApiProbe(enum DevProbe type);
void alcDSoundInit(BackendFuncs *func_list);
void alcDSoundDeinit(void);
void alcDSoundProbe(int type);
void alcDSoundProbe(enum DevProbe type);
void alcWinMMInit(BackendFuncs *FuncList);
void alcWinMMDeinit(void);
void alcWinMMProbe(int type);
void alcWinMMProbe(enum DevProbe type);
void alc_pa_init(BackendFuncs *func_list);
void alc_pa_deinit(void);
void alc_pa_probe(int type);
void alc_pa_probe(enum DevProbe type);
void alc_wave_init(BackendFuncs *func_list);
void alc_wave_deinit(void);
void alc_wave_probe(int type);
void alc_wave_probe(enum DevProbe type);
void alc_pulse_init(BackendFuncs *func_list);
void alc_pulse_deinit(void);
void alc_pulse_probe(int type);
void alc_pulse_probe(enum DevProbe type);
void alc_ca_init(BackendFuncs *func_list);
void alc_ca_deinit(void);
void alc_ca_probe(int type);
void alc_ca_probe(enum DevProbe type);
void alc_opensl_init(BackendFuncs *func_list);
void alc_opensl_deinit(void);
void alc_opensl_probe(int type);
void alc_opensl_probe(enum DevProbe type);
void alc_null_init(BackendFuncs *func_list);
void alc_null_deinit(void);
void alc_null_probe(int type);
void alc_null_probe(enum DevProbe type);
void alc_loopback_init(BackendFuncs *func_list);
void alc_loopback_deinit(void);
void alc_loopback_probe(int type);
void alc_loopback_probe(enum DevProbe type);
typedef struct UIntMap {