Mercurial > sdl-ios-xcode
comparison src/audio/alsa/SDL_alsa_audio.c @ 3824:25052dd25810 SDL-ryan-multiple-audio-device
Minor ALSA dynamic loading fix.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 07 Oct 2006 07:23:52 +0000 |
parents | b225d9820ee3 |
children | ee5dfa7f7993 |
comparison
equal
deleted
inserted
replaced
3823:c562b1a12f82 | 3824:25052dd25810 |
---|---|
88 static void *alsa_handle = NULL; | 88 static void *alsa_handle = NULL; |
89 | 89 |
90 static int | 90 static int |
91 load_alsa_sym(const char *fn, void **addr) | 91 load_alsa_sym(const char *fn, void **addr) |
92 { | 92 { |
93 /* | |
94 * !!! FIXME: | |
95 * Eventually, this will deal with fallbacks, version changes, and | |
96 * missing symbols we can workaround. But for now, it doesn't. | |
97 */ | |
98 | |
93 #if HAVE_DLVSYM | 99 #if HAVE_DLVSYM |
94 *addr = dlvsym(alsa_handle, fn, "ALSA_0.9"); | 100 *addr = dlvsym(alsa_handle, fn, "ALSA_0.9"); |
95 if (*addr == NULL) | 101 if (*addr == NULL) |
96 #endif | 102 #endif |
97 { | 103 { |
98 *addr = dlsym(alsa_handle, fn); | 104 *addr = dlsym(alsa_handle, fn); |
99 if (*addr == NULL) { | 105 if (*addr == NULL) { |
106 SDL_SetError("dlsym('%s') failed: %s", fn, strerror(errno)); | |
100 return 0; | 107 return 0; |
101 } | 108 } |
102 } | 109 } |
103 | 110 |
104 return 1; | 111 return 1; |
138 SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); | 145 SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); |
139 SDL_ALSA_SYM(snd_pcm_sw_params); | 146 SDL_ALSA_SYM(snd_pcm_sw_params); |
140 SDL_ALSA_SYM(snd_pcm_nonblock); | 147 SDL_ALSA_SYM(snd_pcm_nonblock); |
141 return 0; | 148 return 0; |
142 } | 149 } |
150 #undef SDL_ALSA_SYM | |
143 | 151 |
144 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC | 152 #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC |
145 | 153 |
146 static int library_load_count = 0; | 154 static int library_load_count = 0; |
147 | 155 |
375 ALSA_snd_pcm_close(this->hidden->pcm_handle); | 383 ALSA_snd_pcm_close(this->hidden->pcm_handle); |
376 this->hidden->pcm_handle = NULL; | 384 this->hidden->pcm_handle = NULL; |
377 } | 385 } |
378 SDL_free(this->hidden); | 386 SDL_free(this->hidden); |
379 this->hidden = NULL; | 387 this->hidden = NULL; |
388 UnloadALSALibrary(); | |
380 } | 389 } |
381 } | 390 } |
382 | 391 |
383 static int | 392 static int |
384 ALSA_OpenDevice(_THIS, const char *devname, int iscapture) | 393 ALSA_OpenDevice(_THIS, const char *devname, int iscapture) |
397 if (this->hidden == NULL) { | 406 if (this->hidden == NULL) { |
398 SDL_OutOfMemory(); | 407 SDL_OutOfMemory(); |
399 return 0; | 408 return 0; |
400 } | 409 } |
401 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); | 410 SDL_memset(this->hidden, 0, (sizeof *this->hidden)); |
411 | |
412 if (LoadALSALibrary() < 0) { | |
413 ALSA_CloseDevice(this); | |
414 return 0; | |
415 } | |
402 | 416 |
403 /* Open the audio device */ | 417 /* Open the audio device */ |
404 /* Name of device should depend on # channels in spec */ | 418 /* Name of device should depend on # channels in spec */ |
405 status = ALSA_snd_pcm_open(&pcm_handle, | 419 status = ALSA_snd_pcm_open(&pcm_handle, |
406 get_audio_device(this->spec.channels), | 420 get_audio_device(this->spec.channels), |