Commit ee16fc95 authored by Max Kellermann's avatar Max Kellermann

decoder/{mikmod,fluidsynth,mp4ff}: adapt to tag_handler API

Fixes build regression.
parent 5d73215a
...@@ -219,15 +219,15 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs) ...@@ -219,15 +219,15 @@ fluidsynth_file_decode(struct decoder *decoder, const char *path_fs)
delete_fluid_settings(settings); delete_fluid_settings(settings);
} }
static struct tag * static bool
fluidsynth_tag_dup(const char *file) 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 */ /* to be implemented */
(void)file; (void)file;
return tag; return true;
} }
static const char *const fluidsynth_suffixes[] = { static const char *const fluidsynth_suffixes[] = {
...@@ -239,6 +239,6 @@ const struct decoder_plugin fluidsynth_decoder_plugin = { ...@@ -239,6 +239,6 @@ const struct decoder_plugin fluidsynth_decoder_plugin = {
.name = "fluidsynth", .name = "fluidsynth",
.init = fluidsynth_init, .init = fluidsynth_init,
.file_decode = fluidsynth_file_decode, .file_decode = fluidsynth_file_decode,
.tag_dup = fluidsynth_tag_dup, .scan_file = fluidsynth_scan_file,
.suffixes = fluidsynth_suffixes, .suffixes = fluidsynth_suffixes,
}; };
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "config.h" #include "config.h"
#include "decoder_api.h" #include "decoder_api.h"
#include "mpd_error.h" #include "mpd_error.h"
#include "tag_handler.h"
#include <glib.h> #include <glib.h>
#include <mikmod.h> #include <mikmod.h>
...@@ -177,8 +178,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs) ...@@ -177,8 +178,9 @@ mikmod_decoder_file_decode(struct decoder *decoder, const char *path_fs)
Player_Free(handle); Player_Free(handle);
} }
static struct tag * static bool
mikmod_decoder_tag_dup(const char *path_fs) mikmod_decoder_scan_file(const char *path_fs,
const struct tag_handler *handler, void *handler_ctx)
{ {
char *path2 = g_strdup(path_fs); char *path2 = g_strdup(path_fs);
MODULE *handle = Player_Load(path2, 128, 0); MODULE *handle = Player_Load(path2, 128, 0);
...@@ -186,25 +188,22 @@ mikmod_decoder_tag_dup(const char *path_fs) ...@@ -186,25 +188,22 @@ mikmod_decoder_tag_dup(const char *path_fs)
if (handle == NULL) { if (handle == NULL) {
g_free(path2); g_free(path2);
g_debug("Failed to open file: %s", path_fs); g_debug("Failed to open file: %s", path_fs);
return NULL; return false;
} }
Player_Free(handle); Player_Free(handle);
struct tag *tag = tag_new();
tag->time = 0;
char *title = Player_LoadTitle(path2); char *title = Player_LoadTitle(path2);
g_free(path2); g_free(path2);
if (title != NULL) { if (title != NULL) {
tag_add_item(tag, TAG_TITLE, title); tag_handler_invoke_tag(handler, handler_ctx,
TAG_TITLE, title);
free(title); free(title);
} }
return tag; return true;
} }
static const char *const mikmod_decoder_suffixes[] = { static const char *const mikmod_decoder_suffixes[] = {
...@@ -231,6 +230,6 @@ const struct decoder_plugin mikmod_decoder_plugin = { ...@@ -231,6 +230,6 @@ const struct decoder_plugin mikmod_decoder_plugin = {
.init = mikmod_decoder_init, .init = mikmod_decoder_init,
.finish = mikmod_decoder_finish, .finish = mikmod_decoder_finish,
.file_decode = mikmod_decoder_file_decode, .file_decode = mikmod_decoder_file_decode,
.tag_dup = mikmod_decoder_tag_dup, .scan_file = mikmod_decoder_scan_file,
.suffixes = mikmod_decoder_suffixes, .suffixes = mikmod_decoder_suffixes,
}; };
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "decoder_api.h" #include "decoder_api.h"
#include "audio_check.h" #include "audio_check.h"
#include "tag_table.h" #include "tag_table.h"
#include "tag_handler.h"
#include <glib.h> #include <glib.h>
...@@ -377,8 +378,9 @@ mp4ff_tag_name_parse(const char *name) ...@@ -377,8 +378,9 @@ mp4ff_tag_name_parse(const char *name)
return type; return type;
} }
static struct tag * static bool
mp4_stream_tag(struct input_stream *is) mp4ff_scan_stream(struct input_stream *is,
const struct tag_handler *handler, void *handler_ctx)
{ {
struct mp4ff_input_stream mis; struct mp4ff_input_stream mis;
int32_t track; int32_t track;
...@@ -388,23 +390,23 @@ mp4_stream_tag(struct input_stream *is) ...@@ -388,23 +390,23 @@ mp4_stream_tag(struct input_stream *is)
mp4ff_t *mp4fh = mp4ff_input_stream_open(&mis, NULL, is); mp4ff_t *mp4fh = mp4ff_input_stream_open(&mis, NULL, is);
if (mp4fh == NULL) if (mp4fh == NULL)
return NULL; return false;
track = mp4_get_aac_track(mp4fh, NULL, NULL, NULL); track = mp4_get_aac_track(mp4fh, NULL, NULL, NULL);
if (track < 0) { if (track < 0) {
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
return NULL; return false;
} }
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track); file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
scale = mp4ff_time_scale(mp4fh, track); scale = mp4ff_time_scale(mp4fh, track);
if (scale < 0) { if (scale < 0) {
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
return NULL; return false;
} }
struct tag *tag = tag_new(); tag_handler_invoke_duration(handler, handler_ctx,
tag->time = ((float)file_time) / scale + 0.5; ((float)file_time) / scale + 0.5);
for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) { for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) {
char *item; char *item;
...@@ -414,7 +416,8 @@ mp4_stream_tag(struct input_stream *is) ...@@ -414,7 +416,8 @@ mp4_stream_tag(struct input_stream *is)
enum tag_type type = mp4ff_tag_name_parse(item); enum tag_type type = mp4ff_tag_name_parse(item);
if (type != TAG_NUM_OF_ITEM_TYPES) 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(item);
free(value); free(value);
...@@ -422,7 +425,7 @@ mp4_stream_tag(struct input_stream *is) ...@@ -422,7 +425,7 @@ mp4_stream_tag(struct input_stream *is)
mp4ff_close(mp4fh); mp4ff_close(mp4fh);
return tag; return true;
} }
static const char *const mp4_suffixes[] = { static const char *const mp4_suffixes[] = {
...@@ -437,7 +440,7 @@ static const char *const mp4_mime_types[] = { "audio/mp4", "audio/m4a", NULL }; ...@@ -437,7 +440,7 @@ static const char *const mp4_mime_types[] = { "audio/mp4", "audio/m4a", NULL };
const struct decoder_plugin mp4ff_decoder_plugin = { const struct decoder_plugin mp4ff_decoder_plugin = {
.name = "mp4ff", .name = "mp4ff",
.stream_decode = mp4_decode, .stream_decode = mp4_decode,
.stream_tag = mp4_stream_tag, .scan_stream = mp4ff_scan_stream,
.suffixes = mp4_suffixes, .suffixes = mp4_suffixes,
.mime_types = mp4_mime_types, .mime_types = mp4_mime_types,
}; };
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment