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