Improved check for garbage collection

This commit is contained in:
KIRA Ryouta 2024-02-16 11:16:58 +09:00 committed by Paul Ferrand
parent c566631379
commit ffaed1581a
2 changed files with 7 additions and 2 deletions

View file

@ -39,6 +39,7 @@
#include <memory>
#include <thread>
#include <system_error>
#include <atomic_queue/defs.h>
#if defined(_WIN32)
#include <windows.h>
#else
@ -514,7 +515,10 @@ void sfz::FilePool::loadingJob(const QueuedFileData& data) noexcept
}
// wait for garbage collection
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;
}
// Already loading or loaded

View file

@ -76,7 +76,8 @@ struct FileData
}
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);
else
return AudioSpan<const float>(preloadedData);