diff options
author | Max Kellermann <max@duempel.org> | 2016-02-23 10:24:10 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2016-02-23 10:27:31 +0100 |
commit | b5c206d3ae35c0362411e5bca680b88b5158c103 (patch) | |
tree | 08eb8a014b74a5c8f9cd0388a480b69266d45ec8 | |
parent | 17ace95268c93188891e85105eb51f0640526d66 (diff) |
tag/Generic: use common InputStream for APE and ID3
-rw-r--r-- | src/tag/Generic.cxx | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/tag/Generic.cxx b/src/tag/Generic.cxx index a731fbe38..39baef45c 100644 --- a/src/tag/Generic.cxx +++ b/src/tag/Generic.cxx @@ -22,9 +22,15 @@ #include "TagId3.hxx" #include "ApeTag.hxx" #include "fs/Path.hxx" +#include "thread/Mutex.hxx" +#include "thread/Cond.hxx" #include "input/InputStream.hxx" +#include "input/LocalOpen.hxx" +#include "Log.hxx" #include "util/Error.hxx" +#include <stdexcept> + /** * Attempts to scan APE or ID3 tags from the specified file. */ @@ -45,7 +51,19 @@ ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx) */ bool ScanGenericTags(Path path, const TagHandler &handler, void *ctx) -{ - return tag_ape_scan2(path, handler, ctx) || - tag_id3_scan(path, handler, ctx); +try { + Mutex mutex; + Cond cond; + + Error error; + auto is = OpenLocalInputStream(path, mutex, cond, error); + if (!is) { + LogError(error); + return false; + } + + return ScanGenericTags(*is, handler, ctx); +} catch (const std::runtime_error &e) { + LogError(e); + return false; } |