[MPlayer-dev-eng] [PATCH] ALSA AO, attempt both chunk sizes before failing

Jan Knutar jknutar at nic.fi
Wed Aug 29 22:46:24 CEST 2007


> --- a/libao2/ao_alsa.c  Sun Apr 30 16:54:28 2006 +0200
> +++ b/libao2/ao_alsa.c  Sun Apr 30 16:54:28 2006 +0200
> @@ -615,11 +615,15 @@ static int init(int rate_hz, int channel
>         if ((err = snd_pcm_hw_params_set_period_size_near(alsa_handler, alsa_hwparams, 
>                                                           &chunk_size, NULL)) < 0)
>           {
> -           mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodSize,
> -                           chunk_size, snd_strerror(err));
> +           chunk_size = 512 + 1024 - chunk_size;
> +           if ((err = snd_pcm_hw_params_set_period_size(alsa_handler, alsa_hwparams, 
> +                                                        chunk_size, 0)) < 0) {
> +             mp_msg(MSGT_AO,MSGL_ERR,MSGTR_AO_ALSA_UnableToSetPeriodSize,
> +             chunk_size, snd_strerror(err));
> +           }
>             return 0;

What happens if the second chunk_size works?

>           }
> -       else {
> +       if (err >= 0) {
>           mp_msg(MSGT_AO,MSGL_V,"alsa-init: chunksize set to %li\n", chunk_size);
>         }
>         if ((err = snd_pcm_hw_params_set_periods_near(alsa_handler, alsa_hwparams,



More information about the MPlayer-dev-eng mailing list