Make resampler code more export-friendly

This commit is contained in:
twinaphex 2014-09-23 07:20:10 +02:00
parent 75bc44fc8e
commit 3ad9cb5182
3 changed files with 31 additions and 37 deletions

View File

@ -1,6 +1,8 @@
#include "resampler.h"
#ifdef RARCH_INTERNAL
#include "../../libretro.h"
#include "../../performance.h"
#endif
#include <math.h>
#include <stdint.h>
#include <stdlib.h>

View File

@ -20,17 +20,9 @@
#include "../../config.h"
#endif
#include "../../general.h"
#if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL)
#include "../../general.h"
#endif
static const rarch_resampler_t *resampler_drivers[] = {
&sinc_resampler,
#ifdef HAVE_CC_RESAMPLER
&CC_resampler,
#endif
&nearest_resampler,
NULL,
};
@ -44,6 +36,32 @@ static int find_resampler_driver_index(const char *driver)
return -1;
}
#if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL)
#include "../../general.h"
void find_prev_resampler_driver(void)
{
int i = find_resampler_driver_index(g_settings.audio.resampler);
if (i > 0)
strlcpy(g_settings.audio.resampler, resampler_drivers[i - 1]->ident,
sizeof(g_settings.audio.resampler));
else
RARCH_WARN("Couldn't find any previous resampler driver (current one: \"%s\").\n",
g_extern.audio_data.resampler->ident);
}
void find_next_resampler_driver(void)
{
int i = find_resampler_driver_index(g_settings.audio.resampler);
if (i >= 0 && resampler_drivers[i + 1])
strlcpy(g_settings.audio.resampler, resampler_drivers[i + 1]->ident,
sizeof(g_settings.audio.resampler));
else
RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n",
g_extern.audio_data.resampler->ident);
}
#endif
/* Resampler is used by multiple modules so avoid
* clobbering g_extern.audio_data.resampler here. */
@ -68,34 +86,6 @@ static const rarch_resampler_t *find_resampler_driver(const char *ident)
}
}
#ifndef RESAMPLER_TEST
void find_prev_resampler_driver(void)
{
int i = find_resampler_driver_index(g_settings.audio.resampler);
if (i > 0)
strlcpy(g_settings.audio.resampler, resampler_drivers[i - 1]->ident,
sizeof(g_settings.audio.resampler));
#ifdef RARCH_INTERNAL
else
RARCH_WARN("Couldn't find any previous resampler driver (current one: \"%s\").\n",
g_extern.audio_data.resampler->ident);
#endif
}
void find_next_resampler_driver(void)
{
int i = find_resampler_driver_index(g_settings.audio.resampler);
if (i >= 0 && resampler_drivers[i + 1])
strlcpy(g_settings.audio.resampler, resampler_drivers[i + 1]->ident,
sizeof(g_settings.audio.resampler));
#ifdef RARCH_INTERNAL
else
RARCH_WARN("Couldn't find any next resampler driver (current one: \"%s\").\n",
g_extern.audio_data.resampler->ident);
#endif
}
#endif
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
const char *ident, double bw_ratio)
{

View File

@ -16,8 +16,8 @@
/* Bog-standard windowed SINC implementation. */
#include "resampler.h"
#ifdef RARCH_INTERNAL
#include "../../libretro.h"
#ifndef RARCH_INTERNAL
#include "../../performance.h"
#endif
#include <math.h>
@ -25,7 +25,9 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#ifdef _WIN32
#include "../../msvc/msvc_compat.h"
#endif
#if !defined(RESAMPLER_TEST) && defined(RARCH_INTERNAL)
#include "../../general.h"