ALSA_snd_pcm_drop() can hang on some systems (Steam Link) so don't use that when shutting down the ALSA audio driver.

This commit is contained in:
Sam Lantinga 2016-10-07 19:08:22 -07:00
parent 808c75d1cf
commit 52ae92eaf7

View File

@ -49,7 +49,6 @@ static snd_pcm_sframes_t (*ALSA_snd_pcm_readi)
static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int); static int (*ALSA_snd_pcm_recover) (snd_pcm_t *, int, int);
static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *); static int (*ALSA_snd_pcm_prepare) (snd_pcm_t *);
static int (*ALSA_snd_pcm_drain) (snd_pcm_t *); static int (*ALSA_snd_pcm_drain) (snd_pcm_t *);
static int (*ALSA_snd_pcm_drop) (snd_pcm_t *);
static const char *(*ALSA_snd_strerror) (int); static const char *(*ALSA_snd_strerror) (int);
static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void); static size_t(*ALSA_snd_pcm_hw_params_sizeof) (void);
static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void); static size_t(*ALSA_snd_pcm_sw_params_sizeof) (void);
@ -129,7 +128,6 @@ load_alsa_syms(void)
SDL_ALSA_SYM(snd_pcm_recover); SDL_ALSA_SYM(snd_pcm_recover);
SDL_ALSA_SYM(snd_pcm_prepare); SDL_ALSA_SYM(snd_pcm_prepare);
SDL_ALSA_SYM(snd_pcm_drain); SDL_ALSA_SYM(snd_pcm_drain);
SDL_ALSA_SYM(snd_pcm_drop);
SDL_ALSA_SYM(snd_strerror); SDL_ALSA_SYM(snd_strerror);
SDL_ALSA_SYM(snd_pcm_hw_params_sizeof); SDL_ALSA_SYM(snd_pcm_hw_params_sizeof);
SDL_ALSA_SYM(snd_pcm_sw_params_sizeof); SDL_ALSA_SYM(snd_pcm_sw_params_sizeof);
@ -404,7 +402,12 @@ static void
ALSA_CloseDevice(_THIS) ALSA_CloseDevice(_THIS)
{ {
if (this->hidden->pcm_handle) { if (this->hidden->pcm_handle) {
ALSA_snd_pcm_drop(this->hidden->pcm_handle); /* Wait for the submitted audio to drain
ALSA_snd_pcm_drop() can hang, so don't use that.
*/
Uint32 delay = ((this->spec.samples * 1000) / this->spec.freq) * 2;
SDL_Delay(delay);
ALSA_snd_pcm_close(this->hidden->pcm_handle); ALSA_snd_pcm_close(this->hidden->pcm_handle);
} }
SDL_free(this->hidden->mixbuf); SDL_free(this->hidden->mixbuf);