aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/vorbis_comments.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-02-11 19:12:02 +0100
committerMax Kellermann <max@duempel.org>2012-02-11 17:04:29 +0100
commit5d73215a8dad922c8e383f3837f3ec9e26503389 (patch)
tree8fc4b96d93a907054a05d3250f97bf4f68c6df85 /src/decoder/vorbis_comments.c
parentb7356bc526dbbd6fa00d40caff2addec10ae7c7e (diff)
downloadmpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.gz
mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.xz
mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.zip
decoder_plugin: scan tags with callback table
Pass a callback table to scan_file() and scan_stream(), instead of returning a tag object.
Diffstat (limited to 'src/decoder/vorbis_comments.c')
-rw-r--r--src/decoder/vorbis_comments.c35
1 files changed, 23 insertions, 12 deletions
diff --git a/src/decoder/vorbis_comments.c b/src/decoder/vorbis_comments.c
index 9145507dc..e94ee3d0a 100644
--- a/src/decoder/vorbis_comments.c
+++ b/src/decoder/vorbis_comments.c
@@ -21,6 +21,7 @@
#include "vorbis_comments.h"
#include "tag.h"
#include "tag_table.h"
+#include "tag_handler.h"
#include "replay_gain_info.h"
#include <glib.h>
@@ -79,14 +80,15 @@ vorbis_comments_to_replay_gain(struct replay_gain_info *rgi, char **comments)
* the comment value into the tag.
*/
static bool
-vorbis_copy_comment(struct tag *tag, const char *comment,
- const char *name, enum tag_type tag_type)
+vorbis_copy_comment(const char *comment,
+ const char *name, enum tag_type tag_type,
+ const struct tag_handler *handler, void *handler_ctx)
{
const char *value;
value = vorbis_comment_value(comment, name);
if (value != NULL) {
- tag_add_item(tag, tag_type, value);
+ tag_handler_invoke_tag(handler, handler_ctx, tag_type, value);
return true;
}
@@ -101,27 +103,36 @@ static const struct tag_table vorbis_tags[] = {
};
static void
-vorbis_parse_comment(struct tag *tag, const char *comment)
+vorbis_scan_comment(const char *comment,
+ const struct tag_handler *handler, void *handler_ctx)
{
- assert(tag != NULL);
-
for (const struct tag_table *i = vorbis_tags; i->name != NULL; ++i)
- if (vorbis_copy_comment(tag, comment, i->name, i->type))
+ if (vorbis_copy_comment(comment, i->name, i->type,
+ handler, handler_ctx))
return;
for (unsigned i = 0; i < TAG_NUM_OF_ITEM_TYPES; ++i)
- if (vorbis_copy_comment(tag, comment,
- tag_item_names[i], i))
+ if (vorbis_copy_comment(comment,
+ tag_item_names[i], i,
+ handler, handler_ctx))
return;
}
+void
+vorbis_comments_scan(char **comments,
+ const struct tag_handler *handler, void *handler_ctx)
+{
+ while (*comments)
+ vorbis_scan_comment(*comments++,
+ handler, handler_ctx);
+
+}
+
struct tag *
vorbis_comments_to_tag(char **comments)
{
struct tag *tag = tag_new();
-
- while (*comments)
- vorbis_parse_comment(tag, *comments++);
+ vorbis_comments_scan(comments, &add_tag_handler, tag);
if (tag_is_empty(tag)) {
tag_free(tag);