Added back the method to empty the file loading queue
This commit is contained in:
parent
91e4678c4b
commit
030e0c16ee
4 changed files with 22 additions and 7 deletions
|
|
@ -187,8 +187,17 @@ void sfz::FilePool::loadingThread() noexcept
|
|||
FilePromisePtr promise;
|
||||
while (!quitThread) {
|
||||
promisesToClean.clear();
|
||||
|
||||
if (emptyQueue) {
|
||||
while(promiseQueue.pop()) {
|
||||
|
||||
}
|
||||
emptyQueue = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!promiseQueue.try_dequeue(promise)) {
|
||||
std::this_thread::sleep_for(0.1ms);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
@ -208,6 +217,7 @@ void sfz::FilePool::loadingThread() noexcept
|
|||
|
||||
void sfz::FilePool::clear()
|
||||
{
|
||||
emptyFileLoadingQueue();
|
||||
preloadedFiles.clear();
|
||||
temporaryFilePromises.clear();
|
||||
promisesToClean.clear();
|
||||
|
|
@ -256,3 +266,10 @@ uint32_t sfz::FilePool::getPreloadSize() const noexcept
|
|||
{
|
||||
return preloadSize;
|
||||
}
|
||||
|
||||
void sfz::FilePool::emptyFileLoadingQueue() noexcept
|
||||
{
|
||||
emptyQueue = true;
|
||||
while (emptyQueue)
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -136,6 +136,7 @@ public:
|
|||
uint32_t getPreloadSize() const noexcept;
|
||||
void setOversamplingFactor(Oversampling factor) noexcept;
|
||||
Oversampling getOversamplingFactor() const noexcept;
|
||||
void emptyFileLoadingQueue() noexcept;
|
||||
private:
|
||||
fs::path rootDirectory;
|
||||
void loadingThread() noexcept;
|
||||
|
|
|
|||
|
|
@ -49,8 +49,8 @@ namespace sfz {
|
|||
*
|
||||
*/
|
||||
struct Region {
|
||||
Region(const MidiState& midiState, Oversampling factor = config::defaultOversamplingFactor)
|
||||
: midiState(midiState), oversamplingFactor(factor)
|
||||
Region(const MidiState& midiState)
|
||||
: midiState(midiState)
|
||||
{
|
||||
ccSwitched.set();
|
||||
}
|
||||
|
|
@ -327,8 +327,6 @@ private:
|
|||
int activeNotesInRange { -1 };
|
||||
int sequenceCounter { 0 };
|
||||
|
||||
Oversampling oversamplingFactor { config::defaultOversamplingFactor };
|
||||
|
||||
std::uniform_real_distribution<float> volumeDistribution { -sfz::Default::ampRandom, sfz::Default::ampRandom };
|
||||
std::uniform_real_distribution<float> delayDistribution { 0, sfz::Default::delayRandom };
|
||||
std::uniform_int_distribution<uint32_t> offsetDistribution { 0, sfz::Default::offsetRandom };
|
||||
|
|
|
|||
|
|
@ -316,9 +316,7 @@ int sfz::Synth::getNumActiveVoices() const noexcept
|
|||
|
||||
void sfz::Synth::garbageCollect() noexcept
|
||||
{
|
||||
for (auto& voice : voices) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
||||
|
|
@ -550,6 +548,7 @@ void sfz::Synth::setOversamplingFactor(sfz::Oversampling factor) noexcept
|
|||
for (auto& voice: voices)
|
||||
voice->reset();
|
||||
|
||||
resources.filePool.emptyFileLoadingQueue();
|
||||
resources.filePool.setOversamplingFactor(factor);
|
||||
oversamplingFactor = factor;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue