Minor ALSA dynamic loading fix. SDL-ryan-multiple-audio-device
authorRyan C. Gordon <icculus@icculus.org>
Sat, 07 Oct 2006 07:23:52 +0000
branchSDL-ryan-multiple-audio-device
changeset 3824 25052dd25810
parent 3823 c562b1a12f82
child 3825 76c5a414b996
Minor ALSA dynamic loading fix.
src/audio/alsa/SDL_alsa_audio.c
--- a/src/audio/alsa/SDL_alsa_audio.c	Sat Oct 07 06:18:15 2006 +0000
+++ b/src/audio/alsa/SDL_alsa_audio.c	Sat Oct 07 07:23:52 2006 +0000
@@ -90,6 +90,12 @@
 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 @@
     {
         *addr = dlsym(alsa_handle, fn);
         if (*addr == NULL) {
+            SDL_SetError("dlsym('%s') failed: %s", fn, strerror(errno));
             return 0;
         }
     }
@@ -140,6 +147,7 @@
     SDL_ALSA_SYM(snd_pcm_nonblock);
     return 0;
 }
+#undef SDL_ALSA_SYM
 
 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
 
@@ -377,6 +385,7 @@
         }
         SDL_free(this->hidden);
         this->hidden = NULL;
+        UnloadALSALibrary();
     }
 }
 
@@ -400,6 +409,11 @@
     }
     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,