pulse-server: convert channel_map channels

channel_map contains pulseaudio channel names, convert them to
pipewire channel ids and then into pipewire channel names for the
null sink.
This commit is contained in:
Wim Taymans 2020-12-07 20:29:22 +01:00
parent 1e89e7559b
commit 157d6de607
2 changed files with 24 additions and 1 deletions

View file

@ -376,6 +376,19 @@ static inline void channel_map_to_positions(const struct channel_map *map, uint3
pos[i] = map->map[i]; pos[i] = map->map[i];
} }
static inline void channel_map_parse(const char *str, struct channel_map *map)
{
const char *p = str;
size_t len;
while (*p && map->channels < SPA_AUDIO_MAX_CHANNELS) {
if ((len = strcspn(p, ",")) == 0)
break;
map->map[map->channels++] = channel_paname2id(p, len);
p += len + strspn(p+len, ",");
}
}
static inline bool channel_map_valid(const struct channel_map *map) static inline bool channel_map_valid(const struct channel_map *map)
{ {
uint8_t i; uint8_t i;

View file

@ -180,7 +180,17 @@ static int load_module(struct client *client, const char *name, const char *argu
pw_properties_set(props, "rate", NULL); pw_properties_set(props, "rate", NULL);
} }
if ((str = pw_properties_get(props, "channel_map")) != NULL) { if ((str = pw_properties_get(props, "channel_map")) != NULL) {
pw_properties_set(props, "audio.position", str); struct channel_map map = CHANNEL_MAP_INIT;
uint32_t i;
char *s, *p;
channel_map_parse(str, &map);
p = s = alloca(map.channels * 6);
for (i = 0; i < map.channels; i++)
p += snprintf(p, 6, "%s%s", i == 0 ? "" : ",",
channel_id2name(map.map[i]));
pw_properties_set(props, "audio.position", s);
pw_properties_set(props, "channel_map", NULL); pw_properties_set(props, "channel_map", NULL);
} }
if ((str = pw_properties_get(props, "device.description")) != NULL) { if ((str = pw_properties_get(props, "device.description")) != NULL) {