flac: Try `InputStream` interface if flac failed to read through a `wchar_t` path
This commit is contained in:
parent
d52eac66db
commit
fef6b9df80
1
NEWS
1
NEWS
|
@ -1,5 +1,6 @@
|
|||
ver 0.23.14 (not yet released)
|
||||
* decoder
|
||||
- flac: fix scanning files with non-ASCII names on Windows
|
||||
- mad: fix calculation of LAME peak values
|
||||
* mixer
|
||||
- wasapi: fix problem setting volume
|
||||
|
|
|
@ -24,6 +24,7 @@
|
|||
#include "lib/xiph/FlacMetadataChain.hxx"
|
||||
#include "OggCodec.hxx"
|
||||
#include "input/InputStream.hxx"
|
||||
#include "input/LocalOpen.hxx"
|
||||
#include "fs/Path.hxx"
|
||||
#include "fs/NarrowPath.hxx"
|
||||
#include "Log.hxx"
|
||||
|
@ -71,16 +72,32 @@ flac_write_cb(const FLAC__StreamDecoder *dec, const FLAC__Frame *frame,
|
|||
}
|
||||
|
||||
static bool
|
||||
flac_scan_file(Path path_fs, TagHandler &handler) noexcept
|
||||
{
|
||||
flac_scan_file(Path path_fs, TagHandler &handler) noexcept {
|
||||
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,
|
||||
"Failed to read FLAC tags: {}",
|
||||
chain.GetStatusString());
|
||||
return false;
|
||||
}
|
||||
|
||||
chain.Scan(handler);
|
||||
return true;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue