diff options
author | Max Kellermann <max@duempel.org> | 2009-12-31 17:18:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-12-31 18:27:48 +0100 |
commit | 6b96f5d566a6a36bfcdb70c8a27771717eb3d038 (patch) | |
tree | 4792f3d8f9e16c3ba3416e46cc613e7457428cde /src/song_update.c | |
parent | 7a2e07e124ebaae8ecc55de6ea24cbb10c32cebd (diff) | |
download | mpd-6b96f5d566a6a36bfcdb70c8a27771717eb3d038.tar.gz mpd-6b96f5d566a6a36bfcdb70c8a27771717eb3d038.tar.xz mpd-6b96f5d566a6a36bfcdb70c8a27771717eb3d038.zip |
decoder_plugin: added method stream_tag()
This is like tag_dup(), but works with an input_stream object instead
of a file path.
Diffstat (limited to '')
-rw-r--r-- | src/song_update.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/song_update.c b/src/song_update.c index 17e1baf96..5ebc9a03e 100644 --- a/src/song_update.c +++ b/src/song_update.c @@ -27,12 +27,14 @@ #include "tag_ape.h" #include "tag_id3.h" #include "tag.h" +#include "input_stream.h" #include <glib.h> #include <assert.h> #include <sys/types.h> #include <sys/stat.h> +#include <stdio.h> struct song * song_file_load(const char *path, struct directory *parent) @@ -99,6 +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 }; assert(song_is_file(song)); @@ -129,13 +132,36 @@ song_file_update(struct song *song) song->mtime = st.st_mtime; do { + /* load file tag */ song->tag = decoder_plugin_tag_dup(plugin, path_fs); if (song->tag != NULL) break; + /* fall back to stream tag */ + 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; + + /* now try the stream_tag() method */ + if (is.plugin != NULL) { + song->tag = decoder_plugin_stream_tag(plugin, + &is); + if (song->tag != NULL) + break; + + 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 (song->tag != NULL && tag_is_empty(song->tag)) song->tag = tag_fallback(path_fs, song->tag); |