From 202e204fd7e2bf2fd94bd55d1b65d7f15dc62427 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 8 Feb 2013 11:50:45 +0100 Subject: [PATCH] Add resampler.c. --- audio/resampler.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 audio/resampler.c diff --git a/audio/resampler.c b/audio/resampler.c new file mode 100644 index 0000000000..8ee2f3e36a --- /dev/null +++ b/audio/resampler.c @@ -0,0 +1,66 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2013 - Hans-Kristian Arntzen + * + * RetroArch is free software: you can redistribute it and/or modify it under the terms + * of the GNU General Public License as published by the Free Software Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR + * PURPOSE. See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . + */ + +#include "resampler.h" +#include + +#ifdef HAVE_CONFIG_H +#include "../config.h" +#endif + +#include "../general.h" + +static const rarch_resampler_t *backends[] = { +#ifdef HAVE_SINC + &sinc_resampler, +#endif + &hermite_resampler, +}; + +bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, const char *ident) +{ + if (*re && *backend) + (*backend)->free(*re); + + *re = NULL; + *backend = NULL; + + if (ident) + { + for (unsigned i = 0; i < ARRAY_SIZE(backends); i++) + { + if (strcmp(backends[i]->ident, ident) == 0) + { + *backend = backends[i]; + break; + } + } + } + else + *backend = backends[0]; + + if (!*backend) + return false; + + *re = (*backend)->init(); + if (!*re) + { + *backend = NULL; + return false; + } + + return true; +} +