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:
@@ -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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user