diff options
Diffstat (limited to '')
-rw-r--r-- | src/decoder/fluidsynth_decoder_plugin.c | 12 | ||||
-rw-r--r-- | src/decoder/mikmod_decoder_plugin.c | 19 | ||||
-rw-r--r-- | src/decoder/mp4ff_decoder_plugin.c | 23 |
3 files changed, 28 insertions, 26 deletions
diff --git a/src/decoder/fluidsynth_decoder_plugin.c b/src/decoder/fluidsynth_decoder_plugin.c index 814a7b554..085f84f14 100644 --- a/src/decoder/fluidsynth_decoder_plugin.c +++ b/src/decoder/fluidsynth_decoder_plugin.c @@ -219,15 +219,15 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) delete_fluid_settings(settings); } -static struct tag * -fluidsynth_tag_dup(const char *file) +static bool +fluidsynth_scan_file(const char *file, + G_GNUC_UNUSED const struct tag_handler *handler, + G_GNUC_UNUSED void *handler_ctx) { - struct tag *tag = tag_new(); - /* to be implemented */ (void)file; - return tag; + return true; } static const char *const fluidsynth_suffixes[] = { @@ -239,6 +239,6 @@ const struct decoder_plugin fluidsynth_decoder_plugin = { .name = "fluidsynth", .init = fluidsynth_init, .file_decode = fluidsynth_file_decode, - .tag_dup = fluidsynth_tag_dup, + .scan_file = fluidsynth_scan_file, .suffixes = fluidsynth_suffixes, }; diff --git a/src/decoder/mikmod_decoder_plugin.c b/src/decoder/mikmod_decoder_plugin.c index 9dd5a79b6..5681a7a57 100644 --- a/src/decoder/mikmod_decoder_plugin.c +++ b/src/decoder/mikmod_decoder_plugin.c @@ -20,6 +20,7 @@ #include "config.h" #include "decoder_api.h" #include "mpd_error.h" +#include "tag_handler.h" #include <glib.h> #include <mikmod.h> @@ -177,8 +178,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs) Player_Free(handle); } -static struct tag * -mikmod_decoder_tag_dup(const char *path_fs) +static bool +mikmod_decoder_scan_file(const char *path_fs, + const struct tag_handler *handler, void *handler_ctx) { char *path2 = g_strdup(path_fs); MODULE *handle = Player_Load(path2, 128, 0); @@ -186,25 +188,22 @@ mikmod_decoder_tag_dup(const char *path_fs) if (handle == NULL) { g_free(path2); g_debug("Failed to open file: %s", path_fs); - return NULL; + return false; } Player_Free(handle); - struct tag *tag = tag_new(); - - tag->time = 0; - char *title = Player_LoadTitle(path2); g_free(path2); if (title != NULL) { - tag_add_item(tag, TAG_TITLE, title); + tag_handler_invoke_tag(handler, handler_ctx, + TAG_TITLE, title); free(title); } - return tag; + return true; } static const char *const mikmod_decoder_suffixes[] = { @@ -231,6 +230,6 @@ const struct decoder_plugin mikmod_decoder_plugin = { .init = mikmod_decoder_init, .finish = mikmod_decoder_finish, .file_decode = mikmod_decoder_file_decode, - .tag_dup = mikmod_decoder_tag_dup, + .scan_file = mikmod_decoder_scan_file, .suffixes = mikmod_decoder_suffixes, }; diff --git a/src/decoder/mp4ff_decoder_plugin.c b/src/decoder/mp4ff_decoder_plugin.c index 6202ece9e..e1e48770a 100644 --- a/src/decoder/mp4ff_decoder_plugin.c +++ b/src/decoder/mp4ff_decoder_plugin.c @@ -21,6 +21,7 @@ #include "decoder_api.h" #include "audio_check.h" #include "tag_table.h" +#include "tag_handler.h" #include <glib.h> @@ -377,8 +378,9 @@ mp4ff_tag_name_parse(const char *name) return type; } -static struct tag * -mp4_stream_tag(struct input_stream *is) +static bool +mp4ff_scan_stream(struct input_stream *is, + const struct tag_handler *handler, void *handler_ctx) { struct mp4ff_input_stream mis; int32_t track; @@ -388,23 +390,23 @@ mp4_stream_tag(struct input_stream *is) mp4ff_t *mp4fh = mp4ff_input_stream_open(&mis, NULL, is); if (mp4fh == NULL) - return NULL; + return false; track = mp4_get_aac_track(mp4fh, NULL, NULL, NULL); if (track < 0) { mp4ff_close(mp4fh); - return NULL; + return false; } file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track); if (scale < 0) { mp4ff_close(mp4fh); - return NULL; + return false; } - struct tag *tag = tag_new(); - tag->time = ((float)file_time) / scale + 0.5; + tag_handler_invoke_duration(handler, handler_ctx, + ((float)file_time) / scale + 0.5); for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) { char *item; @@ -414,7 +416,8 @@ mp4_stream_tag(struct input_stream *is) enum tag_type type = mp4ff_tag_name_parse(item); if (type != TAG_NUM_OF_ITEM_TYPES) - tag_add_item(tag, type, value); + tag_handler_invoke_tag(handler, handler_ctx, + type, value); free(item); free(value); @@ -422,7 +425,7 @@ mp4_stream_tag(struct input_stream *is) mp4ff_close(mp4fh); - return tag; + return true; } static const char *const mp4_suffixes[] = { @@ -437,7 +440,7 @@ static const char *const mp4_mime_types[] = { "audio/mp4", "audio/m4a", NULL }; const struct decoder_plugin mp4ff_decoder_plugin = { .name = "mp4ff", .stream_decode = mp4_decode, - .stream_tag = mp4_stream_tag, + .scan_stream = mp4ff_scan_stream, .suffixes = mp4_suffixes, .mime_types = mp4_mime_types, }; |