2-midi-looping #3

Merged
boomjacky merged 17 commits from 2-midi-looping into master 2026-05-10 12:24:23 -04:00
2 changed files with 30 additions and 23 deletions
Showing only changes of commit fe3fb7d873 - Show all commits

View File

@@ -51,9 +51,9 @@ int main(int argc, char *argv[]) {
while (1) {
looper_process_commands(client);
{
struct timespec ts = {.tv_sec = 0, .tv_nsec = 50000000};
struct timespec ts = {.tv_sec = 0, .tv_nsec = 1000000};
nanosleep(&ts, NULL);
} /* check commands every 50 ms */
} /* check commands every 1 ms */
}
jack_client_close(client);

View File

@@ -396,21 +396,24 @@ static int test_multiple_channels(void) {
fprintf(stderr, " FAIL: send note 60 failed\n");
return 1;
}
/* wait long enough for the looper's main loop to process the add command
(it sleeps for 1 second between checks, so 1.5 s is safe) */
safe_usleep(1500000);
/* Poll until the port appears (up to 3 seconds) */
int found = 0;
const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
if (ports) {
for (int i = 0; ports[i]; i++) {
if (strstr(ports[i], "looper:channel1_input")) {
found = 1;
break;
for (int retries = 0; retries < 30; retries++) {
safe_usleep(100000);
const char **ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
if (ports) {
for (int i = 0; ports[i]; i++) {
if (strstr(ports[i], "looper:channel1_input")) {
found = 1;
jack_free(ports);
goto port_found;
}
}
jack_free(ports);
}
jack_free(ports);
}
port_found:
;
jack_client_close(client);
kill(pid, SIGTERM);
waitpid(pid, NULL, 0);
@@ -811,18 +814,22 @@ static int test_remove_channel(void) {
fprintf(stderr, " FAIL: send note 61 failed\n");
return 1;
}
safe_usleep(1500000);
/* verify channel1_input has disappeared */
ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
int still_found = 0;
if (ports) {
for (int i = 0; ports[i]; i++) {
if (strstr(ports[i], "looper:channel1_input")) {
still_found = 1;
break;
/* Poll until the port disappears (up to 3 seconds) */
int still_found = 1;
for (int retries = 0; retries < 30; retries++) {
safe_usleep(100000);
ports = jack_get_ports(client, NULL, JACK_DEFAULT_AUDIO_TYPE, 0);
still_found = 0;
if (ports) {
for (int i = 0; ports[i]; i++) {
if (strstr(ports[i], "looper:channel1_input")) {
still_found = 1;
break;
}
}
jack_free(ports);
}
jack_free(ports);
if (!still_found) break;
}
jack_client_close(client);
kill(pid, SIGTERM);