diff --git a/audio/hermite.c b/audio/hermite.c index a608b6ba87..64c7eed6e1 100644 --- a/audio/hermite.c +++ b/audio/hermite.c @@ -64,8 +64,22 @@ void resampler_process(rarch_resampler_t *re, struct resampler_data *data) const float *in_data = data->data_in; float *out_data = data->data_out; - for (size_t i = 0; i < in_frames; i++) + size_t i = 0; + while (i < in_frames) { + while (re->r_frac >= 1.0 && i < in_frames) + { + re->r_frac -= 1.0; + for (unsigned i = 0; i < CHANNELS; i++) + { + re->chan_data[i][0] = re->chan_data[i][1]; + re->chan_data[i][1] = re->chan_data[i][2]; + re->chan_data[i][2] = re->chan_data[i][3]; + re->chan_data[i][3] = *in_data++; + } + i++; + } + while (re->r_frac <= 1.0) { re->r_frac += r_step; @@ -77,18 +91,6 @@ void resampler_process(rarch_resampler_t *re, struct resampler_data *data) } processed_out++; } - - while (re->r_frac >= 1.0) - { - re->r_frac -= 1.0; - for (unsigned i = 0; i < CHANNELS; i++) - { - re->chan_data[i][0] = re->chan_data[i][1]; - re->chan_data[i][1] = re->chan_data[i][2]; - re->chan_data[i][2] = re->chan_data[i][3]; - re->chan_data[i][3] = *in_data++; - } - } } data->output_frames = processed_out; diff --git a/audio/sinc.c b/audio/sinc.c index 63e20636c9..2431a9884e 100644 --- a/audio/sinc.c +++ b/audio/sinc.c @@ -254,14 +254,13 @@ void resampler_process(rarch_resampler_t *re, struct resampler_data *data) frames--; } - if (re->time >= PHASES) - break; - - process_sinc(re, output); - output += 2; - out_frames++; - - re->time += ratio; + while (re->time < PHASES) + { + process_sinc(re, output); + output += 2; + out_frames++; + re->time += ratio; + } } data->output_frames = out_frames;