diff --git a/src/sfizz/FilePool.cpp b/src/sfizz/FilePool.cpp index 140beaa0..c474b634 100644 --- a/src/sfizz/FilePool.cpp +++ b/src/sfizz/FilePool.cpp @@ -262,7 +262,7 @@ absl::optional sfz::FilePool::loadFile(const std::string& f } } -sfz::FilePromisePtr sfz::FilePool::getFilePromise(const std::string& filename) +sfz::FilePromisePtr sfz::FilePool::getFilePromise(const std::string& filename) noexcept { if (emptyPromises.empty()) { DBG("[sfizz] No empty promises left to honor the one for " << filename); @@ -286,7 +286,11 @@ sfz::FilePromisePtr sfz::FilePool::getFilePromise(const std::string& filename) DBG("[sfizz] Could not enqueue the promise for " << filename << " (queue capacity " << promiseQueue.capacity() << ")"); return {}; } - workerBarrier.post(); + + std::error_code ec; + workerBarrier.post(ec); + ASSERT(!ec); + emptyPromises.pop_back(); return promise; @@ -323,7 +327,7 @@ void sfz::FilePool::clearingThread() } } -void sfz::FilePool::loadingThread() +void sfz::FilePool::loadingThread() noexcept { FilePromisePtr promise; while (!quitThread) { @@ -336,7 +340,9 @@ void sfz::FilePool::loadingThread() continue; } - workerBarrier.wait(); + std::error_code ec; + workerBarrier.wait(ec); + ASSERT(!ec); if (!promiseQueue.try_pop(promise)) { continue; @@ -444,10 +450,12 @@ uint32_t sfz::FilePool::getPreloadSize() const noexcept return preloadSize; } -void sfz::FilePool::emptyFileLoadingQueues() +void sfz::FilePool::emptyFileLoadingQueues() noexcept { emptyQueue = true; - workerBarrier.post(); + std::error_code ec; + workerBarrier.post(ec); + ASSERT(!ec); while (emptyQueue) std::this_thread::sleep_for(std::chrono::milliseconds(1)); diff --git a/src/sfizz/FilePool.h b/src/sfizz/FilePool.h index 6471c75f..c2600ece 100644 --- a/src/sfizz/FilePool.h +++ b/src/sfizz/FilePool.h @@ -207,7 +207,7 @@ public: * @param filename the file to preload * @return FilePromisePtr a file promise */ - FilePromisePtr getFilePromise(const std::string& filename); + FilePromisePtr getFilePromise(const std::string& filename) noexcept; /** * @brief Change the preloading size. This will trigger a full * reload of all samples, so don't call it on the audio thread. @@ -240,7 +240,7 @@ public: * method on the audio thread as it will spinlock. * */ - void emptyFileLoadingQueues(); + void emptyFileLoadingQueues() noexcept; /** * @brief Wait for the background loading to finish for all promises * in the queue. @@ -249,7 +249,7 @@ public: private: Logger& logger; fs::path rootDirectory; - void loadingThread(); + void loadingThread() noexcept; void clearingThread(); void tryToClearPromises();