diff options
author | Chris Robinson <[email protected]> | 2011-08-18 23:56:11 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-08-18 23:56:11 -0700 |
commit | 0b0588cc37c7be4c94563366d6d3e004f3a6e9fb (patch) | |
tree | fde7fb7a33801cd8c65c92a21e9f3393dd3c3f77 /Alc | |
parent | 742bb12498bd144388a7f2347d9c941c228a7270 (diff) |
Load backend libs on init
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/alsa.c | 22 | ||||
-rw-r--r-- | Alc/portaudio.c | 20 | ||||
-rw-r--r-- | Alc/pulseaudio.c | 19 | ||||
-rw-r--r-- | Alc/sndio.c | 19 |
4 files changed, 28 insertions, 52 deletions
@@ -158,22 +158,21 @@ MAKE_FUNC(snd_card_next); #endif -void *alsa_load(void) +static ALCboolean alsa_load(void) { if(!alsa_handle) { #ifdef HAVE_DYNLOAD alsa_handle = LoadLib("libasound.so.2"); if(!alsa_handle) - return NULL; + return ALC_FALSE; #define LOAD_FUNC(f) do { \ p##f = GetSymbol(alsa_handle, #f); \ - if(p##f == NULL) \ - { \ + if(p##f == NULL) { \ CloseLib(alsa_handle); \ alsa_handle = NULL; \ - return NULL; \ + return ALC_FALSE; \ } \ } while(0) LOAD_FUNC(snd_strerror); @@ -240,7 +239,7 @@ void *alsa_load(void) alsa_handle = (void*)0xDEADBEEF; #endif } - return alsa_handle; + return ALC_TRUE; } @@ -520,9 +519,6 @@ static ALCboolean alsa_open_playback(ALCdevice *device, const ALCchar *deviceNam char driver[64]; int i; - if(!alsa_load()) - return ALC_FALSE; - strncpy(driver, GetConfigValue("alsa", "device", "default"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; @@ -803,9 +799,6 @@ static ALCboolean alsa_open_capture(ALCdevice *pDevice, const ALCchar *deviceNam char *err; int i; - if(!alsa_load()) - return ALC_FALSE; - strncpy(driver, GetConfigValue("alsa", "capture", "default"), sizeof(driver)-1); driver[sizeof(driver)-1] = 0; @@ -1055,6 +1048,8 @@ static const BackendFuncs alsa_funcs = { ALCboolean alc_alsa_init(BackendFuncs *func_list) { + if(!alsa_load()) + return ALC_FALSE; *func_list = alsa_funcs; return ALC_TRUE; } @@ -1086,9 +1081,6 @@ void alc_alsa_probe(enum DevProbe type) { ALuint i; - if(!alsa_load()) - return; - switch(type) { case DEVICE_PROBE: diff --git a/Alc/portaudio.c b/Alc/portaudio.c index e1447c02..4f3dfd5f 100644 --- a/Alc/portaudio.c +++ b/Alc/portaudio.c @@ -58,7 +58,7 @@ MAKE_FUNC(Pa_GetStreamInfo); #define Pa_GetStreamInfo pPa_GetStreamInfo #endif -void *pa_load(void) +static ALCboolean pa_load(void) { if(!pa_handle) { @@ -77,7 +77,7 @@ void *pa_load(void) pa_handle = LoadLib(PALIB); if(!pa_handle) - return NULL; + return ALC_FALSE; #define LOAD_FUNC(f) do { \ p##f = GetSymbol(pa_handle, #f); \ @@ -85,7 +85,7 @@ void *pa_load(void) { \ CloseLib(pa_handle); \ pa_handle = NULL; \ - return NULL; \ + return ALC_FALSE; \ } \ } while(0) LOAD_FUNC(Pa_Initialize); @@ -107,10 +107,10 @@ void *pa_load(void) ERR("Pa_Initialize() returned an error: %s\n", Pa_GetErrorText(err)); CloseLib(pa_handle); pa_handle = NULL; - return NULL; + return ALC_FALSE; } } - return pa_handle; + return ALC_TRUE; } @@ -163,9 +163,6 @@ static ALCboolean pa_open_playback(ALCdevice *device, const ALCchar *deviceName) else if(strcmp(deviceName, pa_device) != 0) return ALC_FALSE; - if(!pa_load()) - return ALC_FALSE; - data = (pa_data*)calloc(1, sizeof(pa_data)); data->update_size = device->UpdateSize; @@ -293,9 +290,6 @@ static ALCboolean pa_open_capture(ALCdevice *device, const ALCchar *deviceName) else if(strcmp(deviceName, pa_device) != 0) return ALC_FALSE; - if(!pa_load()) - return ALC_FALSE; - data = (pa_data*)calloc(1, sizeof(pa_data)); if(data == NULL) { @@ -420,6 +414,8 @@ static const BackendFuncs pa_funcs = { ALCboolean alc_pa_init(BackendFuncs *func_list) { + if(!pa_load()) + return ALC_FALSE; *func_list = pa_funcs; return ALC_TRUE; } @@ -438,8 +434,6 @@ void alc_pa_deinit(void) void alc_pa_probe(enum DevProbe type) { - if(!pa_load()) return; - switch(type) { case DEVICE_PROBE: diff --git a/Alc/pulseaudio.c b/Alc/pulseaudio.c index 3aa7e199..a99cc28a 100644 --- a/Alc/pulseaudio.c +++ b/Alc/pulseaudio.c @@ -224,7 +224,7 @@ static ALuint numCaptureDevNames; static pa_context_flags_t pulse_ctx_flags; -void *pulse_load(void) //{{{ +static ALCboolean pulse_load(void) //{{{ { if(!pa_handle) { @@ -239,14 +239,14 @@ void *pulse_load(void) //{{{ #endif pa_handle = LoadLib(PALIB); if(!pa_handle) - return NULL; + return ALC_FALSE; #define LOAD_FUNC(x) do { \ p##x = GetSymbol(pa_handle, #x); \ if(!(p##x)) { \ CloseLib(pa_handle); \ pa_handle = NULL; \ - return NULL; \ + return ALC_FALSE; \ } \ } while(0) LOAD_FUNC(pa_context_unref); @@ -323,7 +323,7 @@ void *pulse_load(void) //{{{ pa_handle = (void*)0xDEADBEEF; #endif } - return pa_handle; + return ALC_TRUE; } //}}} // PulseAudio Event Callbacks //{{{ @@ -834,9 +834,6 @@ static ALCboolean pulse_open_playback(ALCdevice *device, const ALCchar *device_n pa_sample_spec spec; pulse_data *data; - if(!pulse_load()) - return ALC_FALSE; - if(!allDevNameMap) probe_devices(AL_FALSE); @@ -1076,9 +1073,6 @@ static ALCboolean pulse_open_capture(ALCdevice *device, const ALCchar *device_na pa_stream_state_t state; pa_channel_map chanmap; - if(!pulse_load()) - return ALC_FALSE; - if(!allCaptureDevNameMap) probe_devices(AL_TRUE); @@ -1298,6 +1292,9 @@ static const BackendFuncs pulse_funcs = { //{{{ ALCboolean alc_pulse_init(BackendFuncs *func_list) //{{{ { + if(!pulse_load()) + return ALC_FALSE; + *func_list = pulse_funcs; pulse_ctx_flags = 0; @@ -1341,8 +1338,6 @@ void alc_pulse_probe(enum DevProbe type) //{{{ pa_threaded_mainloop *loop; ALuint i; - if(!pulse_load()) return; - switch(type) { case DEVICE_PROBE: diff --git a/Alc/sndio.c b/Alc/sndio.c index ba6063dd..aa6ac0e4 100644 --- a/Alc/sndio.c +++ b/Alc/sndio.c @@ -74,22 +74,21 @@ MAKE_FUNC(sio_onvol); #endif -void *sndio_load(void) +static ALCboolean sndio_load(void) { if(!sndio_handle) { #ifdef HAVE_DYNLOAD sndio_handle = LoadLib("libsndio.so"); if(!sndio_handle) - return NULL; + return ALC_FALSE; #define LOAD_FUNC(f) do { \ p##f = GetSymbol(sndio_handle, #f); \ - if(p##f == NULL) \ - { \ + if(p##f == NULL) { \ CloseLib(sndio_handle); \ sndio_handle = NULL; \ - return NULL; \ + return ALC_FALSE; \ } \ } while(0) LOAD_FUNC(sio_initpar); @@ -114,7 +113,7 @@ void *sndio_load(void) sndio_handle = (void*)0xDEADBEEF; #endif } - return sndio_handle; + return ALC_TRUE; } @@ -170,9 +169,6 @@ static ALCboolean sndio_open_playback(ALCdevice *device, const ALCchar *deviceNa { sndio_data *data; - if(!sndio_load()) - return ALC_FALSE; - if(!deviceName) deviceName = sndio_device; else if(strcmp(deviceName, sndio_device) != 0) @@ -362,6 +358,8 @@ static const BackendFuncs sndio_funcs = { ALCboolean alc_sndio_init(BackendFuncs *func_list) { + if(!sndio_load()) + return ALC_FALSE; *func_list = sndio_funcs; return ALC_TRUE; } @@ -377,9 +375,6 @@ void alc_sndio_deinit(void) void alc_sndio_probe(enum DevProbe type) { - if(!sndio_load()) - return; - switch(type) { case DEVICE_PROBE: |