From 5d73215a8dad922c8e383f3837f3ec9e26503389 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 11 Feb 2012 19:12:02 +0100 Subject: decoder_plugin: scan tags with callback table Pass a callback table to scan_file() and scan_stream(), instead of returning a tag object. --- src/decoder/audiofile_decoder_plugin.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/decoder/audiofile_decoder_plugin.c') diff --git a/src/decoder/audiofile_decoder_plugin.c b/src/decoder/audiofile_decoder_plugin.c index 8d6236a57..7db7c7517 100644 --- a/src/decoder/audiofile_decoder_plugin.c +++ b/src/decoder/audiofile_decoder_plugin.c @@ -20,6 +20,7 @@ #include "config.h" #include "decoder_api.h" #include "audio_check.h" +#include "tag_handler.h" #include #include @@ -222,20 +223,20 @@ audiofile_stream_decode(struct decoder *decoder, struct input_stream *is) afCloseFile(af_fp); } -static struct tag *audiofile_tag_dup(const char *file) +static bool +audiofile_scan_file(const char *file, + const struct tag_handler *handler, void *handler_ctx) { - struct tag *ret = NULL; int total_time = audiofile_get_duration(file); - if (total_time >= 0) { - ret = tag_new(); - ret->time = total_time; - } else { + if (total_time < 0) { g_debug("Failed to get total song time from: %s\n", file); + return false; } - return ret; + tag_handler_invoke_duration(handler, handler_ctx, total_time); + return true; } static const char *const audiofile_suffixes[] = { @@ -251,7 +252,7 @@ static const char *const audiofile_mime_types[] = { const struct decoder_plugin audiofile_decoder_plugin = { .name = "audiofile", .stream_decode = audiofile_stream_decode, - .tag_dup = audiofile_tag_dup, + .scan_file = audiofile_scan_file, .suffixes = audiofile_suffixes, .mime_types = audiofile_mime_types, }; -- cgit v1.2.3