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

Andrew Calkin andrew.calkin at gmail.com
Thu Aug 30 03:42:12 CEST 2007


On Wed, Aug 29, 2007 at 11:46:24PM +0300, Jan Knutar wrote:
> > --- 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?

I must admit that I don't know. I would guess that if the patch simply
resulted in distorted sound, then no sound would have been preferable
and so it would never have been written. Clemens, if you're reading, do
you have any input on the matter?

//Andrew



More information about the MPlayer-dev-eng mailing list