pulse-server: refactor channel position parsing

This commit is contained in:
Wim Taymans 2023-02-23 12:39:36 +01:00
parent eca4049a38
commit ad6ab7e0b7
3 changed files with 18 additions and 10 deletions

View file

@ -390,6 +390,22 @@ void channel_map_parse(const char *str, struct channel_map *map)
}
}
void channel_map_parse_position(const char *str, struct channel_map *map)
{
struct spa_json it[2];
char v[256];
spa_json_init(&it[0], str, strlen(str));
if (spa_json_enter_array(&it[0], &it[1]) <= 0)
spa_json_init(&it[1], str, strlen(str));
map->channels = 0;
while (spa_json_get_string(&it[1], v, sizeof(v)) > 0 &&
map->channels < SPA_AUDIO_MAX_CHANNELS) {
map->map[map->channels++] = channel_name2id(v);
}
}
bool channel_map_valid(const struct channel_map *map)
{
uint8_t i;