# HG changeset patch # User reimar # Date 1394567438 0 # Node ID 38234a308fd3b779a7d575798a21b186427021e4 # Parent 737e2a3b9a5d128c1f76083afbebb22552c1545e Fix sndio playback of 24 bit/sample audio. Setting bps correctly is necessary since otherwise sndio defaults to 4 bps (instead of 3) for 24 bit audio. Setting msb will also allow playback if sndio also ignores our preferences and requests 4 bps input with 24 significant bits. Patch by Alexandre Ratchov [alex caoua org] with additional comments by me. diff -r 737e2a3b9a5d -r 38234a308fd3 libao2/ao_sndio.c --- a/libao2/ao_sndio.c Tue Mar 11 12:51:31 2014 +0000 +++ b/libao2/ao_sndio.c Tue Mar 11 19:50:38 2014 +0000 @@ -103,6 +103,10 @@ } sio_initpar(&par); par.bits = af_fmt2bits(format); + par.bps = (par.bits + 7) >> 3; + // normally bits == 8*bps so this makes no difference + // but we can support more formats for msb == 1, see "if" below + par.msb = 1; par.sig = (format & AF_FORMAT_SIGN_MASK) == AF_FORMAT_SI; if (par.bits > 8) par.le = (format & AF_FORMAT_END_MASK) == AF_FORMAT_LE; @@ -118,7 +122,8 @@ mp_msg(MSGT_AO, MSGL_ERR, "ao2: couldn't get params\n"); goto err_out; } - if (par.bps != SIO_BPS(par.bits)) { + // we do not care if LSBs are discarded + if (par.bits < 8 * par.bps && !par.msb) { mp_msg(MSGT_AO, MSGL_ERR, "ao2: unsupported format\n"); goto err_out; }