decoder/{vorbis,flac}: use the tag_table library
This commit is contained in:
parent
9e5a49b8cb
commit
1892d29be0
@ -21,6 +21,7 @@
|
|||||||
#include "flac_metadata.h"
|
#include "flac_metadata.h"
|
||||||
#include "replay_gain_info.h"
|
#include "replay_gain_info.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
#include "tag_table.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
|
||||||
@ -180,10 +181,12 @@ flac_copy_comment(struct tag *tag,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* tracknumber is used in VCs, MPD uses "track" ..., all the other
|
static const struct tag_table flac_tags[] = {
|
||||||
* tag names match */
|
{ "tracknumber", TAG_TRACK },
|
||||||
static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
|
{ "discnumber", TAG_DISC },
|
||||||
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
|
{ "album artist", TAG_ALBUM_ARTIST },
|
||||||
|
{ NULL, TAG_NUM_OF_ITEM_TYPES }
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
flac_parse_comment(struct tag *tag, const char *char_tnum,
|
flac_parse_comment(struct tag *tag, const char *char_tnum,
|
||||||
@ -191,13 +194,9 @@ flac_parse_comment(struct tag *tag, const char *char_tnum,
|
|||||||
{
|
{
|
||||||
assert(tag != NULL);
|
assert(tag != NULL);
|
||||||
|
|
||||||
if (flac_copy_comment(tag, entry, VORBIS_COMMENT_TRACK_KEY,
|
for (const struct tag_table *i = flac_tags; i->name != NULL; ++i)
|
||||||
TAG_TRACK, char_tnum) ||
|
if (flac_copy_comment(tag, entry, i->name, i->type, char_tnum))
|
||||||
flac_copy_comment(tag, entry, VORBIS_COMMENT_DISC_KEY,
|
return;
|
||||||
TAG_DISC, char_tnum) ||
|
|
||||||
flac_copy_comment(tag, entry, "album artist",
|
|
||||||
TAG_ALBUM_ARTIST, char_tnum))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||||
if (flac_copy_comment(tag, entry,
|
if (flac_copy_comment(tag, entry,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "vorbis_comments.h"
|
#include "vorbis_comments.h"
|
||||||
#include "tag.h"
|
#include "tag.h"
|
||||||
|
#include "tag_table.h"
|
||||||
#include "replay_gain_info.h"
|
#include "replay_gain_info.h"
|
||||||
|
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
@ -73,9 +74,6 @@ vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments)
|
|||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
|
|
||||||
static const char *VORBIS_COMMENT_TRACK_KEY = "tracknumber";
|
|
||||||
static const char *VORBIS_COMMENT_DISC_KEY = "discnumber";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the comment's name equals the passed name, and if so, copy
|
* Check if the comment's name equals the passed name, and if so, copy
|
||||||
* the comment value into the tag.
|
* the comment value into the tag.
|
||||||
@ -95,18 +93,21 @@ vorbis_copy_comment(struct tag *tag, const char *comment,
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const struct tag_table vorbis_tags[] = {
|
||||||
|
{ "tracknumber", TAG_TRACK },
|
||||||
|
{ "discnumber", TAG_DISC },
|
||||||
|
{ "album artist", TAG_ALBUM_ARTIST },
|
||||||
|
{ NULL, TAG_NUM_OF_ITEM_TYPES }
|
||||||
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vorbis_parse_comment(struct tag *tag, const char *comment)
|
vorbis_parse_comment(struct tag *tag, const char *comment)
|
||||||
{
|
{
|
||||||
assert(tag != NULL);
|
assert(tag != NULL);
|
||||||
|
|
||||||
if (vorbis_copy_comment(tag, comment, VORBIS_COMMENT_TRACK_KEY,
|
for (const struct tag_table *i = vorbis_tags; i->name != NULL; ++i)
|
||||||
TAG_TRACK) ||
|
if (vorbis_copy_comment(tag, comment, i->name, i->type))
|
||||||
vorbis_copy_comment(tag, comment, VORBIS_COMMENT_DISC_KEY,
|
return;
|
||||||
TAG_DISC) ||
|
|
||||||
vorbis_copy_comment(tag, comment, "album artist",
|
|
||||||
TAG_ALBUM_ARTIST))
|
|
||||||
return;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
|
||||||
if (vorbis_copy_comment(tag, comment,
|
if (vorbis_copy_comment(tag, comment,
|
||||||
|
Loading…
Reference in New Issue
Block a user