fix: initialize Carla host in main.c and add terminal error checks

Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-02 22:23:41 +00:00
parent 02f741a01d
commit 426e36087b
2 changed files with 26 additions and 14 deletions

5
main.c
View File

@@ -8,6 +8,7 @@
#include "cli.h" #include "cli.h"
#include "gui.h" #include "gui.h"
#include "dispatcher.h" #include "dispatcher.h"
#include "carla.h"
static Engine engine; static Engine engine;
static volatile int keep_running = 1; static volatile int keep_running = 1;
@@ -87,6 +88,10 @@ int main(int argc, char *argv[]) {
initial_state.clips[i].read_position = 0; initial_state.clips[i].read_position = 0;
} }
// Initialize Carla host in the initial state (before dispatcher starts)
carla_init(&initial_state.carla_host, NULL);
carla_scan_plugins(&initial_state.carla_host);
// Initialize dispatcher // Initialize dispatcher
dispatch = dispatcher_init(&initial_state); dispatch = dispatcher_init(&initial_state);

21
tui.c
View File

@@ -815,15 +815,27 @@ void tui_init(Engine *engine) {
g_dispatch = engine->dispatch; g_dispatch = engine->dispatch;
initscr(); initscr();
if (!has_colors()) {
endwin();
fprintf(stderr, "Terminal does not support colors\n");
exit(1);
}
cbreak(); cbreak();
noecho(); noecho();
keypad(stdscr, TRUE); keypad(stdscr, TRUE);
curs_set(0); curs_set(0);
// Check terminal size
if (LINES < 20 || COLS < 40) {
endwin();
fprintf(stderr, "Terminal too small (need at least 20x40)\n");
exit(1);
}
mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED | BUTTON2_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL); mousemask(BUTTON1_CLICKED | BUTTON3_CLICKED | BUTTON2_CLICKED | BUTTON1_DOUBLE_CLICKED, NULL);
mouseinterval(10); mouseinterval(10);
if (has_colors()) {
start_color(); start_color();
init_pair(COLOR_EMPTY, COLOR_WHITE, COLOR_BLACK); init_pair(COLOR_EMPTY, COLOR_WHITE, COLOR_BLACK);
init_pair(COLOR_RECORDING, COLOR_RED, COLOR_BLACK); init_pair(COLOR_RECORDING, COLOR_RED, COLOR_BLACK);
@@ -831,7 +843,6 @@ void tui_init(Engine *engine) {
init_pair(COLOR_STOPPED, COLOR_BLUE, COLOR_BLACK); init_pair(COLOR_STOPPED, COLOR_BLUE, COLOR_BLACK);
init_pair(COLOR_SELECTED, COLOR_BLACK, COLOR_CYAN); init_pair(COLOR_SELECTED, COLOR_BLACK, COLOR_CYAN);
init_pair(COLOR_HELP, COLOR_CYAN, COLOR_BLACK); init_pair(COLOR_HELP, COLOR_CYAN, COLOR_BLACK);
}
} }
void tui_run(Engine *engine) { void tui_run(Engine *engine) {
@@ -844,11 +855,7 @@ void tui_run(Engine *engine) {
marks[i] = -1; marks[i] = -1;
} }
// Initialize Carla // Carla is now initialized in main.c before dispatcher starts
AppState init_state = dispatcher_get_state();
carla_init(&init_state.carla_host, engine->client);
carla_scan_plugins(&init_state.carla_host);
draw_grid(); draw_grid();
while (1) { while (1) {