decoder: switch a bunch of plugins to stream_tag()

This patch changes the following decoder plugins to implement
stream_tag() instead of tag_dup():

 faad, ffmpeg, mad, modplug, mp4ff, mpcdec, oggflac

This simplifies their code, because they do not need to take care of
opening/closing the stream.
This commit is contained in:
Max Kellermann
2009-12-31 18:20:08 +01:00
parent 6b96f5d566
commit 05cde5810a
7 changed files with 45 additions and 110 deletions

View File

@@ -149,31 +149,23 @@ mod_decode(struct decoder *decoder, struct input_stream *is)
ModPlug_Unload(f);
}
static struct tag *mod_tagdup(const char *file)
static struct tag *
modplug_stream_tag(struct input_stream *is)
{
ModPlugFile *f;
struct tag *ret = NULL;
GByteArray *bdatas;
char *title;
struct input_stream is;
if (!input_stream_open(&is, file, NULL)) {
g_warning("cant open file %s\n", file);
bdatas = mod_loadfile(NULL, is);
if (!bdatas)
return NULL;
}
bdatas = mod_loadfile(NULL, &is);
if (!bdatas) {
g_warning("cant load file %s\n", file);
return NULL;
}
f = ModPlug_Load(bdatas->data, bdatas->len);
g_byte_array_free(bdatas, TRUE);
if (!f) {
g_warning("could not decode file %s\n", file);
if (f == NULL)
return NULL;
}
ret = tag_new();
ret->time = ModPlug_GetLength(f) / 1000;
@@ -184,8 +176,6 @@ static struct tag *mod_tagdup(const char *file)
ModPlug_Unload(f);
input_stream_close(&is);
return ret;
}
@@ -199,6 +189,6 @@ static const char *const mod_suffixes[] = {
const struct decoder_plugin modplug_decoder_plugin = {
.name = "modplug",
.stream_decode = mod_decode,
.tag_dup = mod_tagdup,
.stream_tag = modplug_stream_tag,
.suffixes = mod_suffixes,
};