spa: make a function to make a channel short name

Make a function that can generate and parse a short name for
the positions that are not in the type list, like the AUX channels.
This commit is contained in:
Wim Taymans 2025-10-22 13:04:53 +02:00
parent 7177f8269d
commit 11f1298f53
16 changed files with 74 additions and 38 deletions

View file

@ -283,14 +283,15 @@ void audioinfo_to_properties(struct spa_audio_info_raw *info, struct pw_properti
if (info->rate)
pw_properties_setf(props, SPA_KEY_AUDIO_RATE, "%u", info->rate);
if (info->channels) {
char *s, *p;
char *s, *p, pos[8];
pw_properties_setf(props, SPA_KEY_AUDIO_CHANNELS, "%u", info->channels);
p = s = alloca(info->channels * 8);
for (i = 0; i < info->channels; i++)
p += spa_scnprintf(p, 8, "%s%s", i == 0 ? "" : ", ",
channel_id2name(spa_format_audio_raw_get_position(info, i)));
channel_id2name(spa_format_audio_raw_get_position(info, i),
pos, sizeof(pos)));
pw_properties_setf(props, SPA_KEY_AUDIO_POSITION, "[ %s ]", s);
}
}