fix: increase timing margins in integration test to ensure MIDI events are delivered

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-07 22:27:00 +00:00
parent 74b68eb378
commit 65c346d14d

View File

@@ -240,6 +240,7 @@ static int send_jack_note_on(const char *target_port, unsigned char note, unsign
midi_inject_port = NULL;
return -1;
}
midi_inject_pending = 1; /* signal before activation */
jack_set_process_callback(midi_inject_client, midi_inject_process, NULL);
if (jack_activate(midi_inject_client) != 0) {
jack_client_close(midi_inject_client);
@@ -247,9 +248,11 @@ static int send_jack_note_on(const char *target_port, unsigned char note, unsign
midi_inject_port = NULL;
return -1;
}
midi_inject_pending = 1;
/* wait for one process cycle to deliver the event */
usleep(200000);
/* wait for the process callback to clear the flag (event delivered) */
for (int attempts = 0; attempts < 50; attempts++) { /* ~50 * 10ms = 500ms */
usleep(10000);
if (!midi_inject_pending) break;
}
jack_deactivate(midi_inject_client);
jack_client_close(midi_inject_client);
midi_inject_client = NULL;
@@ -309,7 +312,7 @@ static int test_looper_looping(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1;
}
usleep(200000); /* allow state to change */
usleep(500000); /* allow state to change (500ms) */
int sr = jack_get_sample_rate(client);
continuous_sine = 0; /* disable continuous tone */
@@ -326,9 +329,8 @@ static int test_looper_looping(void) {
usleep(150000); /* let beep start */
/* after beep finishes, give it a moment then send noteon to stop recording */
usleep(500000);
beep_remaining = 0;
/* ensure beep is fully captured */
usleep(800000); /* 0.8s after start of beep */
if (send_jack_note_on("looper:control", 1, 127) != 0) {
jack_client_close(client);
@@ -336,8 +338,8 @@ static int test_looper_looping(void) {
return 1;
}
/* wait enough time for several loops (3 seconds) */
usleep(3000000);
/* wait enough time for several loops (4 seconds to be safe) */
usleep(4000000);
jack_deactivate(client);
jack_client_close(client);