From d6c1479ba0fbc05c39f8b61f020921477db60c58 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 14 Oct 2021 13:27:57 +0200 Subject: [PATCH] module-zeroconf-discover: also parse the channel_map So that we create the device with the same channel_map as the remote end. Fixes #1692 --- src/modules/meson.build | 1 + src/modules/module-zeroconf-discover.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/src/modules/meson.build b/src/modules/meson.build index 319403310..ce9c1a4fa 100644 --- a/src/modules/meson.build +++ b/src/modules/meson.build @@ -414,6 +414,7 @@ build_module_zeroconf_discover = avahi_dep.found() if build_module_zeroconf_discover pipewire_module_zeroconf_discover = shared_library('pipewire-module-zeroconf-discover', [ 'module-zeroconf-discover.c', + 'module-protocol-pulse/format.c', 'module-zeroconf-discover/avahi-poll.c' ], include_directories : [configinc, spa_inc], install : true, diff --git a/src/modules/module-zeroconf-discover.c b/src/modules/module-zeroconf-discover.c index bd967cfd5..4e702bfcb 100644 --- a/src/modules/module-zeroconf-discover.c +++ b/src/modules/module-zeroconf-discover.c @@ -44,6 +44,7 @@ #include #include +#include "module-protocol-pulse/format.h" #include "module-zeroconf-discover/avahi-poll.h" /** \page page_module_zeroconf_discover PipeWire Module: Zeroconf Discover @@ -199,6 +200,23 @@ static void pw_properties_from_avahi_string(const char *key, const char *value, else if (spa_streq(key, "channels")) { pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value)); } + else if (spa_streq(key, "channel_map")) { + struct channel_map channel_map; + uint32_t i, pos[CHANNELS_MAX]; + char *p, *s; + + spa_zero(channel_map); + channel_map_parse(value, &channel_map); + channel_map_to_positions(&channel_map, pos); + + p = s = alloca(4 + channel_map.channels * 6); + p += snprintf(p, 6, "["); + for (i = 0; i < channel_map.channels; i++) + p += snprintf(p, 6, "%s%s", i == 0 ? "" : ",", + channel_id2name(pos[i])); + p += snprintf(p, 6, "]"); + pw_properties_set(props, SPA_KEY_AUDIO_POSITION, s); + } else if (spa_streq(key, "format")) { pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value); }