pipewiresink: set a default channel map if the number of channels is fixed 85/27185/2
authorAshok Sidipotu <ashok.sidipotu@collabora.com>
Fri, 4 Feb 2022 05:37:55 +0000 (11:07 +0530)
committerJan-Simon Moeller <jsmoeller@linuxfoundation.org>
Wed, 2 Mar 2022 12:22:30 +0000 (12:22 +0000)
-This allows remaping streams using pipewiresink to match the channel layout
of the target device

Bug-AGL: SPEC-4241
Change-Id: I4090187dc9977fc3d0ee440b601cb95f6864a9cf
Signed-off-by: Ashok Sidipotu <ashok.sidipotu@collabora.com>
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/27130
Reviewed-by: Scott Murray <scott.murray@konsulko.com>
Reviewed-by: Jan-Simon Moeller <jsmoeller@linuxfoundation.org>
Tested-by: Jenkins Job builder account
ci-image-build: Jenkins Job builder account
ci-image-boot-test: Jenkins Job builder account
(cherry picked from commit 322965878f61d40173695a9677c6d5200eefae58)
Reviewed-on: https://gerrit.automotivelinux.org/gerrit/c/AGL/meta-agl/+/27185
Reviewed-by: Georgios Kiagiadakis <george.kiagiadakis@collabora.com>
meta-pipewire/recipes-multimedia/pipewire/pipewire/0005-pipewiresink-set-a-default-channel-map-if-the-number.patch [new file with mode: 0644]
meta-pipewire/recipes-multimedia/pipewire/pipewire_0.3.43.bbappend

diff --git a/meta-pipewire/recipes-multimedia/pipewire/pipewire/0005-pipewiresink-set-a-default-channel-map-if-the-number.patch b/meta-pipewire/recipes-multimedia/pipewire/pipewire/0005-pipewiresink-set-a-default-channel-map-if-the-number.patch
new file mode 100644 (file)
index 0000000..3b1b2a4
--- /dev/null
@@ -0,0 +1,77 @@
+From ee2e6412d37d012fbf8d25bd37271a5ee92b3ad4 Mon Sep 17 00:00:00 2001
+From: George Kiagiadakis <george.kiagiadakis@collabora.com>
+Date: Thu, 3 Feb 2022 15:08:57 +0200
+Subject: [PATCH] pipewiresink: set a default channel map if the number of
+ channels is fixed
+
+This allows remaping streams using pipewiresink to match the channel layout
+of the target device
+Upstream-Status: Backport [from master/0.3.46]
+---
+ src/gst/gstpipewireformat.c | 42 ++++++++++++++++++++++++++++++++++++-
+ 1 file changed, 41 insertions(+), 1 deletion(-)
+
+diff --git a/src/gst/gstpipewireformat.c b/src/gst/gstpipewireformat.c
+index dca90267c..c8ce7ba62 100644
+--- a/src/gst/gstpipewireformat.c
++++ b/src/gst/gstpipewireformat.c
+@@ -445,6 +445,44 @@ handle_video_fields (ConvertData *d)
+   return TRUE;
+ }
++static void
++set_default_channels (struct spa_pod_builder *b, uint32_t channels)
++{
++  uint32_t position[SPA_AUDIO_MAX_CHANNELS] = {0};
++  gboolean ok = TRUE;
++
++  switch (channels) {
++  case 8:
++    position[6] = SPA_AUDIO_CHANNEL_SL;
++    position[7] = SPA_AUDIO_CHANNEL_SR;
++    SPA_FALLTHROUGH
++  case 6:
++    position[5] = SPA_AUDIO_CHANNEL_LFE;
++    SPA_FALLTHROUGH
++  case 5:
++    position[4] = SPA_AUDIO_CHANNEL_FC;
++    SPA_FALLTHROUGH
++  case 4:
++    position[2] = SPA_AUDIO_CHANNEL_RL;
++    position[3] = SPA_AUDIO_CHANNEL_RR;
++    SPA_FALLTHROUGH
++  case 2:
++    position[0] = SPA_AUDIO_CHANNEL_FL;
++    position[1] = SPA_AUDIO_CHANNEL_FR;
++    break;
++  case 1:
++    position[0] = SPA_AUDIO_CHANNEL_MONO;
++    break;
++  default:
++    ok = FALSE;
++    break;
++  }
++
++  if (ok)
++    spa_pod_builder_add (b, SPA_FORMAT_AUDIO_position,
++        SPA_POD_Array(sizeof(uint32_t), SPA_TYPE_Id, channels, position), 0);
++}
++
+ static gboolean
+ handle_audio_fields (ConvertData *d)
+ {
+@@ -538,8 +576,10 @@ handle_audio_fields (ConvertData *d)
+     }
+     if (i > 0) {
+       choice = spa_pod_builder_pop(&d->b, &f);
+-      if (i == 1)
++      if (i == 1) {
+         choice->body.type = SPA_CHOICE_None;
++        set_default_channels (&d->b, v);
++      }
+     }
+   }
+   return TRUE;
+-- 
+2.34.1
+
index e2bc0d2..8d3df64 100644 (file)
@@ -11,6 +11,7 @@ SRC_URI += "\
     file://0002-Revert-treewide-meson.build-use-dependency-variable-.patch \
     file://0003-Revert-meson-declare-spa_dep-and-override_dependency.patch \
     file://0004-Revert-systemd-correctly-prefix-systemd-system-units.patch \
+    file://0005-pipewiresink-set-a-default-channel-map-if-the-number.patch \
 "
 
 do_install:append() {