fix: start and clean up looper process in audio pass-through test
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
@@ -208,11 +208,15 @@ static void test_clock_continue(void) {
|
|||||||
|
|
||||||
static int test_audio_pass_through(void) {
|
static int test_audio_pass_through(void) {
|
||||||
printf("Test: audio pass‑through (connectivity)\n");
|
printf("Test: audio pass‑through (connectivity)\n");
|
||||||
|
pid_t pid = start_looper();
|
||||||
|
if (pid < 0) return 1;
|
||||||
jack_client_t *client;
|
jack_client_t *client;
|
||||||
jack_status_t status;
|
jack_status_t status;
|
||||||
client = jack_client_open("test_passthrough", JackNoStartServer, &status);
|
client = jack_client_open("test_passthrough", JackNoStartServer, &status);
|
||||||
if (client == NULL) {
|
if (client == NULL) {
|
||||||
fprintf(stderr, " SKIP: cannot open JACK client (server not running?)\n");
|
fprintf(stderr, " SKIP: cannot open JACK client (server not running?)\n");
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
jack_port_t *output_port = jack_port_register(client, "output",
|
jack_port_t *output_port = jack_port_register(client, "output",
|
||||||
@@ -224,6 +228,8 @@ static int test_audio_pass_through(void) {
|
|||||||
if (!output_port || !input_port) {
|
if (!output_port || !input_port) {
|
||||||
fprintf(stderr, " FAIL: could not register ports\n");
|
fprintf(stderr, " FAIL: could not register ports\n");
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
usleep(200000);
|
usleep(200000);
|
||||||
@@ -235,11 +241,15 @@ static int test_audio_pass_through(void) {
|
|||||||
if (jack_connect(client, my_output, looper_input) != 0) {
|
if (jack_connect(client, my_output, looper_input) != 0) {
|
||||||
fprintf(stderr, " FAIL: cannot connect test_passthrough:output -> looper:input\n");
|
fprintf(stderr, " FAIL: cannot connect test_passthrough:output -> looper:input\n");
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (jack_connect(client, looper_output, my_input) != 0) {
|
if (jack_connect(client, looper_output, my_input) != 0) {
|
||||||
fprintf(stderr, " FAIL: cannot connect looper:output -> test_passthrough:input\n");
|
fprintf(stderr, " FAIL: cannot connect looper:output -> test_passthrough:input\n");
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
passthrough_output_port = output_port;
|
passthrough_output_port = output_port;
|
||||||
@@ -254,6 +264,8 @@ static int test_audio_pass_through(void) {
|
|||||||
if (jack_activate(client) != 0) {
|
if (jack_activate(client) != 0) {
|
||||||
fprintf(stderr, " FAIL: cannot activate client\n");
|
fprintf(stderr, " FAIL: cannot activate client\n");
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
usleep(2200000); /* 2.2 seconds */
|
usleep(2200000); /* 2.2 seconds */
|
||||||
@@ -262,6 +274,8 @@ static int test_audio_pass_through(void) {
|
|||||||
sqrt(passthrough_sum_sq / passthrough_total_samples) : 0.0;
|
sqrt(passthrough_sum_sq / passthrough_total_samples) : 0.0;
|
||||||
jack_deactivate(client);
|
jack_deactivate(client);
|
||||||
jack_client_close(client);
|
jack_client_close(client);
|
||||||
|
kill(pid, SIGTERM);
|
||||||
|
waitpid(pid, NULL, 0);
|
||||||
if (!saw_input) {
|
if (!saw_input) {
|
||||||
fprintf(stderr, " FAIL: looper did not produce output (no callback run?)\n");
|
fprintf(stderr, " FAIL: looper did not produce output (no callback run?)\n");
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
Reference in New Issue
Block a user