types: add function to convert audio channel short name to type

Move some functions around for this
This commit is contained in:
Wim Taymans 2024-09-16 13:27:17 +02:00
parent b5cccdb382
commit 41f9abc733
5 changed files with 27 additions and 9 deletions

View file

@ -15,6 +15,7 @@ extern "C" {
*/
#include <spa/utils/type.h>
#include <spa/utils/string.h>
#include <spa/param/audio/raw.h>
#define SPA_TYPE_INFO_AudioFormat SPA_TYPE_INFO_ENUM_BASE "AudioFormat"
@ -247,6 +248,17 @@ static const struct spa_type_info spa_type_audio_channel[] = {
{ 0, 0, NULL, NULL },
};
static inline uint32_t spa_type_audio_channel_from_short_name(const char *name)
{
int i;
for (i = 0; spa_type_audio_channel[i].name; i++) {
if (spa_streq(name, spa_type_short_name(spa_type_audio_channel[i].name)))
return spa_type_audio_channel[i].type;
}
return SPA_AUDIO_CHANNEL_UNKNOWN;
}
/**
* \}
*/