diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -84,6 +84,7 @@ static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *); static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int); static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int); +static snd_pcm_state_t (*ALSA_snd_pcm_state)(snd_pcm_t *); static int (*ALSA_snd_pcm_sw_params_set_avail_min) (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); static int (*ALSA_snd_pcm_reset)(snd_pcm_t *); @@ -153,6 +154,7 @@ SDL_ALSA_SYM(snd_pcm_sw_params); SDL_ALSA_SYM(snd_pcm_nonblock); SDL_ALSA_SYM(snd_pcm_wait); + SDL_ALSA_SYM(snd_pcm_state); SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); SDL_ALSA_SYM(snd_pcm_reset); SDL_ALSA_SYM(snd_device_name_hint); @@ -332,13 +334,7 @@ while ( frames_left > 0 && SDL_AtomicGet(&this->enabled) ) { int status; - /* This wait is a work-around for a hang when USB devices are - unplugged. Normally it should not result in any waiting, - but in the case of a USB unplug, it serves as a way to - join the playback thread after the timeout occurs */ - status = ALSA_snd_pcm_wait(this->hidden->pcm_handle, 1000); - if (status == 0) { - /*fprintf(stderr, "ALSA timeout waiting for available buffer space\n");*/ + if (ALSA_snd_pcm_state(this->hidden->pcm_handle) == SND_PCM_STATE_DISCONNECTED) { SDL_OpenedAudioDeviceDisconnected(this); return; }