The file pool did not check the preloaded files properly

This commit is contained in:
paulfd 2019-08-29 11:22:39 +02:00
parent c7184e531c
commit c59bb27286

View file

@ -30,9 +30,11 @@ std::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation(
DBG("Missing logic for " << sndFile.channels() << ", discarding sample " << filename); DBG("Missing logic for " << sndFile.channels() << ", discarding sample " << filename);
return {}; return {};
} }
FileInformation returnedValue; FileInformation returnedValue;
returnedValue.end = static_cast<uint32_t>(sndFile.frames()); returnedValue.end = static_cast<uint32_t>(sndFile.frames());
returnedValue.sampleRate = static_cast<double>(sndFile.samplerate()); returnedValue.sampleRate = static_cast<double>(sndFile.samplerate());
SF_INSTRUMENT instrumentInfo; SF_INSTRUMENT instrumentInfo;
sndFile.command(SFC_GET_INSTRUMENT, &instrumentInfo, sizeof(instrumentInfo)); sndFile.command(SFC_GET_INSTRUMENT, &instrumentInfo, sizeof(instrumentInfo));
if (instrumentInfo.loop_count == 1) { if (instrumentInfo.loop_count == 1) {
@ -46,12 +48,15 @@ std::optional<sfz::FilePool::FileInformation> sfz::FilePool::getFileInformation(
else else
return std::min(returnedValue.end, static_cast<uint32_t>(config::preloadSize)); return std::min(returnedValue.end, static_cast<uint32_t>(config::preloadSize));
}(); }();
returnedValue.preloadedData = std::make_shared<StereoBuffer<float>>(preloadedSize);
preloadedData[filename] = returnedValue.preloadedData; if (preloadedData.contains(filename)) {
readFromFile(sndFile, preloadedSize, *returnedValue.preloadedData); returnedValue.preloadedData = preloadedData[filename];
// char buffer [2048] ; } else {
// sndFile.command(SFC_GET_LOG_INFO, buffer, sizeof(buffer)) ; returnedValue.preloadedData = std::make_shared<StereoBuffer<float>>(preloadedSize);
// DBG(buffer); readFromFile(sndFile, preloadedSize, *returnedValue.preloadedData);
preloadedData[filename] = returnedValue.preloadedData;
}
return returnedValue; return returnedValue;
} }