aboutsummaryrefslogtreecommitdiffstats
path: root/src/song_update.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-12-30 23:27:37 +0100
committerMax Kellermann <max@duempel.org>2010-01-01 17:25:07 +0100
commitd3b763a48c09a60a0c0b5ccb6cccd9376875c470 (patch)
tree83b8794f78ef8941806cf5757888d8abf2eaa126 /src/song_update.c
parent816b6ad4a71c3ade95e62b62396f2b0415c03f20 (diff)
downloadmpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.tar.gz
mpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.tar.xz
mpd-d3b763a48c09a60a0c0b5ccb6cccd9376875c470.zip
input_stream: return allocated input_stream objects
Major API redesign: don't let the caller allocate the input_stream object. Let each input plugin allocate its own (derived/extended) input_stream pointer. The "data" attribute can now be removed, and all input plugins simply cast the input_stream pointer to their own structure (with an "struct input_stream base" as the first attribute).
Diffstat (limited to 'src/song_update.c')
-rw-r--r--src/song_update.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/src/song_update.c b/src/song_update.c
index a264c75da..b418b600e 100644
--- a/src/song_update.c
+++ b/src/song_update.c
@@ -101,7 +101,7 @@ song_file_update(struct song *song)
char *path_fs;
const struct decoder_plugin *plugin;
struct stat st;
- struct input_stream is = { .plugin = NULL };
+ struct input_stream *is = NULL;
assert(song_is_file(song));
@@ -141,26 +141,25 @@ song_file_update(struct song *song)
if (plugin->stream_tag != NULL) {
/* open the input_stream (if not already
open) */
- if (is.plugin == NULL &&
- !input_stream_open(&is, path_fs, NULL))
- is.plugin = NULL;
+ if (is == NULL)
+ is = input_stream_open(path_fs, NULL);
/* now try the stream_tag() method */
- if (is.plugin != NULL) {
+ if (is != NULL) {
song->tag = decoder_plugin_stream_tag(plugin,
- &is);
+ is);
if (song->tag != NULL)
break;
- input_stream_seek(&is, 0, SEEK_SET, NULL);
+ input_stream_seek(is, 0, SEEK_SET, NULL);
}
}
plugin = decoder_plugin_from_suffix(suffix, plugin);
} while (plugin != NULL);
- if (is.plugin != NULL)
- input_stream_close(&is);
+ if (is != NULL)
+ input_stream_close(is);
if (song->tag != NULL && tag_is_empty(song->tag))
song->tag = tag_fallback(path_fs, song->tag);