refactor: rename looper ports to ch0in/ch0out and move connection logic to client
This commit is contained in:
committed by
Loic Coenen (aider)
parent
316320c294
commit
20176517a4
@@ -322,15 +322,6 @@ bool carla_get_connected_port(int channel, bool is_input, char *buf, size_t bufs
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// Also look for direct connections to looper:input / looper:output (channel 0)
|
||||
const char *direct_needle = is_input ? "looper:input" : "looper:output";
|
||||
for (int i = 0; i < conn_count; i++) {
|
||||
if (strcmp(connections[i].looper_port, direct_needle) == 0) {
|
||||
strncpy(buf, connections[i].plugin_port, bufsize - 1);
|
||||
buf[bufsize - 1] = '\0';
|
||||
return true;
|
||||
}
|
||||
}
|
||||
buf[0] = '\0';
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -36,14 +36,14 @@ int handle_client_command(const char *input, int *out_id) {
|
||||
if (strcmp(token, "from") == 0) {
|
||||
const char *port = strtok(NULL, " ");
|
||||
if (!port) return -1;
|
||||
int ret = carla_connect_direct(port, "looper:input");
|
||||
int ret = carla_connect_direct(port, "looper:ch0in");
|
||||
if (ret == 0) {
|
||||
strncpy(from_port, port, sizeof(from_port)-1);
|
||||
from_port[sizeof(from_port)-1] = '\0';
|
||||
g_connect_error[0] = '\0';
|
||||
} else {
|
||||
snprintf(g_connect_error, sizeof(g_connect_error),
|
||||
"Failed: %s -> looper:input (ret=%d)", port, ret);
|
||||
"Failed: %s -> looper:ch0in (ret=%d)", port, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
@@ -52,14 +52,14 @@ int handle_client_command(const char *input, int *out_id) {
|
||||
if (strcmp(token, "to") == 0) {
|
||||
const char *port = strtok(NULL, " ");
|
||||
if (!port) return -1;
|
||||
int ret = carla_connect_direct("looper:output", port);
|
||||
int ret = carla_connect_direct("looper:ch0out", port);
|
||||
if (ret == 0) {
|
||||
strncpy(to_port, port, sizeof(to_port)-1);
|
||||
to_port[sizeof(to_port)-1] = '\0';
|
||||
g_connect_error[0] = '\0';
|
||||
} else {
|
||||
snprintf(g_connect_error, sizeof(g_connect_error),
|
||||
"Failed: looper:output -> %s (ret=%d)", port, ret);
|
||||
"Failed: looper:ch0out -> %s (ret=%d)", port, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -440,14 +440,23 @@ void tui_run(void) {
|
||||
int channel = selected_col; // selected column = channel number
|
||||
bool found = carla_resolve_channel_port(channel, is_to, looper_port, sizeof(looper_port));
|
||||
if (!found) {
|
||||
/* Fallback to generic name (may not exist) */
|
||||
/* Fallback to generic name with looper: prefix */
|
||||
if (is_to)
|
||||
snprintf(looper_port, sizeof(looper_port), "ch%dout", channel);
|
||||
snprintf(looper_port, sizeof(looper_port), "looper:ch%dout", channel);
|
||||
else
|
||||
snprintf(looper_port, sizeof(looper_port), "ch%din", channel);
|
||||
/* The actual port name includes a PID suffix, but we try anyway */
|
||||
snprintf(looper_port, sizeof(looper_port), "looper:ch%din", channel);
|
||||
}
|
||||
int ret;
|
||||
const char *src, *dst;
|
||||
if (is_to) {
|
||||
ret = carla_connect_direct(looper_port, port_name);
|
||||
src = looper_port;
|
||||
dst = port_name;
|
||||
} else {
|
||||
ret = carla_connect_direct(port_name, looper_port);
|
||||
src = port_name;
|
||||
dst = looper_port;
|
||||
}
|
||||
int ret = carla_connect_direct(port_name, looper_port);
|
||||
if (ret == 0) {
|
||||
if (is_to) {
|
||||
strncpy(g_to_port, port_name, sizeof(g_to_port)-1);
|
||||
@@ -457,11 +466,11 @@ void tui_run(void) {
|
||||
g_from_port[sizeof(g_from_port)-1] = '\0';
|
||||
}
|
||||
g_connect_error[0] = '\0';
|
||||
log_msg("Connected %s -> %s", port_name, looper_port);
|
||||
log_msg("Connected %s -> %s", src, dst);
|
||||
} else {
|
||||
snprintf(g_connect_error, sizeof(g_connect_error),
|
||||
"Failed: %s -> %s (ret=%d)", port_name, looper_port, ret);
|
||||
log_msg("Failed to connect %s -> %s (ret=%d)", port_name, looper_port, ret);
|
||||
"Failed: %s -> %s (ret=%d)", src, dst, ret);
|
||||
log_msg("Failed to connect %s -> %s (ret=%d)", src, dst, ret);
|
||||
}
|
||||
}
|
||||
if (!potential_arg) g_selected_port[0] = '\0';
|
||||
|
||||
Reference in New Issue
Block a user