summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-26 13:20:30 +0100
committerMax Kellermann <max@duempel.org>2016-02-26 14:03:16 +0100
commitc4537fe6f68aafcd71280e96cbb609b2d535661c (patch)
tree21872d0fe1700ff2b42abf6efb38133540ad88bc
parent677334f5a92f54cba801134dfb7865398ad4db04 (diff)
TagArchive: add TagBuilder overload with ScanGenericTags() fallback
Load APE/ID3 tags from archives.
-rw-r--r--src/SongUpdate.cxx4
-rw-r--r--src/TagArchive.cxx15
-rw-r--r--src/TagArchive.hxx12
3 files changed, 28 insertions, 3 deletions
diff --git a/src/SongUpdate.cxx b/src/SongUpdate.cxx
index 412630d97..a18209048 100644
--- a/src/SongUpdate.cxx
+++ b/src/SongUpdate.cxx
@@ -31,8 +31,6 @@
#include "decoder/DecoderList.hxx"
#include "tag/Tag.hxx"
#include "tag/TagBuilder.hxx"
-#include "tag/TagHandler.hxx"
-#include "tag/Generic.hxx"
#include "TagFile.hxx"
#include "TagStream.hxx"
@@ -127,7 +125,7 @@ Song::UpdateFileInArchive(const Storage &storage)
return false;
TagBuilder tag_builder;
- if (!tag_archive_scan(path_fs, full_tag_handler, &tag_builder))
+ if (!tag_archive_scan(path_fs, tag_builder))
return false;
tag_builder.Commit(tag);
diff --git a/src/TagArchive.cxx b/src/TagArchive.cxx
index 1da2d72f2..20a9c7a2e 100644
--- a/src/TagArchive.cxx
+++ b/src/TagArchive.cxx
@@ -20,6 +20,9 @@
#include "config.h"
#include "TagArchive.hxx"
#include "TagStream.hxx"
+#include "tag/Generic.hxx"
+#include "tag/TagHandler.hxx"
+#include "tag/TagBuilder.hxx"
#include "fs/Path.hxx"
#include "util/Error.hxx"
#include "input/InputStream.hxx"
@@ -42,3 +45,15 @@ tag_archive_scan(Path path, const TagHandler &handler, void *handler_ctx)
return tag_stream_scan(*is, handler, handler_ctx);
}
+
+bool
+tag_archive_scan(Path path, TagBuilder &builder)
+{
+ assert(!path.IsNull());
+
+ Mutex mutex;
+ Cond cond;
+ InputStreamPtr is(OpenArchiveInputStream(path, mutex, cond,
+ IgnoreError()));
+ return is && tag_stream_scan(*is, builder);
+}
diff --git a/src/TagArchive.hxx b/src/TagArchive.hxx
index f93192f59..3c32341ad 100644
--- a/src/TagArchive.hxx
+++ b/src/TagArchive.hxx
@@ -24,6 +24,7 @@
class Path;
struct TagHandler;
+class TagBuilder;
/**
* Scan the tags of a song file inside an archive. Invokes matching
@@ -36,4 +37,15 @@ struct TagHandler;
bool
tag_archive_scan(Path path, const TagHandler &handler, void *handler_ctx);
+/**
+ * Scan the tags of a song file inside an archive. Invokes matching
+ * decoder plugins, and falls back to generic scanners (APE and ID3)
+ * if no tags were found (but the file was recognized).
+ *
+ * @return true if the file was recognized (even if no metadata was
+ * found)
+ */
+bool
+tag_archive_scan(Path path, TagBuilder &builder);
+
#endif