Handle wide chars on windows

This commit is contained in:
Paul Ferrand 2020-01-04 16:32:18 +01:00
parent a29f07a27f
commit 5a21c52164

View file

@ -108,7 +108,7 @@ absl::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation
if (!fs::exists(file)) if (!fs::exists(file))
return {}; return {};
SndfileHandle sndFile(file.c_str()); SndfileHandle sndFile(file.string().c_str());
if (sndFile.channels() != 1 && sndFile.channels() != 2) { if (sndFile.channels() != 1 && sndFile.channels() != 2) {
DBG("Missing logic for " << sndFile.channels() << " channels, discarding sample " << filename); DBG("Missing logic for " << sndFile.channels() << " channels, discarding sample " << filename);
return {}; return {};
@ -135,7 +135,7 @@ bool sfz::FilePool::preloadFile(const std::string& filename, uint32_t maxOffset)
if (!fs::exists(file)) if (!fs::exists(file))
return false; return false;
SndfileHandle sndFile(file.c_str()); SndfileHandle sndFile(file.string().c_str());
if (sndFile.channels() != 1 && sndFile.channels() != 2) if (sndFile.channels() != 1 && sndFile.channels() != 2)
return false; return false;
@ -198,7 +198,7 @@ void sfz::FilePool::setPreloadSize(uint32_t preloadSize) noexcept
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(oversamplingFactor); const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(oversamplingFactor);
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0; const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
fs::path file { rootDirectory / std::string(preloadedFile.first) }; fs::path file { rootDirectory / std::string(preloadedFile.first) };
SndfileHandle sndFile(file.c_str()); SndfileHandle sndFile(file.string().c_str());
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, oversamplingFactor); preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, oversamplingFactor);
} }
this->preloadSize = preloadSize; this->preloadSize = preloadSize;
@ -248,7 +248,7 @@ void sfz::FilePool::loadingThread() noexcept
[[maybe_unused]] const auto waitDurationMillis = std::chrono::duration<double,std::milli>(waitDuration).count(); [[maybe_unused]] const auto waitDurationMillis = std::chrono::duration<double,std::milli>(waitDuration).count();
fs::path file { rootDirectory / std::string(promise->filename) }; fs::path file { rootDirectory / std::string(promise->filename) };
SndfileHandle sndFile(file.c_str()); SndfileHandle sndFile(file.string().c_str());
if (sndFile.error() != 0) { if (sndFile.error() != 0) {
DBG("[sfizz] libsndfile errored for " << promise->filename << " with message " << sndFile.strError()); DBG("[sfizz] libsndfile errored for " << promise->filename << " with message " << sndFile.strError());
continue; continue;
@ -328,7 +328,7 @@ void sfz::FilePool::setOversamplingFactor(sfz::Oversampling factor) noexcept
const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(this->oversamplingFactor); const auto numFrames = preloadedFile.second.preloadedData->getNumFrames() / static_cast<int>(this->oversamplingFactor);
const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0; const uint32_t maxOffset = numFrames > this->preloadSize ? numFrames - this->preloadSize : 0;
fs::path file { rootDirectory / std::string(preloadedFile.first) }; fs::path file { rootDirectory / std::string(preloadedFile.first) };
SndfileHandle sndFile(file.c_str()); SndfileHandle sndFile(file.string().c_str());
preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, factor); preloadedFile.second.preloadedData = readFromFile<float>(sndFile, preloadSize + maxOffset, factor);
preloadedFile.second.sampleRate *= samplerateChange; preloadedFile.second.sampleRate *= samplerateChange;
} }