aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/song_update.c33
-rw-r--r--src/tag_ape.c12
-rw-r--r--src/tag_ape.h9
-rw-r--r--src/tag_id3.c28
-rw-r--r--src/tag_id3.h8
5 files changed, 6 insertions, 84 deletions
diff --git a/src/song_update.c b/src/song_update.c
index d6f643dd9..e58896ed2 100644
--- a/src/song_update.c
+++ b/src/song_update.c
@@ -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;
diff --git a/src/tag_ape.c b/src/tag_ape.c
index 068a9aa6d..31c177aa7 100644
--- a/src/tag_ape.c
+++ b/src/tag_ape.c
@@ -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;
-}
diff --git a/src/tag_ape.h b/src/tag_ape.h
index 2e8bfb3c5..9b5856115 100644
--- a/src/tag_ape.h
+++ b/src/tag_ape.h
@@ -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
diff --git a/src/tag_id3.c b/src/tag_id3.c
index 058701524..394068d3f 100644
--- a/src/tag_id3.c
+++ b/src/tag_id3.c
@@ -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;
-}
diff --git a/src/tag_id3.h b/src/tag_id3.h
index fb5c7c653..b99b4480f 100644
--- a/src/tag_id3.h
+++ b/src/tag_id3.h
@@ -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