Resampler: force even buffer sizes in resize

This commit is contained in:
OV2 2023-03-29 12:27:22 +02:00
parent 59c48e35a7
commit afe8dd9f01
1 changed files with 5 additions and 6 deletions

View File

@ -65,13 +65,9 @@ class Resampler
Resampler(int num_samples) Resampler(int num_samples)
{ {
// Only allow even buffer sizes buffer = NULL;
if (num_samples & 1) resize(num_samples);
num_samples++;
this->buffer_size = num_samples;
buffer = new int16_t[this->buffer_size];
r_step = 1.0; r_step = 1.0;
clear();
} }
~Resampler() ~Resampler()
@ -223,6 +219,9 @@ class Resampler
{ {
if (buffer) if (buffer)
delete[] buffer; delete[] buffer;
// Only allow even buffer sizes
if (num_samples & 1)
num_samples++;
buffer_size = num_samples; buffer_size = num_samples;
buffer = new int16_t[buffer_size]; buffer = new int16_t[buffer_size];
clear(); clear();