Purge some now useless code.

Removes manual input rate adjustments.
Don't allow DSP plugs to resample as it would complicate things alot
with dynamic rate control.
Also purges optional ssnes_* symbols for external plugs.
This commit is contained in:
Themaister 2012-10-13 20:22:45 +02:00
parent 6fd1940741
commit b8abf34785
14 changed files with 28 additions and 181 deletions

View File

@ -285,10 +285,7 @@ ifeq ($(HAVE_SINC), 1)
else
OBJ += audio/hermite.o
endif
ifneq ($(HAVE_FIXED_POINT), 1)
OBJ += audio/utils.o
endif
OBJ += audio/utils.o
ifneq ($(V),1)
Q := @

View File

@ -30,7 +30,7 @@ extern "C" {
#define RARCH_TRUE 1
#endif
#define RARCH_DSP_API_VERSION 3
#define RARCH_DSP_API_VERSION 4
typedef struct rarch_dsp_info
{
@ -61,14 +61,6 @@ typedef struct rarch_dsp_output
// (I.e. 44.1kHz, 16bit stereo will have
// 88.2k samples/sec and 44.1k frames/sec.)
unsigned frames;
// If true, the DSP plugin did not resample the input audio,
// and requests resampling to the proper frequency to be
// performed outside the plugin.
// If false,
// it is assumed that the output has the same sample rate as given
// in output_rate.
int should_resample;
} rarch_dsp_output_t;
typedef struct rarch_dsp_input

View File

@ -66,8 +66,6 @@ static void *audio_ext_init(const char *device, unsigned rate, unsigned latency)
}
plugin_load = (const rarch_audio_driver_t *(*)(void))dylib_proc(ext->lib, "rarch_audio_driver_init");
if (!plugin_load)
plugin_load = (const rarch_audio_driver_t *(*)(void))dylib_proc(ext->lib, "ssnes_audio_driver_init"); // Compat. Will be dropped on ABI break.
if (!plugin_load)
{

View File

@ -84,11 +84,7 @@ static void init_sinc_table(rarch_resampler_t *resamp)
double sinc_phase = M_PI * (p + (SIDELOBES - 1 - j));
float val = CUTOFF * sinc(CUTOFF * sinc_phase) * lanzcos(sinc_phase / SIDELOBES);
#ifdef HAVE_FIXED_POINT
resamp->phase_table[i][PHASE_INDEX][j] = (int16_t)(val * 0x7fff);
#else
resamp->phase_table[i][PHASE_INDEX][j] = val;
#endif
}
}
@ -97,13 +93,8 @@ static void init_sinc_table(rarch_resampler_t *resamp)
{
for (int j = 0; j < TAPS; j++)
{
#ifdef HAVE_FIXED_POINT
resamp->phase_table[i][DELTA_INDEX][j] =
(resamp->phase_table[i + 1][PHASE_INDEX][j] - resamp->phase_table[i][PHASE_INDEX][j]);
#else
resamp->phase_table[i][DELTA_INDEX][j] =
(resamp->phase_table[i + 1][PHASE_INDEX][j] - resamp->phase_table[i][PHASE_INDEX][j]) / SUBPHASES;
#endif
}
}
@ -114,11 +105,7 @@ static void init_sinc_table(rarch_resampler_t *resamp)
double sinc_phase = M_PI * (p + (SIDELOBES - 1 - j));
double phase = CUTOFF * sinc(CUTOFF * sinc_phase) * lanzcos(sinc_phase / SIDELOBES);
#ifdef HAVE_FIXED_POINT
int16_t result = 0x7fff * phase - resamp->phase_table[PHASES - 1][PHASE_INDEX][j];
#else
float result = (phase - resamp->phase_table[PHASES - 1][PHASE_INDEX][j]) / SUBPHASES;
#endif
resamp->phase_table[PHASES - 1][DELTA_INDEX][j] = result;
}
@ -154,9 +141,7 @@ rarch_resampler_t *resampler_new(void)
init_sinc_table(re);
#ifdef HAVE_FIXED_POINT
RARCH_LOG("Sinc resampler [Fixed]\n");
#elif __SSE__
#ifdef __SSE__
RARCH_LOG("Sinc resampler [SSE]\n");
#else
RARCH_LOG("Sinc resampler [C]\n");
@ -165,41 +150,7 @@ rarch_resampler_t *resampler_new(void)
return re;
}
#ifdef HAVE_FIXED_POINT
static inline int16_t saturate(int32_t val)
{
if (val > 0x7fff)
return 0x7fff;
else if (val < -0x8000)
return -0x8000;
else
return val;
}
static void process_sinc(rarch_resampler_t *resamp, int16_t *out_buffer)
{
int32_t sum_l = 0;
int32_t sum_r = 0;
const int16_t *buffer_l = resamp->buffer_l + resamp->ptr;
const int16_t *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned phase = resamp->time >> PHASES_SHIFT;
unsigned delta = (resamp->time >> SUBPHASES_SHIFT) & SUBPHASES_MASK;
const int16_t *phase_table = resamp->phase_table[phase][PHASE_INDEX];
const int16_t *delta_table = resamp->phase_table[phase][DELTA_INDEX];
for (unsigned i = 0; i < TAPS; i++)
{
int16_t sinc_val = phase_table[i] + ((delta * delta_table[i] + 0x4000) >> 15);
sum_l += (buffer_l[i] * sinc_val + 0x4000) >> 15;
sum_r += (buffer_r[i] * sinc_val + 0x4000) >> 15;
}
out_buffer[0] = saturate(sum_l);
out_buffer[1] = saturate(sum_r);
}
#elif __SSE__
#ifdef __SSE__
static void process_sinc(rarch_resampler_t *resamp, float *out_buffer)
{
__m128 sum_l = _mm_setzero_ps();

View File

@ -185,8 +185,6 @@ static const struct cmd_map map[] = {
{ "QUIT", RARCH_QUIT_KEY },
{ "STATE_SLOT_PLUS", RARCH_STATE_SLOT_PLUS },
{ "STATE_SLOT_MINUS", RARCH_STATE_SLOT_MINUS },
{ "AUDIO_INPUT_RATE_PLUS", RARCH_AUDIO_INPUT_RATE_PLUS },
{ "AUDIO_INPUT_RATE_MINUS", RARCH_AUDIO_INPUT_RATE_MINUS },
{ "REWIND", RARCH_REWIND },
{ "MOVIE_RECORD_TOGGLE", RARCH_MOVIE_RECORD_TOGGLE },
{ "PAUSE_TOGGLE", RARCH_PAUSE_TOGGLE },

View File

@ -368,8 +368,6 @@ static const struct retro_keybind retro_keybinds_1[] = {
{ true, RARCH_QUIT_KEY, RETROK_ESCAPE, NO_BTN, AXIS_NONE },
{ true, RARCH_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, AXIS_NONE },
{ true, RARCH_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, AXIS_NONE },
{ true, RARCH_AUDIO_INPUT_RATE_PLUS, RETROK_KP_PLUS, NO_BTN, AXIS_NONE },
{ true, RARCH_AUDIO_INPUT_RATE_MINUS, RETROK_KP_MINUS, NO_BTN, AXIS_NONE },
{ true, RARCH_REWIND, RETROK_r, NO_BTN, AXIS_NONE },
{ true, RARCH_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, AXIS_NONE },
{ true, RARCH_PAUSE_TOGGLE, RETROK_p, NO_BTN, AXIS_NONE },

View File

@ -269,8 +269,6 @@ static void init_dsp_plugin(void)
const rarch_dsp_plugin_t* (RARCH_API_CALLTYPE *plugin_init)(void) =
(const rarch_dsp_plugin_t *(RARCH_API_CALLTYPE*)(void))dylib_proc(g_extern.audio_data.dsp_lib, "rarch_dsp_plugin_init");
if (!plugin_init)
plugin_init = (const rarch_dsp_plugin_t *(RARCH_API_CALLTYPE*)(void))dylib_proc(g_extern.audio_data.dsp_lib, "ssnes_dsp_plugin_init"); // Compat. Will be dropped on ABI break.
if (!plugin_init)
{

View File

@ -69,8 +69,6 @@ enum // RetroArch specific bind IDs.
RARCH_QUIT_KEY,
RARCH_STATE_SLOT_PLUS,
RARCH_STATE_SLOT_MINUS,
RARCH_AUDIO_INPUT_RATE_PLUS,
RARCH_AUDIO_INPUT_RATE_MINUS,
RARCH_REWIND,
RARCH_MOVIE_RECORD_TOGGLE,
RARCH_PAUSE_TOGGLE,

View File

@ -350,8 +350,6 @@ static void *video_ext_init(const video_info_t *video, const input_driver_t **in
}
video_init = (const rarch_video_driver_t *(*)(void))dylib_proc(g_lib, "rarch_video_init");
if (!video_init)
video_init = (const rarch_video_driver_t *(*)(void))dylib_proc(g_lib, "ssnes_video_init"); // Compat. Will be dropped on ABI break.
if (!video_init)
{

View File

@ -138,8 +138,6 @@ static void py_set_attrs(PyObject *mod)
DECL_ATTR_RARCH(QUIT_KEY);
DECL_ATTR_RARCH(STATE_SLOT_PLUS);
DECL_ATTR_RARCH(STATE_SLOT_MINUS);
DECL_ATTR_RARCH(AUDIO_INPUT_RATE_PLUS);
DECL_ATTR_RARCH(AUDIO_INPUT_RATE_MINUS);
DECL_ATTR_RARCH(REWIND);
DECL_ATTR_RARCH(MOVIE_RECORD_TOGGLE);
DECL_ATTR_RARCH(PAUSE_TOGGLE);

View File

@ -185,6 +185,6 @@ check_pkgconf PYTHON python3
add_define_make OS "$OS"
# Creates config.mk and config.h.
VARS="ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL GLES VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG XML SDL_IMAGE LIBPNG DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL CONFIGFILE FREETYPE XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 SINC FIXED_POINT BSV_MOVIE VIDEOCORE"
VARS="ALSA OSS OSS_BSD OSS_LIB AL RSOUND ROAR JACK COREAUDIO PULSE SDL OPENGL GLES VG EGL KMS GBM DRM DYLIB GETOPT_LONG THREADS CG XML SDL_IMAGE LIBPNG DYNAMIC FFMPEG AVCODEC AVFORMAT AVUTIL CONFIGFILE FREETYPE XVIDEO X11 XEXT XF86VM XINERAMA NETPLAY NETWORK_CMD STDIN_CMD COMMAND SOCKET_LEGACY FBO STRL PYTHON FFMPEG_ALLOC_CONTEXT3 FFMPEG_AVCODEC_OPEN2 FFMPEG_AVIO_OPEN FFMPEG_AVFORMAT_WRITE_HEADER FFMPEG_AVFORMAT_NEW_STREAM FFMPEG_AVCODEC_ENCODE_AUDIO2 FFMPEG_AVCODEC_ENCODE_VIDEO2 SINC BSV_MOVIE VIDEOCORE"
create_config_make config.mk $VARS
create_config_header config.h $VARS

View File

@ -30,5 +30,4 @@ HAVE_SDL_IMAGE=auto # Enable SDL_image support
HAVE_LIBPNG=auto # Enable libpng support
HAVE_PYTHON=auto # Enable Python 3 support for shaders
HAVE_SINC=yes # Disable SINC resampler
HAVE_FIXED_POINT=no # Enable fixed-point resampler
HAVE_BSV_MOVIE=yes # Disable BSV movie support

View File

@ -325,7 +325,7 @@ static bool audio_flush(const int16_t *data, size_t samples)
}
#endif
if (g_extern.is_paused)
if (g_extern.is_paused || g_extern.audio_data.mute)
return true;
if (!g_extern.audio_active)
return false;
@ -333,79 +333,42 @@ static bool audio_flush(const int16_t *data, size_t samples)
const sample_t *output_data = NULL;
unsigned output_frames = 0;
#ifndef HAVE_FIXED_POINT
struct resampler_data src_data = {0};
audio_convert_s16_to_float(g_extern.audio_data.data, data, samples);
#endif
#if defined(HAVE_DYLIB) && !defined(HAVE_FIXED_POINT)
#if defined(HAVE_DYLIB)
rarch_dsp_output_t dsp_output = {0};
dsp_output.should_resample = RARCH_TRUE;
rarch_dsp_input_t dsp_input = {0};
dsp_input.samples = g_extern.audio_data.data;
dsp_input.frames = samples >> 1;
rarch_dsp_input_t dsp_input = {0};
dsp_input.samples = g_extern.audio_data.data;
dsp_input.frames = samples >> 1;
if (g_extern.audio_data.dsp_plugin)
g_extern.audio_data.dsp_plugin->process(g_extern.audio_data.dsp_handle, &dsp_output, &dsp_input);
if (dsp_output.should_resample)
{
#endif
struct resampler_data src_data = {0};
#ifdef HAVE_FIXED_POINT
src_data.data_in = data;
src_data.input_frames = samples >> 1;
#elif defined(HAVE_DYLIB)
src_data.data_in = dsp_output.samples ? dsp_output.samples : g_extern.audio_data.data;
src_data.input_frames = dsp_output.samples ? dsp_output.frames : (samples >> 1);
src_data.data_in = dsp_output.samples ? dsp_output.samples : g_extern.audio_data.data;
src_data.input_frames = dsp_output.samples ? dsp_output.frames : (samples >> 1);
#else
src_data.data_in = g_extern.audio_data.data;
src_data.input_frames = samples >> 1;
src_data.data_in = g_extern.audio_data.data;
src_data.input_frames = samples >> 1;
#endif
src_data.data_out = g_extern.audio_data.outsamples;
src_data.data_out = g_extern.audio_data.outsamples;
if (g_extern.audio_data.rate_control)
readjust_audio_input_rate();
if (g_extern.audio_data.rate_control)
readjust_audio_input_rate();
src_data.ratio = g_extern.audio_data.src_ratio;
if (g_extern.is_slowmotion)
src_data.ratio *= g_settings.slowmotion_ratio;
src_data.ratio = g_extern.audio_data.src_ratio;
if (g_extern.is_slowmotion)
src_data.ratio *= g_settings.slowmotion_ratio;
resampler_process(g_extern.audio_data.source, &src_data);
resampler_process(g_extern.audio_data.source, &src_data);
output_data = g_extern.audio_data.outsamples;
output_frames = src_data.output_frames;
#if defined(HAVE_DYLIB) && !defined(HAVE_FIXED_POINT)
}
else
{
output_data = dsp_output.samples;
output_frames = dsp_output.frames;
}
#endif
output_data = g_extern.audio_data.outsamples;
output_frames = src_data.output_frames;
union
{
float f[0x10000];
int16_t i[0x10000 * sizeof(float) / sizeof(int16_t)];
} static empty_buf; // Const here would require us to statically initialize it, bloating the binary.
#ifdef HAVE_FIXED_POINT
if (g_extern.audio_data.mute)
output_data = empty_buf.i;
if (audio_write_func(output_data, output_frames * sizeof(int16_t) * 2) < 0)
{
RARCH_ERR("Audio backend failed to write. Will continue without sound.\n");
return false;
}
#else
if (g_extern.audio_data.use_float)
{
if (audio_write_func(g_extern.audio_data.mute ? empty_buf.f : output_data,
output_frames * sizeof(float) * 2) < 0)
if (audio_write_func(output_data, output_frames * sizeof(float) * 2) < 0)
{
RARCH_ERR("Audio backend failed to write. Will continue without sound.\n");
return false;
@ -413,20 +376,15 @@ static bool audio_flush(const int16_t *data, size_t samples)
}
else
{
if (!g_extern.audio_data.mute)
{
audio_convert_float_to_s16(g_extern.audio_data.conv_outsamples,
output_data, output_frames * 2);
}
audio_convert_float_to_s16(g_extern.audio_data.conv_outsamples,
output_data, output_frames * 2);
if (audio_write_func(g_extern.audio_data.mute ? empty_buf.i : g_extern.audio_data.conv_outsamples,
output_frames * sizeof(int16_t) * 2) < 0)
if (audio_write_func(g_extern.audio_data.conv_outsamples, output_frames * sizeof(int16_t) * 2) < 0)
{
RARCH_ERR("Audio backend failed to write. Will continue without sound.\n");
return false;
}
}
#endif
return true;
}
@ -1985,34 +1943,6 @@ static void check_stateslots(void)
old_should_slot_decrease = should_slot_decrease;
}
static void check_input_rate(void)
{
bool display = false;
if (input_key_pressed_func(RARCH_AUDIO_INPUT_RATE_PLUS))
{
g_settings.audio.in_rate += g_settings.audio.rate_step;
display = true;
}
else if (input_key_pressed_func(RARCH_AUDIO_INPUT_RATE_MINUS))
{
g_settings.audio.in_rate -= g_settings.audio.rate_step;
display = true;
}
if (display)
{
char msg[256];
snprintf(msg, sizeof(msg), "Audio input rate: %.2f Hz", g_settings.audio.in_rate);
msg_queue_clear(g_extern.msg_queue);
msg_queue_push(g_extern.msg_queue, msg, 1, 180);
RARCH_LOG("%s\n", msg);
g_extern.audio_data.src_ratio =
(double)g_settings.audio.out_rate / g_settings.audio.in_rate;
}
}
static inline void flush_rewind_audio(void)
{
if (g_extern.frame_is_reverse) // We just rewound. Flush rewind audio buffer.
@ -2511,12 +2441,6 @@ static void do_state_checks(void)
#endif
}
#endif
#ifdef HAVE_DYLIB
// DSP plugin doesn't use variable input rate.
if (!g_extern.audio_data.dsp_plugin)
#endif
check_input_rate();
}
static void init_state(void)

View File

@ -599,8 +599,6 @@ static const struct bind_map bind_maps[MAX_PLAYERS][RARCH_BIND_LIST_END_NULL] =
DECLARE_BIND(exit_emulator, RARCH_QUIT_KEY),
DECLARE_BIND(state_slot_increase, RARCH_STATE_SLOT_PLUS),
DECLARE_BIND(state_slot_decrease, RARCH_STATE_SLOT_MINUS),
DECLARE_BIND(rate_step_up, RARCH_AUDIO_INPUT_RATE_PLUS),
DECLARE_BIND(rate_step_down, RARCH_AUDIO_INPUT_RATE_MINUS),
DECLARE_BIND(rewind, RARCH_REWIND),
DECLARE_BIND(movie_record_toggle, RARCH_MOVIE_RECORD_TOGGLE),
DECLARE_BIND(pause_toggle, RARCH_PAUSE_TOGGLE),