[MPlayer-dev-eng] [PATCH] Fix playback of 24-bit audio when sndio ao is used
Reimar Döffinger
Reimar.Doeffinger at gmx.de
Tue Mar 4 20:05:09 CET 2014
On Thu, Feb 27, 2014 at 12:19:53AM -0500, Brad Smith wrote:
> Here is a diff from Alexandre Ratchov to fix 24-bit audio with the sndio
> backend. Without the diff playing 24-bit audio results in white noise.
>
> $ mplayer test_s24be.aiff
> MPlayer SVN-r36952 (C) 2000-2014 MPlayer Team
>
> Playing test_s24be.aiff.
> libavformat version 54.63.104 (external)
> libavformat file format detected.
> [aiff @ 0x1215ca4ed860]max_analyze_duration 5000000 reached at 5010612 microseconds
> [lavf] stream 0: audio (pcm_s24be), -aid 0
> Load subtitles in ./
> ==========================================================================
> Opening audio decoder: [pcm] Uncompressed PCM audio decoder
> AUDIO: 44100 Hz, 2 ch, s24be, 2116.8 kbit/100.00% (ratio: 264600->264600)
> Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
> ==========================================================================
> AO: [sndio] 44100Hz 2ch s24be (3 bytes per sample)
> Video: no video
> Starting playback...
>
> Exiting... (End of file)
> $ mplayer test_s24le.wav
> MPlayer SVN-r36952 (C) 2000-2014 MPlayer Team
>
> Playing test_s24le.wav.
> libavformat version 54.63.104 (external)
> Audio only file format detected.
> Load subtitles in ./
> ==========================================================================
> Opening audio decoder: [pcm] Uncompressed PCM audio decoder
> AUDIO: 44100 Hz, 2 ch, s24le, 2116.8 kbit/100.00% (ratio: 264600->264600)
> Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
> ==========================================================================
> AO: [sndio] 44100Hz 2ch s24le (3 bytes per sample)
> Video: no video
> Starting playback...
>
> Exiting... (End of file)
>
>
> --- 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.
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 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...
More information about the MPlayer-dev-eng
mailing list