fix: cast atomic pointer loads/stores and remove duplicate free in writer_thread
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
@@ -128,7 +128,7 @@ int process_callback(jack_nframes_t nframes, void *arg) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// push loop output into save ring if saving (atomic load)
|
// 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 (r != NULL) {
|
||||||
if (state == STATE_LOOPING && channels[c].loop_count > 0) {
|
if (state == STATE_LOOPING && channels[c].loop_count > 0) {
|
||||||
float *outf = (float *)out;
|
float *outf = (float *)out;
|
||||||
@@ -229,7 +229,7 @@ int looper_init(jack_client_t *client) {
|
|||||||
* ---------------------------------------------------------------- */
|
* ---------------------------------------------------------------- */
|
||||||
static void *writer_thread(void *arg) {
|
static void *writer_thread(void *arg) {
|
||||||
struct channel_t *ch = (struct channel_t *)arg;
|
struct channel_t *ch = (struct channel_t *)arg;
|
||||||
RingBuf *ring = ch->save_ring;
|
RingBuf *ring = (RingBuf *)ch->save_ring;
|
||||||
if (!ring) return NULL;
|
if (!ring) return NULL;
|
||||||
|
|
||||||
static const char *path = "save.wav";
|
static const char *path = "save.wav";
|
||||||
@@ -259,8 +259,6 @@ static void *writer_thread(void *arg) {
|
|||||||
ring_destroy(ring);
|
ring_destroy(ring);
|
||||||
free(ring);
|
free(ring);
|
||||||
atomic_store_explicit(&ch->save_ring, NULL, memory_order_release);
|
atomic_store_explicit(&ch->save_ring, NULL, memory_order_release);
|
||||||
ring_destroy(ring);
|
|
||||||
free(ring);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -329,7 +327,7 @@ void looper_process_commands(jack_client_t *client) {
|
|||||||
if (ring) {
|
if (ring) {
|
||||||
size_t sz = (size_t)channels[0].loop_count * 2;
|
size_t sz = (size_t)channels[0].loop_count * 2;
|
||||||
if (ring_init(ring, sz) == 0) {
|
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_t th;
|
||||||
pthread_create(&th, NULL, writer_thread, &channels[0]);
|
pthread_create(&th, NULL, writer_thread, &channels[0]);
|
||||||
pthread_detach(th);
|
pthread_detach(th);
|
||||||
|
|||||||
Reference in New Issue
Block a user