tag/Generic: use common InputStream for APE and ID3
This commit is contained in:
		| @@ -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) | |||||||
|  */ |  */ | ||||||
| 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; | ||||||
| } | } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Max Kellermann
					Max Kellermann