Tuesday, October 04, 2022

Re: xine's ffmpegaudio doesn't downmix, sio_getpar() reports 6 channels instead of 2

On Mon, Oct 03, 2022 at 03:11:51PM +0000, adr wrote:
> On Mon, 3 Oct 2022, Alexandre Ratchov wrote:
> >
> > I tried to play this file:
> >
> > $ ffprobe ~/Downloads/Surround\ Sound\ Test\ PCM\ 5.1.m2ts 2>&1 | grep Audio
> > Stream #0:1[0x1100]: Audio: pcm_bluray (HDMV / 0x564D4448), 48000 Hz, 5.1(side), s16, 4608 kb/s
>
> I haven't tried multichannel PCM, but I've tested AAC and A/52
> streams. By the way, there is an internal A/52 downmixer but I
> can't remember if it is available with liba52 disabled.
>

Thanks for the explanation. I used the wrong file format. Now
everything works as expected.

> In respect to force the downmix into sndiod, yes I'm with you. But
> until the developers agree on how to implement it, better to be
> able to hear an audio stream correctly, don't you think? The patch
> is really small. Now I think is better to not ask upstream but to
> keep it as a patch until sndiod is fixed.

Agreed. Here's a diff against the ports tree:

Other tests? OKs?

Index: Makefile
===================================================================
RCS file: /cvs/ports/multimedia/xine-lib/Makefile,v
retrieving revision 1.155
diff -u -p -u -p -r1.155 Makefile
--- Makefile 3 Apr 2022 11:12:09 -0000 1.155
+++ Makefile 4 Oct 2022 10:47:26 -0000
@@ -1,7 +1,7 @@
COMMENT= multimedia decoding library

DISTNAME= xine-lib-1.2.12
-REVISION= 2
+REVISION= 3
CATEGORIES= multimedia
MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=xine/}
EXTRACT_SUFX= .tar.xz
Index: patches/patch-src_audio_out_audio_sndio_out_c
===================================================================
RCS file: patches/patch-src_audio_out_audio_sndio_out_c
diff -N patches/patch-src_audio_out_audio_sndio_out_c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_audio_out_audio_sndio_out_c 4 Oct 2022 10:47:26 -0000
@@ -0,0 +1,108 @@
+Index: src/audio_out/audio_sndio_out.c
+--- src/audio_out/audio_sndio_out.c.orig
++++ src/audio_out/audio_sndio_out.c
+@@ -37,6 +37,8 @@
+ #include <xine/audio_out.h>
+ #include "bswap.h"
+
++#include "speakers.h"
++
+ #define GAP_TOLERANCE AO_MAX_GAP
+ #define PCT_TO_MIDI(p) (((p) * SIO_MAXVOL + 50) / 100)
+
+@@ -248,11 +250,15 @@ static void ao_sndio_exit(ao_driver_t *this_gen)
+ {
+ sndio_driver_t *this = (sndio_driver_t *) this_gen;
+
++ this->xine->config->unregister_callbacks (this->xine->config, "audio.output.speaker_arrangement", NULL, this, sizeof (*this));
++
+ xprintf (this->xine, XINE_VERBOSITY_DEBUG,
+ "audio_sndio_out: ao_sndio_exit called\n");
+
+ if (this->hdl != NULL)
+ sio_close(this->hdl);
++
++ free (this);
+ }
+
+ static int ao_sndio_get_property (ao_driver_t *this_gen, int property)
+@@ -316,13 +322,27 @@ static int ao_sndio_ctrl(ao_driver_t *this_gen, int cm
+ return 0;
+ }
+
++static void sndio_speaker_arrangement_cb (void *user_data,
++ xine_cfg_entry_t *entry);
++
+ static ao_driver_t *open_plugin (audio_driver_class_t *class_gen, const void *data)
+ {
+ sndio_class_t *class = (sndio_class_t *) class_gen;
++ config_values_t *config = class->xine->config;
+ sndio_driver_t *this;
+
+ lprintf ("audio_sndio_out: open_plugin called\n");
+
++ AUDIO_DEVICE_SPEAKER_ARRANGEMENT_TYPES;
++ int speakers;
++
++ speakers = config->register_enum (config,
++ "audio.output.speaker_arrangement",
++ STEREO,
++ (char **)speaker_arrangement,
++ AUDIO_DEVICE_SPEAKER_ARRANGEMENT_HELP,
++ 0, sndio_speaker_arrangement_cb, this);
++
+ this = calloc(1, sizeof (sndio_driver_t));
+ if (!this)
+ return NULL;
+@@ -333,10 +353,16 @@ static ao_driver_t *open_plugin (audio_driver_class_t
+ * Set capabilities
+ */
+ this->capabilities = AO_CAP_MODE_MONO | AO_CAP_MODE_STEREO |
+- AO_CAP_MODE_4CHANNEL | AO_CAP_MODE_4_1CHANNEL |
+- AO_CAP_MODE_5CHANNEL | AO_CAP_MODE_5_1CHANNEL |
+ AO_CAP_MIXER_VOL | AO_CAP_MUTE_VOL | AO_CAP_8BITS |
+ AO_CAP_16BITS;
++ if (speakers == SURROUND4)
++ this->capabilities |= AO_CAP_MODE_4CHANNEL;
++ if (speakers == SURROUND41)
++ this->capabilities |= AO_CAP_MODE_4_1CHANNEL;
++ if (speakers == SURROUND5)
++ this->capabilities |= AO_CAP_MODE_5CHANNEL;
++ if (speakers == SURROUND51)
++ this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
+
+ this->ao_driver.get_capabilities = ao_sndio_get_capabilities;
+ this->ao_driver.get_property = ao_sndio_get_property;
+@@ -352,6 +378,32 @@ static ao_driver_t *open_plugin (audio_driver_class_t
+ this->ao_driver.control = ao_sndio_ctrl;
+
+ return &this->ao_driver;
++}
++
++static void sndio_speaker_arrangement_cb (void *user_data,
++ xine_cfg_entry_t *entry) {
++ sndio_driver_t *this = (sndio_driver_t *) user_data;
++ int32_t value = entry->num_value;
++ if (value == SURROUND4) {
++ this->capabilities |= AO_CAP_MODE_4CHANNEL;
++ } else {
++ this->capabilities &= ~AO_CAP_MODE_4CHANNEL;
++ }
++ if (value == SURROUND41) {
++ this->capabilities |= AO_CAP_MODE_4_1CHANNEL;
++ } else {
++ this->capabilities &= ~AO_CAP_MODE_4_1CHANNEL;
++ }
++ if (value == SURROUND5) {
++ this->capabilities |= AO_CAP_MODE_5CHANNEL;
++ } else {
++ this->capabilities &= ~AO_CAP_MODE_5CHANNEL;
++ }
++ if (value >= SURROUND51) {
++ this->capabilities |= AO_CAP_MODE_5_1CHANNEL;
++ } else {
++ this->capabilities &= ~AO_CAP_MODE_5_1CHANNEL;
++ }
+ }
+
+ /*

No comments:

Post a Comment