diff options
Diffstat (limited to 'src/decoder/modplug_decoder_plugin.c')
-rw-r--r-- | src/decoder/modplug_decoder_plugin.c | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/src/decoder/modplug_decoder_plugin.c b/src/decoder/modplug_decoder_plugin.c index 037c2fd74..21ee79e7e 100644 --- a/src/decoder/modplug_decoder_plugin.c +++ b/src/decoder/modplug_decoder_plugin.c @@ -1,5 +1,5 @@ /* - * Copyright (C) 2003-2010 The Music Player Daemon Project + * Copyright (C) 2003-2011 The Music Player Daemon Project * http://www.musicpd.org * * This program is free software; you can redistribute it and/or modify @@ -19,6 +19,7 @@ #include "config.h" #include "decoder_api.h" +#include "tag_handler.h" #include <glib.h> #include <modplug.h> @@ -62,7 +63,7 @@ static GByteArray *mod_loadfile(struct decoder *decoder, struct input_stream *is while (true) { ret = decoder_read(decoder, is, data, MODPLUG_READ_BLOCK); if (ret == 0) { - if (input_stream_eof(is)) + if (input_stream_lock_eof(is)) /* end of file */ break; @@ -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, }; |