diff --git a/src/cubeb_resampler_internal.h b/src/cubeb_resampler_internal.h index 3e8b097..876d09b 100644 --- a/src/cubeb_resampler_internal.h +++ b/src/cubeb_resampler_internal.h @@ -307,9 +307,11 @@ public: uint32_t input_needed_for_output(int32_t output_frame_count) const { assert(output_frame_count >= 0); // Check overflow + int32_t unresampled_frames_left = samples_to_frames(resampling_in_buffer.length()); int32_t resampled_frames_left = samples_to_frames(resampling_out_buffer.length()); - float input_frames_needed = - output_frame_count * resampling_ratio - resampled_frames_left; + float input_frames_needed = + (output_frame_count - unresampled_frames_left) * resampling_ratio + - resampled_frames_left; if (input_frames_needed < 0) { return 0; }