json: add helper function to parse channel positions

Use the helper instead of duplicating the same code.

Also add some helpers to parse a json array of uint32_t

Move some functions to convert between type name and id.
This commit is contained in:
Wim Taymans 2024-09-18 09:54:34 +02:00
parent 911a601b95
commit e2991f6398
34 changed files with 256 additions and 791 deletions

View file

@ -502,12 +502,7 @@ static void get_channels(struct spa_bt_transport *t, bool a2dp_duplex, uint32_t
static const char *get_channel_name(uint32_t channel)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (spa_type_audio_channel[i].type == channel)
return spa_debug_type_short_name(spa_type_audio_channel[i].name);
}
return NULL;
return spa_type_to_short_name(channel, spa_type_audio_channel, NULL);
}
static int channel_position_cmp(const void *pa, const void *pb)