Refactor resampler.c