Ported ALSA minimum-sample-count fix from 1.2 branch to 1.3.
authorRyan C. Gordon
Sun, 21 Aug 2011 11:52:21 -0400
changeset 562208e941dad8e9
parent 5615 5e060b67c73d
child 5624 84d302e859d1
Ported ALSA minimum-sample-count fix from 1.2 branch to 1.3.
src/audio/alsa/SDL_alsa_audio.c
     1.1 --- a/src/audio/alsa/SDL_alsa_audio.c	Sun Aug 21 02:35:13 2011 -0400
     1.2 +++ b/src/audio/alsa/SDL_alsa_audio.c	Sun Aug 21 11:52:21 2011 -0400
     1.3 @@ -81,7 +81,8 @@
     1.4  static int (*ALSA_snd_pcm_sw_params) (snd_pcm_t *, snd_pcm_sw_params_t *);
     1.5  static int (*ALSA_snd_pcm_nonblock) (snd_pcm_t *, int);
     1.6  static int (*ALSA_snd_pcm_wait)(snd_pcm_t *, int);
     1.7 -
     1.8 +static int (*ALSA_snd_pcm_sw_params_set_avail_min)
     1.9 +  (snd_pcm_t *, snd_pcm_sw_params_t *, snd_pcm_uframes_t);
    1.10  
    1.11  #ifdef SDL_AUDIO_DRIVER_ALSA_DYNAMIC
    1.12  #define snd_pcm_hw_params_sizeof ALSA_snd_pcm_hw_params_sizeof
    1.13 @@ -140,6 +141,7 @@
    1.14      SDL_ALSA_SYM(snd_pcm_sw_params);
    1.15      SDL_ALSA_SYM(snd_pcm_nonblock);
    1.16      SDL_ALSA_SYM(snd_pcm_wait);
    1.17 +    SDL_ALSA_SYM(snd_pcm_sw_params_set_avail_min);
    1.18      return 0;
    1.19  }
    1.20  
    1.21 @@ -618,6 +620,13 @@
    1.22                       ALSA_snd_strerror(status));
    1.23          return 0;
    1.24      }
    1.25 +    status = ALSA_snd_pcm_sw_params_set_avail_min(pcm_handle, swparams, this->spec.samples);
    1.26 +    if (status < 0) {
    1.27 +        ALSA_CloseDevice(this);
    1.28 +        SDL_SetError("Couldn't set minimum available samples: %s",
    1.29 +                     ALSA_snd_strerror(status));
    1.30 +        return 0;
    1.31 +    }
    1.32      status =
    1.33          ALSA_snd_pcm_sw_params_set_start_threshold(pcm_handle, swparams, 1);
    1.34      if (status < 0) {