[MPlayer-dev-eng] [PATCH] Fix sndio playback of 24 bit/sample audio.

Reimar Döffinger Reimar.Doeffinger at gmx.de
Tue Mar 11 19:57:56 CET 2014


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.
---
 libao2/ao_sndio.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/libao2/ao_sndio.c b/libao2/ao_sndio.c
index f04115e..013d78a 100644
--- a/libao2/ao_sndio.c
+++ b/libao2/ao_sndio.c
@@ -103,6 +103,10 @@ static int init(int rate, int channels, int format, int flags)
     }
     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 @@ static int init(int rate, int channels, int format, int flags)
         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;
     }
-- 
1.9.0



More information about the MPlayer-dev-eng mailing list