fix: increase test audio buffer size to prevent buffer overflow
Co-authored-by: aider (deepseek/deepseek-coder) <aider@aider.chat>
This commit is contained in:
@@ -42,7 +42,9 @@ static atomic_int tests_passed;
|
|||||||
static atomic_int tests_failed;
|
static atomic_int tests_failed;
|
||||||
|
|
||||||
// Shared buffers for test audio input (written by test thread, read by JACK callback)
|
// Shared buffers for test audio input (written by test thread, read by JACK callback)
|
||||||
static float test_audio_input[MAX_CHANNELS][TEST_NFRAMES * TEST_DURATION_SECONDS];
|
// Max samples = sample_rate * max_duration_seconds (sample_rate is typically 48000)
|
||||||
|
#define MAX_SAMPLES (48000 * TEST_DURATION_SECONDS)
|
||||||
|
static float test_audio_input[MAX_CHANNELS][MAX_SAMPLES];
|
||||||
static atomic_size_t test_audio_input_count[MAX_CHANNELS];
|
static atomic_size_t test_audio_input_count[MAX_CHANNELS];
|
||||||
static atomic_size_t test_audio_input_read[MAX_CHANNELS];
|
static atomic_size_t test_audio_input_read[MAX_CHANNELS];
|
||||||
|
|
||||||
@@ -51,7 +53,7 @@ static uint8_t test_midi_buffer[3]; // status, note, velocity
|
|||||||
static atomic_bool test_midi_pending;
|
static atomic_bool test_midi_pending;
|
||||||
|
|
||||||
// Test audio output buffers (written by JACK callback, read by test thread)
|
// Test audio output buffers (written by JACK callback, read by test thread)
|
||||||
static float test_output_buffer[MAX_CHANNELS][TEST_NFRAMES * TEST_DURATION_SECONDS];
|
static float test_output_buffer[MAX_CHANNELS][MAX_SAMPLES];
|
||||||
static atomic_size_t test_output_count[MAX_CHANNELS];
|
static atomic_size_t test_output_count[MAX_CHANNELS];
|
||||||
|
|
||||||
// ============================================================
|
// ============================================================
|
||||||
@@ -100,7 +102,7 @@ static int test_process_callback(jack_nframes_t nframes, void *arg) {
|
|||||||
jack_port_get_buffer(test_audio_in[ch], nframes);
|
jack_port_get_buffer(test_audio_in[ch], nframes);
|
||||||
|
|
||||||
size_t count = atomic_load(&test_output_count[ch]);
|
size_t count = atomic_load(&test_output_count[ch]);
|
||||||
if (count + nframes <= TEST_NFRAMES * TEST_DURATION_SECONDS) {
|
if (count + nframes <= MAX_SAMPLES) {
|
||||||
for (jack_nframes_t i = 0; i < nframes; i++) {
|
for (jack_nframes_t i = 0; i < nframes; i++) {
|
||||||
test_output_buffer[ch][count + i] = in[i];
|
test_output_buffer[ch][count + i] = in[i];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user