Improved check for garbage collection
This commit is contained in:
parent
c566631379
commit
ffaed1581a
2 changed files with 7 additions and 2 deletions
|
|
@ -39,6 +39,7 @@
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <system_error>
|
#include <system_error>
|
||||||
|
#include <atomic_queue/defs.h>
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#else
|
#else
|
||||||
|
|
@ -514,7 +515,10 @@ void sfz::FilePool::loadingJob(const QueuedFileData& data) noexcept
|
||||||
}
|
}
|
||||||
// wait for garbage collection
|
// wait for garbage collection
|
||||||
if (currentStatus == FileData::Status::GarbageCollecting) {
|
if (currentStatus == FileData::Status::GarbageCollecting) {
|
||||||
std::this_thread::sleep_for(std::chrono::microseconds(1));
|
atomic_queue::spin_loop_pause();
|
||||||
|
atomic_queue::spin_loop_pause();
|
||||||
|
atomic_queue::spin_loop_pause();
|
||||||
|
atomic_queue::spin_loop_pause();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// Already loading or loaded
|
// Already loading or loaded
|
||||||
|
|
|
||||||
|
|
@ -76,7 +76,8 @@ struct FileData
|
||||||
}
|
}
|
||||||
AudioSpan<const float> getData()
|
AudioSpan<const float> getData()
|
||||||
{
|
{
|
||||||
if (availableFrames > preloadedData.getNumFrames())
|
ASSERT(readerCount > 0);
|
||||||
|
if (status != Status::GarbageCollecting && availableFrames > preloadedData.getNumFrames())
|
||||||
return AudioSpan<const float>(fileData).first(availableFrames);
|
return AudioSpan<const float>(fileData).first(availableFrames);
|
||||||
else
|
else
|
||||||
return AudioSpan<const float>(preloadedData);
|
return AudioSpan<const float>(preloadedData);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue