From f8f13f464ca71c4f9158da5f84a81a81d4c6e08d Mon Sep 17 00:00:00 2001 From: KIRA Ryouta Date: Wed, 14 Feb 2024 16:16:21 +0900 Subject: [PATCH] Fixed status check order in garbage collection process --- src/sfizz/FilePool.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/sfizz/FilePool.cpp b/src/sfizz/FilePool.cpp index a37d22b6..42e1f8cc 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -678,12 +678,15 @@ void sfz::FilePool::triggerGarbageCollection() noexcept sfz::FileData& data = it->second; + if (data.readerCount != 0) + return false; + auto status = data.status.load(); if (data.availableFrames == 0) { return status == FileData::Status::Preloaded || status == FileData::Status::FullLoaded; } - switch (status) { + switch(status) { case FileData::Status::Invalid: case FileData::Status::Streaming: return false; @@ -691,9 +694,6 @@ void sfz::FilePool::triggerGarbageCollection() noexcept break; } - if (data.readerCount != 0) - return false; - const auto secondsIdle = std::chrono::duration_cast(now - data.lastViewerLeftAt).count(); if (secondsIdle < config::fileClearingPeriod) return false;