aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/modplug_decoder_plugin.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/modplug_decoder_plugin.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/modplug_decoder_plugin.c')
-rw-r--r--src/decoder/modplug_decoder_plugin.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/decoder/modplug_decoder_plugin.c b/src/decoder/modplug_decoder_plugin.c
index 9345dd240..21ee79e7e 100644
--- a/src/decoder/modplug_decoder_plugin.c
+++ b/src/decoder/modplug_decoder_plugin.c
@@ -19,6 +19,7 @@
#include "config.h"
#include "decoder_api.h"
+#include "tag_handler.h"
#include <glib.h>
#include <modplug.h>
@@ -149,34 +150,33 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
ModPlug_Unload(f);
}
-static struct tag *
-modplug_stream_tag(struct input_stream *is)
+static bool
+modplug_scan_stream(struct input_stream *is,
+ const struct tag_handler *handler, void *handler_ctx)
{
ModPlugFile *f;
- struct tag *ret = NULL;
GByteArray *bdatas;
- char *title;
bdatas = mod_loadfile(NULL, is);
if (!bdatas)
- return NULL;
+ return false;
f = ModPlug_Load(bdatas->data, bdatas->len);
g_byte_array_free(bdatas, TRUE);
if (f == NULL)
- return NULL;
+ return false;
- ret = tag_new();
- ret->time = ModPlug_GetLength(f) / 1000;
+ tag_handler_invoke_duration(handler, handler_ctx,
+ ModPlug_GetLength(f) / 1000);
- title = g_strdup(ModPlug_GetName(f));
- if (title)
- tag_add_item(ret, TAG_TITLE, title);
- g_free(title);
+ const char *title = ModPlug_GetName(f);
+ if (title != NULL)
+ tag_handler_invoke_tag(handler, handler_ctx,
+ TAG_TITLE, title);
ModPlug_Unload(f);
- return ret;
+ return true;
}
static const char *const mod_suffixes[] = {
@@ -189,6 +189,6 @@ static const char *const mod_suffixes[] = {
const struct decoder_plugin modplug_decoder_plugin = {
.name = "modplug",
.stream_decode = mod_decode,
- .stream_tag = modplug_stream_tag,
+ .scan_stream = modplug_scan_stream,
.suffixes = mod_suffixes,
};