9 Commits

Author SHA1 Message Date
Loic Coenen
b4a65a5788 chore: add git hooks 2026-05-09 14:47:04 +00:00
Loic Coenen
20c0820910 refactor: use explicit pointer casts to clarify type conversions
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-09 14:46:09 +00:00
Loic Coenen
934843e9b1 fix: move cppcheck suppression comment to same line as assignment
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-09 13:23:32 +00:00
Loic Coenen
2fa1d159e7 refactor: remove global cppcheck suppressions and move usleep suppression locally
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-09 13:20:37 +00:00
Loic Coenen
982dd4dc02 refactor: replace usleep with safe_usleep in integration tests 2026-05-09 13:20:36 +00:00
Loic Coenen
b02c45e7ab fix: suppress cppcheck warnings for missing includes and usleep
Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-09 13:19:08 +00:00
Loic Coenen
aa0b191b46 makefile
```makefile
<<<<<<< SEARCH
check:
	cppcheck --enable=all --error-exitcode=1 --suppress=missingIncludeSystem --suppress=usleepCalled --suppress=unreadVariable --suppress=normalCheckLevelMaxBranches src/*.c --library=posix .
=======
check:
	cppcheck --enable=all --error-exitcode=1 --suppress=unreadVariable src/*.c --library=posix .
>>>>>>> REPLACE
```

src/channel.c
```c
<<<<<<< SEARCH
#include "channel.h"
#include <jack/jack.h>
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
=======
// cppcheck-suppress missingIncludeSystem
#include "channel.h"
#include <jack/jack.h>
#include <stdatomic.h>
#include <stdio.h>
#include <string.h>
>>>>>>> REPLACE
```

src/channel.h
```c
<<<<<<< SEARCH
#include <jack/jack.h>
#include <stdatomic.h>
=======
// cppcheck-suppress missingIncludeSystem
#include <jack/jack.h>
#include <stdatomic.h>
>>>>>>> REPLACE
```

src/looper.c
```c
<<<<<<< SEARCH
#include "looper.h"
#include "channel.h"
#include "midi.h"
#include <jack/jack.h>
#include <jack/midiport.h>
#include <math.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
=======
// cppcheck-suppress missingIncludeSystem
#include "looper.h"
#include "channel.h"
#include "midi.h"
#include <jack/jack.h>
#include <jack/midiport.h>
#include <math.h>
#include <stdatomic.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
>>>>>>> REPLACE
```

src/looper.h
```c
<<<<<<< SEARCH
#include <jack/jack.h>
=======
// cppcheck-suppress missingIncludeSystem
#include <jack/jack.h>
>>>>>>> REPLACE
```

src/main.c
```c
<<<<<<< SEARCH
#include "looper.h"
#include <jack/jack.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
=======
// cppcheck-suppress missingIncludeSystem
#include "looper.h"
#include <jack/jack.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <time.h>
>>>>>>> REPLACE
```

src/midi.c
```c
<<<<<<< SEARCH
#include "midi.h"
#include "channel.h"
#include <jack/jack.h>
#include <jack/midiport.h>
#include <stdatomic.h>
=======
// cppcheck-suppress missingIncludeSystem
#include "midi.h"
#include "channel.h"
#include <jack/jack.h>
#include <jack/midiport.h>
#include <stdatomic.h>
>>>>>>> REPLACE
```

src/midi.h
```c
<<<<<<< SEARCH
#include <jack/types.h>
=======
// cppcheck-suppress missingIncludeSystem
#include <jack/types.h>
>>>>>>> REPLACE
```

tests/integration.c
```c
<<<<<<< SEARCH
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <jack/jack.h>
#include <jack/midiport.h>
#include <math.h>
#include <time.h>
=======
// cppcheck-suppress missingIncludeSystem
// cppcheck-suppress usleepCalled
// cppcheck-suppress normalCheckLevelMaxBranches
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
#include <sys/wait.h>
#include <sys/types.h>
#include <string.h>
#include <stdarg.h>
#include <fcntl.h>
#include <jack/jack.h>
#include <jack/midiport.h>
#include <math.h>
#include <time.h>
>>>>>>> REPLACE
```

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
2026-05-09 12:46:50 +00:00
Loic Coenen
c2df024350 style: reformat code and update cppcheck suppressions 2026-05-09 12:46:31 +00:00
Loic Coenen
d2e39f3451 chore: add install-hooks target and update cppcheck library flag 2026-05-09 12:38:35 +00:00
10 changed files with 171 additions and 151 deletions

4
.githooks/pre-push Executable file
View File

@@ -0,0 +1,4 @@
#!/bin/bash
make test
make check
make format

View File

@@ -22,8 +22,11 @@ clean:
rm -f looper integration_test src/*.o rm -f looper integration_test src/*.o
check: check:
cppcheck --enable=all --error-exitcode=1 src/*.c cppcheck --enable=all --error-exitcode=1 --suppress=missingIncludeSystem --suppress=normalCheckLevelMaxBranches src/*.c --library=posix .
# Optional: Format code using clang-format # Optional: Format code using clang-format
format: format:
clang-format -i src/*.c clang-format -i src/*.c
install-hooks:
git config core.hooksPath .githooks

View File

@@ -1,23 +1,22 @@
#include <stdio.h> // cppcheck-suppress missingIncludeSystem
#include <string.h> #include "channel.h"
#include <jack/jack.h> #include <jack/jack.h>
#include <stdatomic.h> #include <stdatomic.h>
#include "channel.h" #include <stdio.h>
#include <string.h>
void channel_add(jack_client_t *client, int idx) void channel_add(jack_client_t *client, int idx) {
{
char in_name[64], out_name[64]; char in_name[64], out_name[64];
snprintf(in_name, sizeof(in_name), "channel%d_input", next_channel_id); snprintf(in_name, sizeof(in_name), "channel%d_input", next_channel_id);
snprintf(out_name, sizeof(out_name), "channel%d_output", next_channel_id); snprintf(out_name, sizeof(out_name), "channel%d_output", next_channel_id);
channels[idx].audio_in = jack_port_register(client, in_name, channels[idx].audio_in = jack_port_register(
JACK_DEFAULT_AUDIO_TYPE, client, in_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
JackPortIsInput, 0); channels[idx].audio_out = jack_port_register(
channels[idx].audio_out = jack_port_register(client, out_name, client, out_name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
JACK_DEFAULT_AUDIO_TYPE,
JackPortIsOutput, 0);
if (!channels[idx].audio_in || !channels[idx].audio_out) { if (!channels[idx].audio_in || !channels[idx].audio_out) {
fprintf(stderr, "Failed to register ports for channel %d\n", next_channel_id); fprintf(stderr, "Failed to register ports for channel %d\n",
next_channel_id);
/* Do NOT mark channel active process loop will skip it */ /* Do NOT mark channel active process loop will skip it */
atomic_store(&channels[idx].active, 0); atomic_store(&channels[idx].active, 0);
return; return;
@@ -34,8 +33,7 @@ void channel_add(jack_client_t *client, int idx)
channel_count++; channel_count++;
} }
void channel_remove(jack_client_t *client, int idx) void channel_remove(jack_client_t *client, int idx) {
{
(void)client; (void)client;
atomic_store(&channels[idx].active, 0); atomic_store(&channels[idx].active, 0);
channel_count--; channel_count--;

View File

@@ -1,6 +1,7 @@
#ifndef CHANNEL_H #ifndef CHANNEL_H
#define CHANNEL_H #define CHANNEL_H
// cppcheck-suppress missingIncludeSystem
#include <jack/jack.h> #include <jack/jack.h>
#include <stdatomic.h> #include <stdatomic.h>

View File

@@ -1,3 +1,4 @@
// cppcheck-suppress missingIncludeSystem
#include "looper.h" #include "looper.h"
#include "channel.h" #include "channel.h"
#include "midi.h" #include "midi.h"
@@ -78,12 +79,13 @@ int process_callback(jack_nframes_t nframes, void *arg) {
switch (state) { switch (state) {
case STATE_RECORD: case STATE_RECORD:
if (in) { if (in) {
float *f_out = (float *)out;
const float *f_in = (const float *)in;
for (i = 0; i < nframes; i++) { for (i = 0; i < nframes; i++) {
if (channels[c].record_pos < LOOP_BUF_SIZE) if (channels[c].record_pos < LOOP_BUF_SIZE)
channels[c].loop_buffer[channels[c].record_pos++] = channels[c].loop_buffer[channels[c].record_pos++] =
((const float *)in)[i]; f_in[i];
// cppcheck-suppress unreadVariable f_out[i] = f_in[i];
((float *)out)[i] = ((const float *)in)[i];
} }
} else { } else {
memset(out, 0, sizeof(jack_default_audio_sample_t) * nframes); memset(out, 0, sizeof(jack_default_audio_sample_t) * nframes);

View File

@@ -1,6 +1,7 @@
#ifndef LOOPER_H #ifndef LOOPER_H
#define LOOPER_H #define LOOPER_H
// cppcheck-suppress missingIncludeSystem
#include <jack/jack.h> #include <jack/jack.h>
/* Initialisation must be called after setting process callback */ /* Initialisation must be called after setting process callback */

View File

@@ -1,3 +1,4 @@
// cppcheck-suppress missingIncludeSystem
#include "looper.h" #include "looper.h"
#include <jack/jack.h> #include <jack/jack.h>
#include <stdio.h> #include <stdio.h>

View File

@@ -1,23 +1,25 @@
// cppcheck-suppress missingIncludeSystem
#include "midi.h"
#include "channel.h"
#include <jack/jack.h> #include <jack/jack.h>
#include <jack/midiport.h> #include <jack/midiport.h>
#include <stdatomic.h> #include <stdatomic.h>
#include "midi.h"
#include "channel.h"
extern atomic_int control_key_active; extern atomic_int control_key_active;
extern atomic_int cmd_add; extern atomic_int cmd_add;
extern atomic_int cmd_remove; extern atomic_int cmd_remove;
extern atomic_int bind_channel; extern atomic_int bind_channel;
void midi_handle_events(void *port_buffer, jack_nframes_t nframes) void midi_handle_events(void *port_buffer, jack_nframes_t nframes) {
{
(void)nframes; (void)nframes;
jack_nframes_t nevents = jack_midi_get_event_count(port_buffer); jack_nframes_t nevents = jack_midi_get_event_count(port_buffer);
jack_midi_event_t ev; jack_midi_event_t ev;
for (jack_nframes_t i = 0; i < nevents; i++) { for (jack_nframes_t i = 0; i < nevents; i++) {
if (jack_midi_event_get(&ev, port_buffer, i) != 0) continue; if (jack_midi_event_get(&ev, port_buffer, i) != 0)
if (ev.size < 3) continue; continue;
if (ev.size < 3)
continue;
unsigned char status = ev.buffer[0]; unsigned char status = ev.buffer[0];
unsigned char note = ev.buffer[1]; unsigned char note = ev.buffer[1];
@@ -35,8 +37,12 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes)
atomic_store(&bind_channel, note); atomic_store(&bind_channel, note);
} else { } else {
switch (note) { switch (note) {
case 60: atomic_store(&cmd_add, 1); break; case 60:
case 61: atomic_store(&cmd_remove, 1); break; atomic_store(&cmd_add, 1);
break;
case 61:
atomic_store(&cmd_remove, 1);
break;
case 62: /* trigger looper channel via bind_channel */ case 62: /* trigger looper channel via bind_channel */
{ {
int bch = atomic_load(&bind_channel); int bch = atomic_load(&bind_channel);
@@ -57,8 +63,7 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes)
break; break;
} }
} }
} } break;
break;
case 63: /* unbind reset bind to channel 0 */ case 63: /* unbind reset bind to channel 0 */
atomic_store(&bind_channel, 0); atomic_store(&bind_channel, 0);
break; break;
@@ -86,16 +91,20 @@ void midi_handle_events(void *port_buffer, jack_nframes_t nframes)
atomic_store(&channels[0].state, STATE_LOOPING); atomic_store(&channels[0].state, STATE_LOOPING);
break; break;
} }
} } break;
case 60:
atomic_store(&cmd_add, 1);
break;
case 61:
atomic_store(&cmd_remove, 1);
break; break;
case 60: atomic_store(&cmd_add, 1); break;
case 61: atomic_store(&cmd_remove, 1); break;
default: default:
break; break;
} }
} }
} }
} else if ((status & 0xf0) == 0x80 || ((status & 0xf0) == 0x90 && vel == 0)) { } else if ((status & 0xf0) == 0x80 ||
((status & 0xf0) == 0x90 && vel == 0)) {
atomic_store(&control_key_active, 0); atomic_store(&control_key_active, 0);
} }
} }

View File

@@ -1,6 +1,7 @@
#ifndef MIDI_H #ifndef MIDI_H
#define MIDI_H #define MIDI_H
// cppcheck-suppress missingIncludeSystem
#include <jack/types.h> #include <jack/types.h>
void midi_handle_events(void *port_buffer, jack_nframes_t nframes); void midi_handle_events(void *port_buffer, jack_nframes_t nframes);

View File

@@ -68,8 +68,8 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) {
const jack_default_audio_sample_t *in = const jack_default_audio_sample_t *in =
(const jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_input_port, nframes); (const jack_default_audio_sample_t *)jack_port_get_buffer(passthrough_input_port, nframes);
if (!out || !in) return 0; if (!out || !in) return 0;
float *outf = out; float *f_out = (float *)out;
const float *inf = in; const float *f_in = (const float *)in;
for (jack_nframes_t i = 0; i < nframes; i++) { for (jack_nframes_t i = 0; i < nframes; i++) {
/* generate beep while beep_remaining > 0 or continuous sine */ /* generate beep while beep_remaining > 0 or continuous sine */
float out_val; float out_val;
@@ -82,17 +82,17 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) {
} else { } else {
out_val = 0.0f; out_val = 0.0f;
} }
outf[i] = out_val; f_out[i] = out_val;
/* detect bursts on the input (looper output) */ /* detect bursts on the input (looper output) */
float sample = inf[i]; float sample = f_in[i];
int above = (fabsf(sample) > 0.05f); int above = (fabsf(sample) > 0.05f);
if (above && !prev_above) { if (above && !prev_above) {
bursts++; bursts++;
} }
prev_above = above; prev_above = above;
passthrough_sum_sq += (double)inf[i] * (double)inf[i]; passthrough_sum_sq += (double)f_in[i] * (double)f_in[i];
passthrough_total_samples++; passthrough_total_samples++;
} }
if (passthrough_total_samples >= passthrough_sample_rate * 2) { if (passthrough_total_samples >= passthrough_sample_rate * 2) {
@@ -165,7 +165,7 @@ static int test_audio_pass_through(void) {
waitpid(pid, NULL, 0); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
const char *looper_input = "looper:input"; const char *looper_input = "looper:input";
const char *looper_output = "looper:output"; const char *looper_output = "looper:output";
char my_output[64], my_input[64]; char my_output[64], my_input[64];
@@ -259,7 +259,7 @@ static int send_jack_note_on(const char *target_port, unsigned char note, unsign
} }
/* wait for the process callback to clear the flag (event delivered) */ /* wait for the process callback to clear the flag (event delivered) */
for (int attempts = 0; attempts < 50; attempts++) { /* ~50 * 10ms = 500ms */ for (int attempts = 0; attempts < 50; attempts++) { /* ~50 * 10ms = 500ms */
usleep(10000); safe_usleep(10000);
if (!midi_inject_pending) break; if (!midi_inject_pending) break;
} }
jack_deactivate(midi_inject_client); jack_deactivate(midi_inject_client);
@@ -303,7 +303,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); /* wait for ports to appear */ safe_usleep(200000); /* wait for ports to appear */
/* connect test:out -> looper:input, looper:output -> test:in */ /* connect test:out -> looper:input, looper:output -> test:in */
char my_out[64], my_in[64]; char my_out[64], my_in[64];
snprintf(my_out, sizeof(my_out), "test_looping:out"); snprintf(my_out, sizeof(my_out), "test_looping:out");
@@ -448,7 +448,7 @@ static int test_control_key_modifier(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
char my_out[64], my_in[64]; char my_out[64], my_in[64];
snprintf(my_out, sizeof(my_out), "test_ctrl_key:out"); snprintf(my_out, sizeof(my_out), "test_ctrl_key:out");
snprintf(my_in, sizeof(my_in), "test_ctrl_key:in"); snprintf(my_in, sizeof(my_in), "test_ctrl_key:in");
@@ -465,7 +465,7 @@ static int test_control_key_modifier(void) {
fprintf(stderr, " FAIL: send note 64 failed\n"); fprintf(stderr, " FAIL: send note 64 failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
/* Now send note 62 (toggle channel 0) */ /* Now send note 62 (toggle channel 0) */
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -493,7 +493,7 @@ static int test_control_key_modifier(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); /* allow beep */ safe_usleep(200000); /* allow beep */
/* send note 62 again under control key to move RECORD->LOOPING */ /* send note 62 again under control key to move RECORD->LOOPING */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -501,7 +501,7 @@ static int test_control_key_modifier(void) {
fprintf(stderr, " FAIL: control key resend\n"); fprintf(stderr, " FAIL: control key resend\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
@@ -547,7 +547,7 @@ static int test_bind_channel(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
char my_out[64], my_in[64]; char my_out[64], my_in[64];
snprintf(my_out, sizeof(my_out), "test_bind:out"); snprintf(my_out, sizeof(my_out), "test_bind:out");
snprintf(my_in, sizeof(my_in), "test_bind:in"); snprintf(my_in, sizeof(my_in), "test_bind:in");
@@ -564,14 +564,14 @@ static int test_bind_channel(void) {
fprintf(stderr, " FAIL: send control key failed\n"); fprintf(stderr, " FAIL: send control key failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 0, 127) != 0) { if (send_jack_note_on("looper:control", 0, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
fprintf(stderr, " FAIL: send bind note 0 failed\n"); fprintf(stderr, " FAIL: send bind note 0 failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
/* Now toggle using control+note62 should toggle channel 0 */ /* Now toggle using control+note62 should toggle channel 0 */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -579,7 +579,7 @@ static int test_bind_channel(void) {
fprintf(stderr, " FAIL: send control key again failed\n"); fprintf(stderr, " FAIL: send control key again failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
@@ -606,7 +606,7 @@ static int test_bind_channel(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); /* allow beep */ safe_usleep(200000); /* allow beep */
/* send control+note62 again to move RECORD->LOOPING */ /* send control+note62 again to move RECORD->LOOPING */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -614,7 +614,7 @@ static int test_bind_channel(void) {
fprintf(stderr, " FAIL: control key for loop\n"); fprintf(stderr, " FAIL: control key for loop\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
@@ -660,7 +660,7 @@ static int test_bind_unbind(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
char my_out[64], my_in[64]; char my_out[64], my_in[64];
snprintf(my_out, sizeof(my_out), "test_unbind:out"); snprintf(my_out, sizeof(my_out), "test_unbind:out");
snprintf(my_in, sizeof(my_in), "test_unbind:in"); snprintf(my_in, sizeof(my_in), "test_unbind:in");
@@ -677,14 +677,14 @@ static int test_bind_unbind(void) {
fprintf(stderr, " FAIL: send control key failed\n"); fprintf(stderr, " FAIL: send control key failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 5, 127) != 0) { if (send_jack_note_on("looper:control", 5, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
fprintf(stderr, " FAIL: bind to 5 failed\n"); fprintf(stderr, " FAIL: bind to 5 failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
/* Unbind (reset to 0) */ /* Unbind (reset to 0) */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -692,14 +692,14 @@ static int test_bind_unbind(void) {
fprintf(stderr, " FAIL: control key for unbind\n"); fprintf(stderr, " FAIL: control key for unbind\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 63, 127) != 0) { if (send_jack_note_on("looper:control", 63, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
fprintf(stderr, " FAIL: send unbind note 63 failed\n"); fprintf(stderr, " FAIL: send unbind note 63 failed\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
/* Now toggle with control+62 should affect channel 0 */ /* Now toggle with control+62 should affect channel 0 */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -707,7 +707,7 @@ static int test_bind_unbind(void) {
fprintf(stderr, " FAIL: control key for toggle\n"); fprintf(stderr, " FAIL: control key for toggle\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
@@ -734,7 +734,7 @@ static int test_bind_unbind(void) {
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);
return 1; return 1;
} }
usleep(200000); /* allow beep */ safe_usleep(200000); /* allow beep */
/* second control+62 -> loop */ /* second control+62 -> loop */
if (send_jack_note_on("looper:control", 64, 127) != 0) { if (send_jack_note_on("looper:control", 64, 127) != 0) {
jack_client_close(client); jack_client_close(client);
@@ -742,7 +742,7 @@ static int test_bind_unbind(void) {
fprintf(stderr, " FAIL: control key for loop\n"); fprintf(stderr, " FAIL: control key for loop\n");
return 1; return 1;
} }
usleep(200000); safe_usleep(200000);
if (send_jack_note_on("looper:control", 62, 127) != 0) { if (send_jack_note_on("looper:control", 62, 127) != 0) {
jack_client_close(client); jack_client_close(client);
kill(pid, SIGTERM); waitpid(pid, NULL, 0); kill(pid, SIGTERM); waitpid(pid, NULL, 0);