feat: add fzf-based file/plugin/port selection and update build system
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
#define _GNU_SOURCE
|
||||
#include <stdlib.h>
|
||||
#include <CarlaHost.h>
|
||||
#include <CarlaBackend.h>
|
||||
#include <string.h>
|
||||
@@ -206,6 +208,48 @@ int carla_disconnect_plugin(int id) {
|
||||
return any ? 0 : -1; // return -1 if no connections were found (harmless)
|
||||
}
|
||||
|
||||
#ifdef MOCK_JACK
|
||||
/* Mock: return a few fake port names */
|
||||
int carla_get_ports(const char *type, char ***ports, int *count) {
|
||||
(void)type;
|
||||
static const char *fake[] = {"system:capture_1", "system:capture_2", "system:playback_1", "system:playback_2"};
|
||||
*count = 4;
|
||||
*ports = malloc(*count * sizeof(char*));
|
||||
if (!*ports) { *count = 0; return -1; }
|
||||
for (int i = 0; i < *count; i++)
|
||||
(*ports)[i] = strdup(fake[i]);
|
||||
return 0;
|
||||
}
|
||||
#else
|
||||
#include <jack/jack.h>
|
||||
int carla_get_ports(const char *type, char ***ports, int *count) {
|
||||
(void)type;
|
||||
if (!jack_client) {
|
||||
*ports = NULL;
|
||||
*count = 0;
|
||||
return -1;
|
||||
}
|
||||
const char **jports = jack_get_ports(jack_client, NULL, NULL, 0);
|
||||
if (!jports) {
|
||||
*ports = NULL;
|
||||
*count = 0;
|
||||
return -1;
|
||||
}
|
||||
int n = 0;
|
||||
while (jports[n]) n++;
|
||||
*count = n;
|
||||
*ports = malloc(n * sizeof(char*));
|
||||
if (!*ports) {
|
||||
jack_free(jports);
|
||||
return -1;
|
||||
}
|
||||
for (int i = 0; i < n; i++)
|
||||
(*ports)[i] = strdup(jports[i]);
|
||||
jack_free(jports);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef TESTING
|
||||
int carla_test_connection_count(void) {
|
||||
return conn_count;
|
||||
|
||||
Reference in New Issue
Block a user