Skip to content

Commit

Permalink
Improved check for garbage collection
Browse files Browse the repository at this point in the history
  • Loading branch information
KKQ-KKQ committed Feb 16, 2024
1 parent b0b3467 commit d7f1d81
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/sfizz/FilePool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#include <memory>
#include <thread>
#include <system_error>
#include <atomic_queue/defs.h>
#if defined(_WIN32)
#include <windows.h>
#else
Expand Down Expand Up @@ -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
Expand Down
3 changes: 2 additions & 1 deletion src/sfizz/FilePool.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d7f1d81

Please sign in to comment.