fix: reconnect MIDI client before each test to avoid stale connections
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
@@ -56,6 +56,29 @@ static int midi_inject_process(jack_nframes_t nframes, void *arg) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Helper: close and reopen the persistent MIDI client so it connects
|
||||
to the current looper instance */
|
||||
static void midi_inject_reconnect(const char *target_port) {
|
||||
if (midi_inject_client) {
|
||||
jack_deactivate(midi_inject_client);
|
||||
jack_client_close(midi_inject_client);
|
||||
midi_inject_client = NULL;
|
||||
midi_inject_port = NULL;
|
||||
}
|
||||
jack_status_t st;
|
||||
midi_inject_client = jack_client_open("midi_inject_persistent", JackNoStartServer, &st);
|
||||
if (!midi_inject_client) return;
|
||||
midi_inject_port = jack_port_register(midi_inject_client, "out",
|
||||
JACK_DEFAULT_MIDI_TYPE,
|
||||
JackPortIsOutput, 0);
|
||||
if (!midi_inject_port) return;
|
||||
jack_set_process_callback(midi_inject_client, midi_inject_process, NULL);
|
||||
jack_activate(midi_inject_client);
|
||||
char src[64];
|
||||
snprintf(src, sizeof(src), "midi_inject_persistent:out");
|
||||
jack_connect(midi_inject_client, src, target_port);
|
||||
}
|
||||
|
||||
/* The test code uses this callback in two ways:
|
||||
- For the audio passthrough test (existing function) it still works.
|
||||
- For the loop test we need a version that respects the static variables
|
||||
|
||||
Reference in New Issue
Block a user