fix: use static atomic variable for save/load thread flag

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 11:01:03 +00:00
parent 6fb81aa322
commit 7f0ce410b4

View File

@@ -10,6 +10,10 @@
#include <sys/stat.h>
#include <errno.h>
static atomic_bool save_load_running_atomic = false;
static atomic_bool save_load_running_atomic = false;
// Forward declarations
static void process_queued_triggers(Engine *engine, jack_nframes_t current_frame);
static jack_nframes_t get_next_quantize_frame(Engine *engine, jack_nframes_t current_frame);
@@ -300,7 +304,7 @@ void* save_load_thread_func(void *arg) {
// Create samples directory if it doesn't exist
mkdir("samples", 0755);
while (atomic_load(&engine->save_load_running)) {
while (atomic_load(&save_load_running_atomic)) {
SaveLoadRequest req;
int ret = save_load_queue_pop(&engine->save_load_queue, &req);
@@ -382,7 +386,7 @@ void* save_load_thread_func(void *arg) {
int engine_start_save_load_thread(Engine *engine) {
if (!engine) return -1;
atomic_store(&engine->save_load_running, true);
atomic_store(&save_load_running_atomic, true);
save_load_queue_init(&engine->save_load_queue);
if (pthread_create(&engine->save_load_thread, NULL, save_load_thread_func, engine) != 0) {
@@ -397,7 +401,7 @@ int engine_start_save_load_thread(Engine *engine) {
void engine_stop_save_load_thread(Engine *engine) {
if (!engine) return;
atomic_store(&engine->save_load_running, false);
atomic_store(&save_load_running_atomic, false);
pthread_join(engine->save_load_thread, NULL);
}