Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Minor ALSA dynamic loading fix.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Oct 7, 2006
1 parent 2e54c0f commit 3f95f92
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/audio/alsa/SDL_alsa_audio.c
Expand Up @@ -90,13 +90,20 @@ 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)
#endif
{
*addr = dlsym(alsa_handle, fn);
if (*addr == NULL) {
SDL_SetError("dlsym('%s') failed: %s", fn, strerror(errno));
return 0;
}
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -377,6 +385,7 @@ ALSA_CloseDevice(_THIS)
}
SDL_free(this->hidden);
this->hidden = NULL;
UnloadALSALibrary();
}
}

Expand All @@ -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,
Expand Down

0 comments on commit 3f95f92

Please sign in to comment.