Added a signal that the filepool should empty the queue
This commit is contained in:
parent
ffda6626e2
commit
17236412e3
2 changed files with 10 additions and 1 deletions
|
|
@ -112,6 +112,12 @@ void sfz::FilePool::enqueueLoading(Voice* voice, const std::string* sample, int
|
||||||
void sfz::FilePool::loadingThread() noexcept
|
void sfz::FilePool::loadingThread() noexcept
|
||||||
{
|
{
|
||||||
while (!quitThread) {
|
while (!quitThread) {
|
||||||
|
if (emptyQueue) {
|
||||||
|
while(loadingQueue.pop()) {}
|
||||||
|
emptyQueue = false;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
FileLoadingInformation fileToLoad {};
|
FileLoadingInformation fileToLoad {};
|
||||||
if (!loadingQueue.wait_dequeue_timed(fileToLoad, 200ms)) {
|
if (!loadingQueue.wait_dequeue_timed(fileToLoad, 200ms)) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
|
|
@ -113,6 +113,8 @@ public:
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
void clear();
|
void clear();
|
||||||
|
void emptyFileLoadingQueue() noexcept { emptyQueue = true; }
|
||||||
|
bool shouldEmptyQueue() const noexcept { return emptyQueue; }
|
||||||
private:
|
private:
|
||||||
fs::path rootDirectory;
|
fs::path rootDirectory;
|
||||||
struct FileLoadingInformation {
|
struct FileLoadingInformation {
|
||||||
|
|
@ -126,6 +128,7 @@ private:
|
||||||
void loadingThread() noexcept;
|
void loadingThread() noexcept;
|
||||||
void garbageThread() noexcept;
|
void garbageThread() noexcept;
|
||||||
bool quitThread { false };
|
bool quitThread { false };
|
||||||
|
bool emptyQueue { false };
|
||||||
std::mutex fileHandleMutex;
|
std::mutex fileHandleMutex;
|
||||||
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
std::vector<std::shared_ptr<AudioBuffer<float>>> fileHandles;
|
||||||
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
absl::flat_hash_map<absl::string_view, std::shared_ptr<AudioBuffer<float>>> preloadedData;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue