diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 684e098f18..3601e1dbdf 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -796,8 +796,10 @@ bool audio_driver_find_driver(void) void audio_driver_deinit_resampler(void) { - rarch_resampler_freep(&audio_driver_resampler, - &audio_driver_resampler_data); + if (audio_driver_resampler && audio_driver_resampler_data) + audio_driver_resampler->free(audio_driver_resampler_data); + audio_driver_resampler = NULL; + audio_driver_resampler_data = NULL; } bool audio_driver_free_devices_list(void) @@ -852,8 +854,8 @@ void audio_driver_process_resampler(void *data) struct resampler_data *resampler = (struct resampler_data*)data; performance_counter_init(&resampler_proc, "resampler_proc"); performance_counter_start(&resampler_proc); - rarch_resampler_process(audio_driver_resampler, - audio_driver_resampler_data, resampler); + + audio_driver_resampler->process(audio_driver_resampler_data, resampler); performance_counter_stop(&resampler_proc); } diff --git a/audio/audio_resampler_driver.h b/audio/audio_resampler_driver.h index 0366d5f872..7f3f995930 100644 --- a/audio/audio_resampler_driver.h +++ b/audio/audio_resampler_driver.h @@ -181,20 +181,6 @@ const char *audio_resampler_driver_find_ident(int index); bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident, double bw_ratio); -/* Convenience macros. - * freep makes sure to set handles to NULL to avoid double-free - * in rarch_resampler_realloc. */ -#define rarch_resampler_freep(backend, handle) do { \ - if (*(backend) && *(handle)) \ - (*backend)->free(*handle); \ - *backend = NULL; \ - *handle = NULL; \ -} while(0) - -#define rarch_resampler_process(backend, handle, data) do { \ - (backend)->process(handle, data); \ -} while(0) - RETRO_END_DECLS #endif diff --git a/audio/test/main.c b/audio/test/main.c index 047095c62f..a322632c53 100644 --- a/audio/test/main.c +++ b/audio/test/main.c @@ -87,7 +87,7 @@ int main(int argc, char *argv[]) data.input_frames = sizeof(input_f) / (2 * sizeof(float)); data.ratio = ratio * rate_mod; - rarch_resampler_process(resampler, re, &data); + resampler->process(re, &data); output_samples = data.output_frames * 2; @@ -97,6 +97,9 @@ int main(int argc, char *argv[]) break; } - rarch_resampler_freep(&resampler, &re); + if (resampler && re) + resampler->free(re); + resampler = NULL; + re = NULL; } diff --git a/audio/test/snr.c b/audio/test/snr.c index a61e6feb14..e3e284a40b 100644 --- a/audio/test/snr.c +++ b/audio/test/snr.c @@ -327,7 +327,7 @@ int main(int argc, char *argv[]) data.input_frames = in_rate * 2; data.ratio = ratio; - rarch_resampler_process(resampler, re, &data); + resampler->process(re, &data); /* We generate 2 seconds worth of audio, however, * only the last second is considered so phase has stabilized. */ @@ -346,7 +346,10 @@ int main(int argc, char *argv[]) res.alias_freq[2] / (float)in_rate, res.alias_power[2]); } - rarch_resampler_freep(&resampler, &re); + if (resampler && re) + resampler->free(re); + resampler = NULL; + re = NULL; free(input); free(output); diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 71ba0550a3..4faff59799 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -762,8 +762,10 @@ static void ffmpeg_free(void *data) if (handle->config.audio_opts) av_dict_free(&handle->config.audio_opts); - rarch_resampler_freep(&handle->audio.resampler, - &handle->audio.resampler_data); + if (handle->audio.resampler && handle->audio.resampler_data) + handle->audio.resampler->free(handle->audio.resampler_data); + handle->audio.resampler = NULL; + handle->audio.resampler_data = NULL; av_free(handle->audio.float_conv); av_free(handle->audio.resample_out); @@ -1188,10 +1190,10 @@ static void ffmpeg_audio_resample(ffmpeg_t *handle, info.input_frames = aud->frames; info.ratio = handle->audio.ratio; - rarch_resampler_process(handle->audio.resampler, - handle->audio.resampler_data, &info); - aud->data = handle->audio.resample_out; - aud->frames = info.output_frames; + handle->audio.resampler->process(handle->audio.resampler_data, &info); + + aud->data = handle->audio.resample_out; + aud->frames = info.output_frames; if (!handle->audio.use_float) {