Merge branch 'hotfix/file-switching'
This commit is contained in:
commit
2e7b3e0cd7
3 changed files with 13 additions and 6 deletions
|
|
@ -145,16 +145,17 @@ void sfz::FilePool::loadingThread() noexcept
|
|||
void sfz::FilePool::garbageThread() noexcept
|
||||
{
|
||||
while (!quitThread) {
|
||||
fileHandleMutex.lock();
|
||||
for (auto handle = fileHandles.begin(); handle < fileHandles.end();) {
|
||||
if (handle->use_count() == 1) {
|
||||
handle->reset();
|
||||
std::lock_guard<std::mutex> guard { fileHandleMutex };
|
||||
std::iter_swap(handle, fileHandles.end() - 1);
|
||||
fileHandles.pop_back();
|
||||
} else {
|
||||
handle++;
|
||||
}
|
||||
}
|
||||
fileHandleMutex.unlock();
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,11 +72,11 @@ private:
|
|||
void loadingThread() noexcept;
|
||||
void garbageThread() noexcept;
|
||||
bool quitThread { false };
|
||||
std::mutex fileHandleMutex;
|
||||
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
||||
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
||||
std::thread fileLoadingThread { &FilePool::loadingThread, this };
|
||||
std::thread garbageCollectionThread { &FilePool::garbageThread, this };
|
||||
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
||||
std::mutex fileHandleMutex;
|
||||
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
||||
LEAK_DETECTOR(FilePool);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,6 +108,14 @@ void sfz::Synth::buildRegion(const std::vector<Opcode>& regionOpcodes)
|
|||
|
||||
void sfz::Synth::clear()
|
||||
{
|
||||
for (auto &voice: voices)
|
||||
voice->reset();
|
||||
for (auto& list: noteActivationLists)
|
||||
list.clear();
|
||||
for (auto& list: ccActivationLists)
|
||||
list.clear();
|
||||
regions.clear();
|
||||
filePool.clear();
|
||||
hasGlobal = false;
|
||||
hasControl = false;
|
||||
numGroups = 0;
|
||||
|
|
@ -121,8 +129,6 @@ void sfz::Synth::clear()
|
|||
globalOpcodes.clear();
|
||||
masterOpcodes.clear();
|
||||
groupOpcodes.clear();
|
||||
regions.clear();
|
||||
filePool.clear();
|
||||
}
|
||||
|
||||
void sfz::Synth::handleGlobalOpcodes(const std::vector<Opcode>& members)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue