diff --git a/src/modules/module-protocol-pulse/format.c b/src/modules/module-protocol-pulse/format.c index c6bfe3677..5f3081b51 100644 --- a/src/modules/module-protocol-pulse/format.c +++ b/src/modules/module-protocol-pulse/format.c @@ -376,6 +376,19 @@ static inline void channel_map_to_positions(const struct channel_map *map, uint3 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) { uint8_t i; diff --git a/src/modules/module-protocol-pulse/module.c b/src/modules/module-protocol-pulse/module.c index 03ef21ca7..723c93f45 100644 --- a/src/modules/module-protocol-pulse/module.c +++ b/src/modules/module-protocol-pulse/module.c @@ -180,7 +180,17 @@ static int load_module(struct client *client, const char *name, const char *argu pw_properties_set(props, "rate", 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); } if ((str = pw_properties_get(props, "device.description")) != NULL) {