aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/decoder/mp4ff_decoder_plugin.c11
-rw-r--r--src/tag_ape.c9
-rw-r--r--src/tag_table.h16
3 files changed, 22 insertions, 14 deletions
diff --git a/src/decoder/mp4ff_decoder_plugin.c b/src/decoder/mp4ff_decoder_plugin.c
index 89f65670e..6202ece9e 100644
--- a/src/decoder/mp4ff_decoder_plugin.c
+++ b/src/decoder/mp4ff_decoder_plugin.c
@@ -356,16 +356,17 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
mp4ff_close(mp4fh);
}
-static const char *const mp4ff_tag_names[TAG_NUM_OF_ITEM_TYPES] = {
- [TAG_ALBUM_ARTIST] = "album artist",
- [TAG_COMPOSER] = "writer",
- [TAG_PERFORMER] = "band",
+static const struct tag_table mp4ff_tags[] = {
+ { "album artist", TAG_ALBUM_ARTIST },
+ { "writer", TAG_COMPOSER },
+ { "band", TAG_PERFORMER },
+ { NULL, TAG_NUM_OF_ITEM_TYPES }
};
static enum tag_type
mp4ff_tag_name_parse(const char *name)
{
- enum tag_type type = tag_table_lookup(mp4ff_tag_names, name);
+ enum tag_type type = tag_table_lookup_i(mp4ff_tags, name);
if (type == TAG_NUM_OF_ITEM_TYPES)
type = tag_name_parse_i(name);
diff --git a/src/tag_ape.c b/src/tag_ape.c
index 1978ea39b..5a30531c0 100644
--- a/src/tag_ape.c
+++ b/src/tag_ape.c
@@ -23,15 +23,16 @@
#include "tag_table.h"
#include "ape.h"
-static const char *const ape_tag_names[TAG_NUM_OF_ITEM_TYPES] = {
- [TAG_ALBUM_ARTIST] = "album artist",
- [TAG_DATE] = "year",
+static const struct tag_table ape_tags[] = {
+ { "album artist", TAG_ALBUM_ARTIST },
+ { "year", TAG_DATE },
+ { NULL, TAG_NUM_OF_ITEM_TYPES }
};
static enum tag_type
tag_ape_name_parse(const char *name)
{
- enum tag_type type = tag_table_lookup(ape_tag_names, name);
+ enum tag_type type = tag_table_lookup_i(ape_tags, name);
if (type == TAG_NUM_OF_ITEM_TYPES)
type = tag_name_parse_i(name);
diff --git a/src/tag_table.h b/src/tag_table.h
index 367a3de5f..ecb3805d2 100644
--- a/src/tag_table.h
+++ b/src/tag_table.h
@@ -24,18 +24,24 @@
#include <glib.h>
+struct tag_table {
+ const char *name;
+
+ enum tag_type type;
+};
+
/**
* Looks up a string in a tag translation table (case insensitive).
* Returns TAG_NUM_OF_ITEM_TYPES if the specified name was not found
* in the table.
*/
+G_GNUC_PURE
static inline enum tag_type
-tag_table_lookup(const char *const* table, const char *name)
+tag_table_lookup_i(const struct tag_table *table, const char *name)
{
- for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; i++)
- if (table[i] != NULL &&
- g_ascii_strcasecmp(name, table[i]) == 0)
- return (enum tag_type)i;
+ for (; table->name != NULL; ++table)
+ if (g_ascii_strcasecmp(name, table->name) == 0)
+ return table->type;
return TAG_NUM_OF_ITEM_TYPES;
}