Commit b5c206d3 authored by Max Kellermann's avatar Max Kellermann

tag/Generic: use common InputStream for APE and ID3

parent 17ace952
...@@ -22,9 +22,15 @@ ...@@ -22,9 +22,15 @@
#include "TagId3.hxx" #include "TagId3.hxx"
#include "ApeTag.hxx" #include "ApeTag.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "thread/Mutex.hxx"
#include "thread/Cond.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "Log.hxx"
#include "util/Error.hxx" #include "util/Error.hxx"
#include <stdexcept>
/** /**
* Attempts to scan APE or ID3 tags from the specified file. * Attempts to scan APE or ID3 tags from the specified file.
*/ */
...@@ -45,7 +51,19 @@ ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx) ...@@ -45,7 +51,19 @@ ScanGenericTags(InputStream &is, const TagHandler &handler, void *ctx)
*/ */
bool bool
ScanGenericTags(Path path, const TagHandler &handler, void *ctx) ScanGenericTags(Path path, const TagHandler &handler, void *ctx)
{ try {
return tag_ape_scan2(path, handler, ctx) || Mutex mutex;
tag_id3_scan(path, handler, ctx); 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;
} }
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