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
This commit is contained in:
Wim Taymans 2021-10-14 13:27:57 +02:00
parent 257bbb1fd5
commit d6c1479ba0
2 changed files with 19 additions and 0 deletions

View file

@ -414,6 +414,7 @@ build_module_zeroconf_discover = avahi_dep.found()
if build_module_zeroconf_discover if build_module_zeroconf_discover
pipewire_module_zeroconf_discover = shared_library('pipewire-module-zeroconf-discover', pipewire_module_zeroconf_discover = shared_library('pipewire-module-zeroconf-discover',
[ 'module-zeroconf-discover.c', [ 'module-zeroconf-discover.c',
'module-protocol-pulse/format.c',
'module-zeroconf-discover/avahi-poll.c' ], 'module-zeroconf-discover/avahi-poll.c' ],
include_directories : [configinc, spa_inc], include_directories : [configinc, spa_inc],
install : true, install : true,

View file

@ -44,6 +44,7 @@
#include <avahi-common/error.h> #include <avahi-common/error.h>
#include <avahi-common/malloc.h> #include <avahi-common/malloc.h>
#include "module-protocol-pulse/format.h"
#include "module-zeroconf-discover/avahi-poll.h" #include "module-zeroconf-discover/avahi-poll.h"
/** \page page_module_zeroconf_discover PipeWire Module: Zeroconf Discover /** \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")) { else if (spa_streq(key, "channels")) {
pw_properties_setf(props, PW_KEY_AUDIO_CHANNELS, "%u", atoi(value)); 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")) { else if (spa_streq(key, "format")) {
pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value); pw_properties_set(props, PW_KEY_AUDIO_FORMAT, value);
} }