From cc505774444ecd3dc434d130ee64ba7654c3146a Mon Sep 17 00:00:00 2001 From: Loic Coenen Date: Tue, 12 May 2026 18:01:57 +0000 Subject: [PATCH] fix: cast atomic pointer loads/stores and remove duplicate free in writer_thread Co-authored-by: aider (deepseek/deepseek-reasoner) --- src/looper.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/looper.c b/src/looper.c index ec23be1..6f7b8d8 100644 --- a/src/looper.c +++ b/src/looper.c @@ -128,7 +128,7 @@ int process_callback(jack_nframes_t nframes, void *arg) { } // push loop output into save ring if saving (atomic load) - RingBuf *r = atomic_load_explicit(&channels[c].save_ring, memory_order_acquire); + RingBuf *r = (RingBuf *)atomic_load_explicit(&channels[c].save_ring, memory_order_acquire); if (r != NULL) { if (state == STATE_LOOPING && channels[c].loop_count > 0) { float *outf = (float *)out; @@ -229,7 +229,7 @@ int looper_init(jack_client_t *client) { * ---------------------------------------------------------------- */ static void *writer_thread(void *arg) { struct channel_t *ch = (struct channel_t *)arg; - RingBuf *ring = ch->save_ring; + RingBuf *ring = (RingBuf *)ch->save_ring; if (!ring) return NULL; static const char *path = "save.wav"; @@ -259,8 +259,6 @@ static void *writer_thread(void *arg) { ring_destroy(ring); free(ring); atomic_store_explicit(&ch->save_ring, NULL, memory_order_release); - ring_destroy(ring); - free(ring); return NULL; } @@ -329,7 +327,7 @@ void looper_process_commands(jack_client_t *client) { if (ring) { size_t sz = (size_t)channels[0].loop_count * 2; if (ring_init(ring, sz) == 0) { - atomic_store_explicit(&channels[0].save_ring, ring, memory_order_release); + atomic_store_explicit(&channels[0].save_ring, (_Atomic RingBuf *)ring, memory_order_release); pthread_t th; pthread_create(&th, NULL, writer_thread, &channels[0]); pthread_detach(th);