diff options
author | Chris Robinson <[email protected]> | 2009-12-26 08:49:11 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2009-12-26 08:49:11 -0800 |
commit | c6340ce12d64062fa0723b2d24cb567bb375b378 (patch) | |
tree | e48bdbb3e0c82107f2e6d7e6df9b505b6d5d1844 | |
parent | 7bc739e965ff45b5c9504d90883ffe167f7d50d3 (diff) |
Clean up some loading checks
-rw-r--r-- | Alc/alsa.c | 18 | ||||
-rw-r--r-- | Alc/dsound.c | 14 | ||||
-rw-r--r-- | Alc/portaudio.c | 17 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 19 |
4 files changed, 33 insertions, 35 deletions
@@ -118,7 +118,7 @@ static ALuint numCaptureDevNames; static volatile ALuint load_count; -void alsa_load(void) +void *alsa_load(void) { if(load_count == 0) { @@ -127,7 +127,7 @@ void alsa_load(void) #ifdef HAVE_DLFCN_H alsa_handle = dlopen("libasound.so.2", RTLD_NOW); if(!alsa_handle) - return; + return NULL; dlerror(); #define LOAD_FUNC(f) do { \ @@ -137,7 +137,7 @@ void alsa_load(void) dlclose(alsa_handle); \ alsa_handle = NULL; \ AL_PRINT("Could not load %s from libasound.so.2: %s\n", #f, str); \ - return; \ + return NULL; \ } \ } while(0) #else @@ -205,6 +205,8 @@ LOAD_FUNC(snd_card_next); #undef LOAD_FUNC } ++load_count; + + return alsa_handle; } void alsa_unload(void) @@ -468,8 +470,7 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam return ALC_FALSE; } - alsa_load(); - if(!alsa_handle) + if(!alsa_load()) return ALC_FALSE; data = (alsa_data*)calloc(1, sizeof(alsa_data)); @@ -757,8 +758,7 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam return ALC_FALSE; } - alsa_load(); - if(!alsa_handle) + if(!alsa_load()) return ALC_FALSE; data = (alsa_data*)calloc(1, sizeof(alsa_data)); @@ -970,8 +970,8 @@ void alc_alsa_probe(int type) char name[128]; ALuint i; - alsa_load(); - if(!alsa_handle) return; + if(!alsa_load()) + return; psnd_ctl_card_info_malloc(&info); psnd_pcm_info_malloc(&pcminfo); diff --git a/Alc/dsound.c b/Alc/dsound.c index 966b6236..63047824 100644 --- a/Alc/dsound.c +++ b/Alc/dsound.c @@ -74,7 +74,7 @@ static ALuint NumDevices; static volatile ALuint load_count; -void DSoundLoad(void) +void *DSoundLoad(void) { if(load_count == 0) { @@ -83,7 +83,7 @@ void DSoundLoad(void) if(ds_handle == NULL) { AL_PRINT("Failed to load dsound.dll\n"); - return; + return NULL; } #define LOAD_FUNC(f) do { \ @@ -93,7 +93,7 @@ void DSoundLoad(void) FreeLibrary(ds_handle); \ ds_handle = NULL; \ AL_PRINT("Could not load %s from dsound.dll\n", #f); \ - return; \ + return NULL; \ } \ } while(0) #else @@ -106,6 +106,8 @@ LOAD_FUNC(DirectSoundEnumerateA); #undef LOAD_FUNC } ++load_count; + + return ds_handle; } void DSoundUnload(void) @@ -223,8 +225,7 @@ static ALCboolean DSoundOpenPlayback(ALCdevice *device, const ALCchar *deviceNam return ALC_FALSE; } - DSoundLoad(); - if(ds_handle == NULL) + if(!DSoundLoad()) return ALC_FALSE; //Initialise requested device @@ -550,8 +551,7 @@ void alcDSoundDeinit(void) void alcDSoundProbe(int type) { - DSoundLoad(); - if(!ds_handle) return; + if(!DSoundLoad()) return; if(type == DEVICE_PROBE) AppendDeviceList(dsDevice); diff --git a/Alc/portaudio.c b/Alc/portaudio.c index a190bea8..5d403f29 100644 --- a/Alc/portaudio.c +++ b/Alc/portaudio.c @@ -50,7 +50,7 @@ static const ALCchar pa_device[] = "PortAudio Software"; static volatile ALuint load_count; -void pa_load(void) +void *pa_load(void) { const char *str; PaError err; @@ -65,7 +65,7 @@ void pa_load(void) #endif pa_handle = dlopen(PALIB, RTLD_NOW); if(!pa_handle) - return; + return NULL; dlerror(); #define LOAD_FUNC(f) do { \ @@ -75,7 +75,7 @@ void pa_load(void) dlclose(pa_handle); \ pa_handle = NULL; \ AL_PRINT("Could not load %s from "PALIB": %s\n", #f, str); \ - return; \ + return NULL; \ } \ } while(0) #else @@ -103,11 +103,12 @@ LOAD_FUNC(Pa_GetStreamInfo); dlclose(pa_handle); #endif pa_handle = NULL; - return; + return NULL; } } - ++load_count; + + return pa_handle; } void pa_unload(void) @@ -155,8 +156,7 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName) else if(strcmp(deviceName, pa_device) != 0) return ALC_FALSE; - pa_load(); - if(pa_handle == NULL) + if(!pa_load()) return ALC_FALSE; data = (pa_data*)calloc(1, sizeof(pa_data)); @@ -287,8 +287,7 @@ void alc_pa_deinit(void) void alc_pa_probe(int type) { - pa_load(); - if(!pa_handle) return; + if(!pa_load()) return; if(type == DEVICE_PROBE) AppendDeviceList(pa_device); diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 621079f0..e4f53f4c 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -134,7 +134,7 @@ static const ALCchar pulse_capture_device[] = "PulseAudio Capture"; static volatile ALuint load_count; -void pulse_load(void) //{{{ +void *pulse_load(void) //{{{ { if(load_count == 0) { @@ -146,7 +146,7 @@ void pulse_load(void) //{{{ AL_PRINT("Could not load %s from libpulse-0.dll\n", #x); \ FreeLibrary(pa_handle); \ pa_handle = NULL; \ - return; \ + return NULL; \ } \ } while(0) #define LOAD_OPTIONAL_FUNC(x) do { \ @@ -169,7 +169,7 @@ void pulse_load(void) //{{{ AL_PRINT("Could not load %s from libpulse: %s\n", #x, err); \ dlclose(pa_handle); \ pa_handle = NULL; \ - return; \ + return NULL; \ } \ } while(0) #define LOAD_OPTIONAL_FUNC(x) do { \ @@ -187,7 +187,7 @@ void pulse_load(void) //{{{ #endif if(!pa_handle) - return; + return NULL; LOAD_FUNC(pa_context_unref); LOAD_FUNC(pa_sample_spec_valid); @@ -245,6 +245,8 @@ LOAD_OPTIONAL_FUNC(pa_stream_begin_write); #undef LOAD_FUNC } ++load_count; + + return pa_handle; } //}}} void pulse_unload(void) //{{{ @@ -489,8 +491,7 @@ static ALCboolean pulse_open_playback(ALCdevice *device, const ALCchar *device_n else if(strcmp(device_name, pulse_device) != 0) return ALC_FALSE; - pulse_load(); - if(!pa_handle) + if(!pulse_load()) return ALC_FALSE; if(pulse_open(device, device_name) != ALC_FALSE) @@ -660,8 +661,7 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na else if(strcmp(device_name, pulse_capture_device) != 0) return ALC_FALSE; - pulse_load(); - if(!pa_handle) + if(!pulse_load()) return ALC_FALSE; if(pulse_open(device, device_name) == ALC_FALSE) @@ -904,8 +904,7 @@ void alc_pulse_deinit(void) //{{{ void alc_pulse_probe(int type) //{{{ { - pulse_load(); - if(!pa_handle) return; + if(!pulse_load()) return; if(type == DEVICE_PROBE) AppendDeviceList(pulse_device); |