[MPlayer-dev-eng] [PATCH] Fix playback of 24-bit audio when sndio ao is used

Alexandre Ratchov alex at caoua.org
Tue Mar 4 20:46:28 CET 2014


On Tue, Mar 04, 2014 at 08:05:09PM +0100, Reimar Döffinger wrote:
> > 
> > --- libao2/ao_sndio.c.orig	Mon Jan  6 23:02:58 2014
> > +++ libao2/ao_sndio.c	Tue Feb 18 14:31:47 2014
> > @@ -103,6 +103,8 @@ static int init(int rate, int channels, int format, in
> >      }
> >      sio_initpar(&par);
> >      par.bits = af_fmt2bits(format);
> > +    par.bps = (par.bits + 7) >> 3;
> > +    par.msb = 1;
> 
> This seems kind of questionable, if we had a special format that stored 24 bit in 32 bit
> it would almost certainly be LSB-aligned.
> Though I suspect that is related to the next part.
> 
> > @@ -118,7 +120,7 @@ static int init(int rate, int channels, int format, in
> >          mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't get params\n");
> >          goto err_out;
> >      }
> > -    if (par.bps != SIO_BPS(par.bits)) {
> > +    if (par.bits < 8 * par.bps && !par.msb) {
> >          mp_msg(MSGT_AO, MSGL_ERR, "ao2: unsupported format\n");
> >          goto err_out;
> >      }
> 
> I kind of wonder if it isn't a bit overkill to try to make
> every format work.
> For most other aos we instead have a fallback to 16 bit/sample
> signed that is basically supported everywhere instead of
> giving up right away.
> It might not pick the ideal format, but better than failing.

This check is kinda "theoretical". On the default setup, there are
conversion layers that support any linear fixed-point format and
mplayer never fails.

It will fail if the device picks a unsupported format; this may
happen if format conversions are disabled (they are enabled by
default) on a very obscure piece of hardware, like the mavb(4)
driver which supports only 24-bit LSB-aligned in 32-bit words).

> Unfortunately I also see one last big issue with the code:
> What happens when the input is float?
> How does sndio indicated if the input format is float or integer?

It supports integers only.

> It seems that this code will request "32 bit" if the format is
> float, and when it then gets "32 bit" back it will go ahead
> and request 32 bit integer from MPlayer, instead of the
> float it wanted originally...

This is exactly what happens, and this currenly works.

-- Alexandre



More information about the MPlayer-dev-eng mailing list