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;
|
FilePromisePtr promise;
|
||||||
while (!quitThread) {
|
while (!quitThread) {
|
||||||
promisesToClean.clear();
|
promisesToClean.clear();
|
||||||
|
|
||||||
|
if (emptyQueue) {
|
||||||
|
while(promiseQueue.pop()) {
|
||||||
|
|
||||||
|
}
|
||||||
|
emptyQueue = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!promiseQueue.try_dequeue(promise)) {
|
if (!promiseQueue.try_dequeue(promise)) {
|
||||||
std::this_thread::sleep_for(0.1ms);
|
std::this_thread::sleep_for(1ms);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -208,6 +217,7 @@ void sfz::FilePool::loadingThread() noexcept
|
||||||
|
|
||||||
void sfz::FilePool::clear()
|
void sfz::FilePool::clear()
|
||||||
{
|
{
|
||||||
|
emptyFileLoadingQueue();
|
||||||
preloadedFiles.clear();
|
preloadedFiles.clear();
|
||||||
temporaryFilePromises.clear();
|
temporaryFilePromises.clear();
|
||||||
promisesToClean.clear();
|
promisesToClean.clear();
|
||||||
|
|
@ -256,3 +266,10 @@ uint32_t sfz::FilePool::getPreloadSize() const noexcept
|
||||||
{
|
{
|
||||||
return preloadSize;
|
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;
|
uint32_t getPreloadSize() const noexcept;
|
||||||
void setOversamplingFactor(Oversampling factor) noexcept;
|
void setOversamplingFactor(Oversampling factor) noexcept;
|
||||||
Oversampling getOversamplingFactor() const noexcept;
|
Oversampling getOversamplingFactor() const noexcept;
|
||||||
|
void emptyFileLoadingQueue() noexcept;
|
||||||
private:
|
private:
|
||||||
fs::path rootDirectory;
|
fs::path rootDirectory;
|
||||||
void loadingThread() noexcept;
|
void loadingThread() noexcept;
|
||||||
|
|
|
||||||
|
|
@ -49,8 +49,8 @@ namespace sfz {
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct Region {
|
struct Region {
|
||||||
Region(const MidiState& midiState, Oversampling factor = config::defaultOversamplingFactor)
|
Region(const MidiState& midiState)
|
||||||
: midiState(midiState), oversamplingFactor(factor)
|
: midiState(midiState)
|
||||||
{
|
{
|
||||||
ccSwitched.set();
|
ccSwitched.set();
|
||||||
}
|
}
|
||||||
|
|
@ -327,8 +327,6 @@ private:
|
||||||
int activeNotesInRange { -1 };
|
int activeNotesInRange { -1 };
|
||||||
int sequenceCounter { 0 };
|
int sequenceCounter { 0 };
|
||||||
|
|
||||||
Oversampling oversamplingFactor { config::defaultOversamplingFactor };
|
|
||||||
|
|
||||||
std::uniform_real_distribution<float> volumeDistribution { -sfz::Default::ampRandom, sfz::Default::ampRandom };
|
std::uniform_real_distribution<float> volumeDistribution { -sfz::Default::ampRandom, sfz::Default::ampRandom };
|
||||||
std::uniform_real_distribution<float> delayDistribution { 0, sfz::Default::delayRandom };
|
std::uniform_real_distribution<float> delayDistribution { 0, sfz::Default::delayRandom };
|
||||||
std::uniform_int_distribution<uint32_t> offsetDistribution { 0, sfz::Default::offsetRandom };
|
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
|
void sfz::Synth::garbageCollect() noexcept
|
||||||
{
|
{
|
||||||
for (auto& voice : voices) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
void sfz::Synth::setSamplesPerBlock(int samplesPerBlock) noexcept
|
||||||
|
|
@ -550,6 +548,7 @@ void sfz::Synth::setOversamplingFactor(sfz::Oversampling factor) noexcept
|
||||||
for (auto& voice: voices)
|
for (auto& voice: voices)
|
||||||
voice->reset();
|
voice->reset();
|
||||||
|
|
||||||
|
resources.filePool.emptyFileLoadingQueue();
|
||||||
resources.filePool.setOversamplingFactor(factor);
|
resources.filePool.setOversamplingFactor(factor);
|
||||||
oversamplingFactor = factor;
|
oversamplingFactor = factor;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue