Commit 4a23a4bf authored by Max Kellermann's avatar Max Kellermann

tag_{ape,id3}: remove the _load() functions

Use _scan() instead, to have more control.
parent ac3ad452
......@@ -66,33 +66,12 @@ song_file_load(const char *path, struct directory *parent)
/**
* Attempts to load APE or ID3 tags from the specified file.
*/
static struct tag *
tag_load_fallback(const char *path)
static bool
tag_scan_fallback(const char *path,
const struct tag_handler *handler, void *handler_ctx)
{
struct tag *tag = tag_ape_load(path);
if (tag == NULL)
tag = tag_id3_load(path);
return tag;
}
/**
* The decoder plugin failed to load any tags: fall back to the APE or
* ID3 tag loader.
*/
static struct tag *
tag_fallback(const char *path, struct tag *tag)
{
struct tag *fallback = tag_load_fallback(path);
if (fallback != NULL) {
/* tag was successfully loaded: copy the song
duration, and destroy the old (empty) tag */
fallback->time = tag->time;
tag_free(tag);
return fallback;
} else
/* no APE/ID3 tag found: return the empty tag */
return tag;
return tag_ape_scan2(path, handler, handler_ctx) ||
tag_id3_scan(path, handler, handler_ctx);
}
bool
......@@ -183,7 +162,7 @@ song_file_update(struct song *song)
}
if (song->tag != NULL && tag_is_empty(song->tag))
song->tag = tag_fallback(path_fs, song->tag);
tag_scan_fallback(path_fs, &add_tag_handler, song->tag);
g_free(path_fs);
return song->tag != NULL;
......
......@@ -101,15 +101,3 @@ tag_ape_scan2(const char *path_fs,
return tag_ape_scan(path_fs, tag_ape_callback, &ctx);
}
struct tag *
tag_ape_load(const char *path_fs)
{
struct tag *tag = tag_new();
if (!tag_ape_scan2(path_fs, &add_tag_handler, tag)) {
tag_free(tag);
tag = NULL;
}
return tag;
}
......@@ -33,13 +33,4 @@ bool
tag_ape_scan2(const char *path_fs,
const struct tag_handler *handler, void *handler_ctx);
/**
* Loads the APE tag from a file.
*
* @param path_fs the path of the file in filesystem encoding
* @return a tag object, or NULL if the file has no APE tag
*/
struct tag *
tag_ape_load(const char *path_fs);
#endif
......@@ -570,31 +570,3 @@ tag_id3_scan(const char *path_fs,
id3_tag_delete(tag);
return true;
}
struct tag *tag_id3_load(const char *file)
{
struct tag *ret;
struct id3_tag *tag;
FILE *stream;
stream = fopen(file, "rb");
if (!stream) {
g_debug("tag_id3_load: Failed to open file: '%s', %s",
file, strerror(errno));
return NULL;
}
tag = tag_id3_find_from_beginning(stream);
if (tag == NULL)
tag = tag_id3_riff_aiff_load(stream);
if (!tag)
tag = tag_id3_find_from_end(stream);
fclose(stream);
if (!tag)
return NULL;
ret = tag_id3_import(tag);
id3_tag_delete(tag);
return ret;
}
......@@ -36,8 +36,6 @@ tag_id3_scan(const char *path_fs,
struct id3_tag;
struct tag *tag_id3_import(struct id3_tag *);
struct tag *tag_id3_load(const char *file);
#else
#include <glib.h>
......@@ -50,12 +48,6 @@ tag_id3_scan(G_GNUC_UNUSED const char *path_fs,
return false;
}
static inline struct tag *
tag_id3_load(G_GNUC_UNUSED const char *file)
{
return NULL;
}
#endif
#endif
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