diff --git a/apu/hermite_resampler.h b/apu/hermite_resampler.h index c2a175c5..bc542d93 100644 --- a/apu/hermite_resampler.h +++ b/apu/hermite_resampler.h @@ -66,6 +66,13 @@ class HermiteResampler : public Resampler void read (short *data, int num_samples) { + //If we are outputting the exact same ratio as the input, pull directly from the input buffer + if (r_step == 1.0) + { + ring_buffer::pull((unsigned char*)data, num_samples * sizeof(short)); + return; + } + assert((num_samples & 1) == 0); // resampler always processes both stereo samples int i_position = start >> 1; int max_samples = buffer_size >> 1; @@ -121,6 +128,12 @@ class HermiteResampler : public Resampler inline int avail (void) { + //If we are outputting the exact same ratio as the input, find out directly from the input buffer + if (r_step == 1.0) + { + return (ring_buffer::space_filled() + sizeof(short) - 1) / sizeof(short); + } + return (int) floor (((size >> 2) - r_frac) / r_step) * 2; } };