Corrected a bug when reloading files, where the string views used for the FilePool hash table where pointing towards freed memory.

This commit is contained in:
paulfd 2019-09-16 15:11:15 +02:00
parent 5b17f727d8
commit e028fdced9
3 changed files with 10 additions and 0 deletions

View file

@ -120,4 +120,12 @@ void sfz::FilePool::loadingThread() noexcept
auto fileLoaded = std::make_unique<AudioBuffer<float>>(sndFile.channels(), fileToLoad.numFrames);
fileToLoad.voice->setFileData(readFromFile<float>(sndFile, fileToLoad.numFrames), fileToLoad.ticket);
}
}
void sfz::FilePool::clear()
{
preloadedData.clear();
while(loadingQueue.pop()){
// Pop the queue
}
}

View file

@ -59,6 +59,7 @@ public:
};
std::optional<FileInformation> getFileInformation(std::string_view filename, uint32_t offset) noexcept;
void enqueueLoading(Voice* voice, std::string_view sample, int numFrames, unsigned ticket) noexcept;
void clear();
private:
std::filesystem::path rootDirectory;
struct FileLoadingInformation {

View file

@ -119,6 +119,7 @@ void sfz::Synth::clear()
masterOpcodes.clear();
groupOpcodes.clear();
regions.clear();
filePool.clear();
}
void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members)