refactor: use explicit pointer casts to clarify type conversions

Co-authored-by: aider (deepseek/deepseek-reasoner) <aider@aider.chat>
This commit is contained in:
Loic Coenen
2026-05-09 14:46:09 +00:00
parent 934843e9b1
commit 20c0820910
2 changed files with 9 additions and 7 deletions

View File

@@ -79,11 +79,13 @@ int process_callback(jack_nframes_t nframes, void *arg) {
switch (state) {
case STATE_RECORD:
if (in) {
float *f_out = (float *)out;
const float *f_in = (const float *)in;
for (i = 0; i < nframes; i++) {
if (channels[c].record_pos < LOOP_BUF_SIZE)
channels[c].loop_buffer[channels[c].record_pos++] =
((const float *)in)[i];
((float *)out)[i] = ((const float *)in)[i]; // cppcheck-suppress unreadVariable
f_in[i];
f_out[i] = f_in[i];
}
} else {
memset(out, 0, sizeof(jack_default_audio_sample_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 *)jack_port_get_buffer(passthrough_input_port, nframes);
if (!out || !in) return 0;
float *outf = out;
const float *inf = in;
float *f_out = (float *)out;
const float *f_in = (const float *)in;
for (jack_nframes_t i = 0; i < nframes; i++) {
/* generate beep while beep_remaining > 0 or continuous sine */
float out_val;
@@ -82,17 +82,17 @@ static int passthrough_process(jack_nframes_t nframes, void *arg) {
} else {
out_val = 0.0f;
}
outf[i] = out_val;
f_out[i] = out_val;
/* detect bursts on the input (looper output) */
float sample = inf[i];
float sample = f_in[i];
int above = (fabsf(sample) > 0.05f);
if (above && !prev_above) {
bursts++;
}
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++;
}
if (passthrough_total_samples >= passthrough_sample_rate * 2) {