From ae1a7fc84ae81a02208fdf6cb3f02581deee94f1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sun, 15 Mar 2009 18:36:29 +0100 Subject: vorbis_encoder: added support for all MPD tag types Copy all tags know to MPD to the vorbis_comment. --- Makefile.am | 2 ++ src/encoder/vorbis_encoder.c | 33 ++++----------------------------- 2 files changed, 6 insertions(+), 29 deletions(-) diff --git a/Makefile.am b/Makefile.am index d25703b1a..007c3f353 100644 --- a/Makefile.am +++ b/Makefile.am @@ -591,6 +591,7 @@ test_read_tags_SOURCES = test/read_tags.c \ test_run_encoder_SOURCES = test/run_encoder.c \ src/conf.c src/buffer2array.c \ src/utils.c \ + src/tag.c src/tag_pool.c \ src/audio_parser.c \ $(ENCODER_SRC) test_run_encoder_LDADD = $(MPD_LIBS) \ @@ -614,6 +615,7 @@ test_run_output_SOURCES = test/run_output.c \ src/conf.c src/buffer2array.c src/utils.c src/log.c \ src/audio_parser.c \ src/timer.c \ + src/tag.c src/tag_pool.c \ src/fifo_buffer.c \ src/page.c \ src/socket_util.c \ diff --git a/src/encoder/vorbis_encoder.c b/src/encoder/vorbis_encoder.c index cbf227c22..b2b71f335 100644 --- a/src/encoder/vorbis_encoder.c +++ b/src/encoder/vorbis_encoder.c @@ -266,39 +266,14 @@ vorbis_encoder_flush(struct encoder *_encoder, G_GNUC_UNUSED GError **error) return true; } -static void -add_tag(vorbis_comment *vc, const char *name, char *value) -{ - if (value) { - union { - const char *in; - char *out; - } u = { .in = name }; - - vorbis_comment_add_tag(vc, u.out, value); - } -} - static void copy_tag_to_vorbis_comment(vorbis_comment *vc, const struct tag *tag) { for (unsigned i = 0; i < tag->num_items; i++) { - switch (tag->items[i]->type) { - case TAG_ITEM_ARTIST: - add_tag(vc, "ARTIST", tag->items[i]->value); - break; - - case TAG_ITEM_ALBUM: - add_tag(vc, "ALBUM", tag->items[i]->value); - break; - - case TAG_ITEM_TITLE: - add_tag(vc, "TITLE", tag->items[i]->value); - break; - - default: - break; - } + struct tag_item *item = tag->items[i]; + char *name = g_ascii_strup(tag_item_names[item->type], -1); + vorbis_comment_add_tag(vc, name, item->value); + g_free(name); } } -- cgit v1.2.3