From cb5df71e4cfa6de9a2dc963259cbde3eb85e3030 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 21 Aug 2011 11:52:21 -0400 Subject: [PATCH] Ported ALSA minimum-sample-count fix from 1.2 branch to 1.3. --- src/audio/alsa/SDL_alsa_audio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/audio/alsa/SDL_alsa_audio.c b/src/audio/alsa/SDL_alsa_audio.c index 31b2063b9..523be6e28 100644 --- a/src/audio/alsa/SDL_alsa_audio.c +++ b/src/audio/alsa/SDL_alsa_audio.c @@ -81,7 +81,8 @@ static int (*ALSA_snd_pcm_sw_params_set_start_threshold) 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 int (*ALSA_snd_pcm_sw_params_set_avail_min) + (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t); #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof @@ -140,6 +141,7 @@ load_alsa_syms(void) SDL_ALSA_SYM(snd_pcm_sw_params); SDL_ALSA_SYM(snd_pcm_nonblock); SDL_ALSA_SYM(snd_pcm_wait); + SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min); return 0; } @@ -618,6 +620,13 @@ ALSA_OpenDevice(_THIS, const char *devname, int iscapture) ALSA_snd_strerror(status)); return 0; } + status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples); + if (status < 0) { + ALSA_CloseDevice(this); + SDL_SetError("Couldn't set minimum available samples: %s", + ALSA_snd_strerror(status)); + return 0; + } status = ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1); if (status < 0) {