Commit fef6b9df authored by Shen-Ta Hsieh's avatar Shen-Ta Hsieh Committed by Max Kellermann

flac: Try `InputStream` interface if flac failed to read through a `wchar_t` path

parent d52eac66
ver 0.23.14 (not yet released) ver 0.23.14 (not yet released)
* decoder * decoder
- flac: fix scanning files with non-ASCII names on Windows
- mad: fix calculation of LAME peak values - mad: fix calculation of LAME peak values
* mixer * mixer
- wasapi: fix problem setting volume - wasapi: fix problem setting volume
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "lib/xiph/FlacMetadataChain.hxx" #include "lib/xiph/FlacMetadataChain.hxx"
#include "OggCodec.hxx" #include "OggCodec.hxx"
#include "input/InputStream.hxx" #include "input/InputStream.hxx"
#include "input/LocalOpen.hxx"
#include "fs/Path.hxx" #include "fs/Path.hxx"
#include "fs/NarrowPath.hxx" #include "fs/NarrowPath.hxx"
#include "Log.hxx" #include "Log.hxx"
...@@ -71,16 +72,32 @@ flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame, ...@@ -71,16 +72,32 @@ flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame,
} }
static bool static bool
flac_scan_file(Path path_fs, TagHandler &handler) noexcept flac_scan_file(Path path_fs, TagHandler &handler) noexcept {
{
FlacMetadataChain chain; FlacMetadataChain chain;
if (!chain.Read(NarrowPath(path_fs))) { const bool succeed = [&chain, &path_fs]() noexcept {
// read by NarrowPath
if (chain.Read(NarrowPath(path_fs))) {
return true;
}
if (std::is_same_v<Path::value_type, char> ||
chain.GetStatus() != FLAC__METADATA_CHAIN_STATUS_ERROR_OPENING_FILE) {
return false;
}
// read by InputStream
Mutex mutex;
auto is = OpenLocalInputStream(path_fs, mutex);
if (is && chain.Read(*is)) {
return true;
}
return false;
}();
if (!succeed) {
FmtDebug(flac_domain, FmtDebug(flac_domain,
"Failed to read FLAC tags: {}", "Failed to read FLAC tags: {}",
chain.GetStatusString()); chain.GetStatusString());
return false; return false;
} }
chain.Scan(handler); chain.Scan(handler);
return true; return true;
} }
......
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