diff options
author | Chris Robinson <[email protected]> | 2011-06-14 04:02:58 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-06-14 04:02:58 -0700 |
commit | 53c5275aa4ea9c42d850cf3f2d9fe589a7c84924 (patch) | |
tree | 2de994091bfee13326534878ad4f770a1e36fe56 /Alc | |
parent | c93d7a1721dc8233d0a256c022ab55223c582062 (diff) |
Use a proper enum for the probe type
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALc.c | 2 | ||||
-rw-r--r-- | Alc/alsa.c | 42 | ||||
-rw-r--r-- | Alc/coreaudio.c | 17 | ||||
-rw-r--r-- | Alc/dsound.c | 45 | ||||
-rw-r--r-- | Alc/loopback.c | 2 | ||||
-rw-r--r-- | Alc/mmdevapi.c | 17 | ||||
-rw-r--r-- | Alc/null.c | 17 | ||||
-rw-r--r-- | Alc/opensl.c | 4 | ||||
-rw-r--r-- | Alc/oss.c | 42 | ||||
-rw-r--r-- | Alc/portaudio.c | 20 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 101 | ||||
-rw-r--r-- | Alc/solaris.c | 17 | ||||
-rw-r--r-- | Alc/wave.c | 17 | ||||
-rw-r--r-- | Alc/winmm.c | 52 |
14 files changed, 228 insertions, 167 deletions
@@ -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[] = { @@ -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; + + case CAPTURE_DEVICE_PROBE: + for(i = 0;i < numCaptureDevNames;++i) + free(allCaptureDevNameMap[i].name); - for(i = 0;i < numCaptureDevNames;++i) - AppendCaptureDeviceList(allCaptureDevNameMap[i].name); + free(allCaptureDevNameMap); + allCaptureDevNameMap = probe_devices(SND_PCM_STREAM_CAPTURE, &numCaptureDevNames); + + for(i = 0;i < numCaptureDevNames;++i) + AppendCaptureDeviceList(allCaptureDevNameMap[i].name); + break; } } diff --git a/Alc/coreaudio.c b/Alc/coreaudio.c index 4cac049f..e32e15fa 100644 --- a/Alc/coreaudio.c +++ b/Alc/coreaudio.c @@ -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; + } } diff --git a/Alc/dsound.c b/Alc/dsound.c index 4280f508..a75e6922 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -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; } } diff --git a/Alc/loopback.c b/Alc/loopback.c index 50975c9c..e8c5256e 100644 --- a/Alc/loopback.c +++ b/Alc/loopback.c @@ -70,7 +70,7 @@ void alc_loopback_deinit(void) { } -void alc_loopback_probe(int type) +void alc_loopback_probe(enum DevProbe type) { (void)type; } diff --git a/Alc/mmdevapi.c b/Alc/mmdevapi.c index 44ef45bc..abfa9fe6 100644 --- a/Alc/mmdevapi.c +++ b/Alc/mmdevapi.c @@ -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; + } } @@ -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; + } } diff --git a/Alc/opensl.c b/Alc/opensl.c index 89b1d36f..0f8f02f3 100644 --- a/Alc/opensl.c +++ b/Alc/opensl.c @@ -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; } } @@ -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; } } diff --git a/Alc/portaudio.c b/Alc/portaudio.c index 82e3fcba..86ae4c64 100644 --- a/Alc/portaudio.c +++ b/Alc/portaudio.c @@ -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; + } } diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 161df3a3..c66e6b98 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -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); - - ppa_context_disconnect(context); - ppa_context_unref(context); + pa_context *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; } } //}}} //}}} diff --git a/Alc/solaris.c b/Alc/solaris.c index 0510985e..075715a9 100644 --- a/Alc/solaris.c +++ b/Alc/solaris.c @@ -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; + } } @@ -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; + } } diff --git a/Alc/winmm.c b/Alc/winmm.c index eebeb9de..64e669e2 100644 --- a/Alc/winmm.c +++ b/Alc/winmm.c @@ -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; } } |