From 3f95f92c4ffdc1359fa4724d137e40f5be8849c3 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 7 Oct 2006 07:23:52 +0000 Subject: [PATCH] Minor ALSA dynamic loading fix. --- src/audio/alsa/SDL_alsa_audio.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 0cb33b993..a629462e1 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -90,6 +90,12 @@ static void *alsa_handle = NULL; static int load_alsa_sym(const char *fn, void **addr) { + /* + * !!! FIXME: + * Eventually, this will deal with fallbacks, version changes, and + * missing symbols we can workaround. But for now, it doesn't. + */ + #if HAVE_DLVSYM *addr = dlvsym(alsa_handle, fn, "ALSA_0.9"); if (*addr == NULL) @@ -97,6 +103,7 @@ load_alsa_sym(const char *fn, void **addr) { *addr = dlsym(alsa_handle, fn); if (*addr == NULL) { + SDL_SetError("dlsym('%s') failed: %s", fn, strerror(errno)); return 0; } } @@ -140,6 +147,7 @@ static int load_alsa_syms(void) SDL_ALSA_SYM(snd_pcm_nonblock); return 0; } +#undef SDL_ALSA_SYM #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC @@ -377,6 +385,7 @@ ALSA_CloseDevice(_THIS) } SDL_free(this->hidden); this->hidden = NULL; + UnloadALSALibrary(); } } @@ -400,6 +409,11 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) } SDL_memset(this->hidden, 0, (sizeof *this->hidden)); + if (LoadALSALibrary() < 0) { + ALSA_CloseDevice(this); + return 0; + } + /* Open the audio device */ /* Name of device should depend on # channels in spec */ status = ALSA_snd_pcm_open(&pcm_handle,