fix: use atomic operations for thread-safe clip state access
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
8
tui.c
8
tui.c
@@ -4,6 +4,7 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <signal.h>
|
||||
#include <stdatomic.h>
|
||||
|
||||
#define GRID_ROWS 8
|
||||
#define GRID_COLS 8
|
||||
@@ -215,7 +216,7 @@ static void draw_cell(int row, int col, bool selected) {
|
||||
int y = row * CELL_HEIGHT + 1;
|
||||
int x = col * CELL_WIDTH + 1;
|
||||
|
||||
int color = state_to_color(clip->state);
|
||||
int color = state_to_color((ClipState)atomic_load(&clip->state));
|
||||
if (selected) {
|
||||
color = COLOR_SELECTED;
|
||||
} else if (current_mode == MODE_VISUAL && is_in_visual_selection(row, col)) {
|
||||
@@ -237,7 +238,7 @@ static void draw_cell(int row, int col, bool selected) {
|
||||
|
||||
// Draw state indicator
|
||||
char state_char;
|
||||
switch (clip->state) {
|
||||
switch ((ClipState)atomic_load(&clip->state)) {
|
||||
case CLIP_EMPTY: state_char = ' '; break;
|
||||
case CLIP_RECORDING: state_char = 'R'; break;
|
||||
case CLIP_LOOPING: state_char = 'L'; break;
|
||||
@@ -272,7 +273,8 @@ static void draw_grid(void) {
|
||||
|
||||
mvprintw(GRID_ROWS * CELL_HEIGHT + 1, 0,
|
||||
"Selected: Clip %d | State: %s | Buffer: %zu samples",
|
||||
clip_idx, clip_state_to_string(clip->state), clip->buffer_size);
|
||||
clip_idx, clip_state_to_string((ClipState)atomic_load(&clip->state)),
|
||||
(size_t)atomic_load(&clip->buffer_size));
|
||||
|
||||
TransportState transport_state = (TransportState)atomic_load(&g_engine->transport->state_atomic);
|
||||
ClockSource clock_source = (ClockSource)atomic_load(&g_engine->transport->clock_source_atomic);
|
||||
|
||||
Reference in New Issue
Block a user