mirror of
https://github.com/libretro/RetroArch
synced 2025-04-17 11:43:00 +00:00
Update DSP API for config callback.
Clean up API a bit to have separate SSNES_*_API_VERSION defines.
This commit is contained in:
parent
5f5013871a
commit
7f1cd62c8a
@ -81,9 +81,9 @@ static void* audio_ext_init(const char *device, unsigned rate, unsigned latency)
|
||||
|
||||
SSNES_LOG("Loaded external audio driver: \"%s\"\n", ext->driver->ident ? ext->driver->ident : "Unknown");
|
||||
|
||||
if (ext->driver->api_version != SSNES_API_VERSION)
|
||||
if (ext->driver->api_version != SSNES_AUDIO_API_VERSION)
|
||||
{
|
||||
SSNES_ERR("API mismatch in external video plugin. SSNES: %d, Plugin: %d ...\n", SSNES_API_VERSION, ext->driver->api_version);
|
||||
SSNES_ERR("API mismatch in external video plugin. SSNES: %d, Plugin: %d ...\n", SSNES_AUDIO_API_VERSION, ext->driver->api_version);
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
@ -22,12 +22,23 @@ extern "C" {
|
||||
#define SSNES_API_CALLTYPE
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_TRUE
|
||||
#define SSNES_TRUE 1
|
||||
#define SSNES_FALSE 0
|
||||
#define SSNES_OK 1
|
||||
#define SSNES_ERROR 0
|
||||
#endif
|
||||
|
||||
#define SSNES_API_VERSION 1
|
||||
#ifndef SSNES_FALSE
|
||||
#define SSNES_FALSE 0
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_OK
|
||||
#define SSNES_OK 1
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_ERROR
|
||||
#define SSNES_ERROR 0
|
||||
#endif
|
||||
|
||||
#define SSNES_AUDIO_API_VERSION 1
|
||||
|
||||
typedef struct ssnes_audio_driver_info
|
||||
{
|
||||
@ -95,7 +106,7 @@ typedef struct ssnes_audio_driver
|
||||
// Human readable identification string for the driver.
|
||||
const char *ident;
|
||||
|
||||
// Must be set to SSNES_API_VERSION.
|
||||
// Must be set to SSNES_AUDIO_API_VERSION.
|
||||
// Used for detecting API mismatch.
|
||||
int api_version;
|
||||
} ssnes_audio_driver_t;
|
||||
|
@ -22,10 +22,15 @@ extern "C" {
|
||||
#define SSNES_API_CALLTYPE
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_FALSE
|
||||
#define SSNES_FALSE 0
|
||||
#define SSNES_TRUE 1
|
||||
#endif
|
||||
|
||||
#define SSNES_API_VERSION 1
|
||||
#ifndef SSNES_TRUE
|
||||
#define SSNES_TRUE 1
|
||||
#endif
|
||||
|
||||
#define SSNES_DSP_API_VERSION 2
|
||||
|
||||
typedef struct ssnes_dsp_info
|
||||
{
|
||||
@ -89,12 +94,22 @@ typedef struct ssnes_dsp_plugin
|
||||
void (*process)(void *data, ssnes_dsp_output_t *output,
|
||||
const ssnes_dsp_input_t *input);
|
||||
|
||||
// Frees the handle.
|
||||
// Frees the handle.
|
||||
void (*free)(void *data);
|
||||
|
||||
// API version used to compile the plugin.
|
||||
// Used to detect mismatches in API.
|
||||
// Must be set to SSNES_DSP_API_VERSION on compile.
|
||||
int api_version;
|
||||
|
||||
// Signal plugin that it may open a configuring window or
|
||||
// something similiar. The behavior of this function
|
||||
// is thus plugin dependent. Implementing this is optional,
|
||||
// and can be set to NULL.
|
||||
void (*config)(void *data);
|
||||
|
||||
// Human readable identification string.
|
||||
const char *ident;
|
||||
} ssnes_dsp_plugin_t;
|
||||
|
||||
// Called by SSNES at startup to get the callback struct.
|
||||
|
@ -246,6 +246,7 @@ static const struct snes_keybind snes_keybinds_1[] = {
|
||||
{ SSNES_CHEAT_INDEX_MINUS, SDLK_t, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_CHEAT_TOGGLE, SDLK_u, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_SCREENSHOT, SDLK_PRINT, NO_BTN, AXIS_NONE },
|
||||
{ SSNES_DSP_CONFIG, SDLK_c, NO_BTN, AXIS_NONE },
|
||||
{ -1 }
|
||||
};
|
||||
|
||||
|
6
driver.c
6
driver.c
@ -175,12 +175,14 @@ static void init_dsp_plugin(void)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (g_extern.audio_data.dsp_plugin->api_version != SSNES_API_VERSION)
|
||||
if (g_extern.audio_data.dsp_plugin->api_version != SSNES_DSP_API_VERSION)
|
||||
{
|
||||
SSNES_ERR("DSP plugin API mismatch!\n");
|
||||
SSNES_ERR("DSP plugin API mismatch! SSNES: %d, Plugin: %d\n", SSNES_DSP_API_VERSION, g_extern.audio_data.dsp_plugin->api_version);
|
||||
goto error;
|
||||
}
|
||||
|
||||
SSNES_LOG("Loaded DSP plugin: \"%s\"\n", g_extern.audio_data.dsp_plugin->ident ? g_extern.audio_data.dsp_plugin->ident : "Unknown");
|
||||
|
||||
ssnes_dsp_info_t info = {
|
||||
.input_rate = g_settings.audio.in_rate,
|
||||
.output_rate = g_settings.audio.out_rate
|
||||
|
3
driver.h
3
driver.h
@ -45,7 +45,8 @@ enum
|
||||
SSNES_CHEAT_INDEX_PLUS,
|
||||
SSNES_CHEAT_INDEX_MINUS,
|
||||
SSNES_CHEAT_TOGGLE,
|
||||
SSNES_SCREENSHOT
|
||||
SSNES_SCREENSHOT,
|
||||
SSNES_DSP_CONFIG
|
||||
};
|
||||
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
||||
|
||||
|
||||
#define MAX_PLAYERS 5
|
||||
#define MAX_BINDS 32 // Needs to be increased every time there are new binds added.
|
||||
#define MAX_BINDS 33 // Needs to be increased every time there are new binds added.
|
||||
#define SSNES_NO_JOYPAD 0xFFFF
|
||||
|
||||
enum ssnes_shader_type
|
||||
|
@ -217,10 +217,10 @@ static bool setup_video(ext_t *ext, const video_info_t *video, const input_drive
|
||||
{
|
||||
SSNES_LOG("Loaded driver: \"%s\"\n", ext->driver->ident ? ext->driver->ident : "Unknown");
|
||||
|
||||
if (SSNES_API_VERSION != ext->driver->api_version)
|
||||
if (SSNES_GRAPHICS_API_VERSION != ext->driver->api_version)
|
||||
{
|
||||
SSNES_ERR("API version mismatch detected!\n");
|
||||
SSNES_ERR("Required API version: %d, Library version: %d\n", SSNES_API_VERSION, ext->driver->api_version);
|
||||
SSNES_ERR("Required API version: %d, Library version: %d\n", SSNES_GRAPHICS_API_VERSION, ext->driver->api_version);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -22,14 +22,26 @@ extern "C" {
|
||||
#define SSNES_API_CALLTYPE
|
||||
#endif
|
||||
|
||||
#define SSNES_API_VERSION 1
|
||||
#define SSNES_GRAPHICS_API_VERSION 1
|
||||
|
||||
// Since we don't want to rely on C++ or C99 for a proper boolean type,
|
||||
// and make sure return semantics are perfectly clear ... ;)
|
||||
|
||||
#ifndef SSNES_OK
|
||||
#define SSNES_OK 1
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_ERROR
|
||||
#define SSNES_ERROR 0
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_TRUE
|
||||
#define SSNES_TRUE 1
|
||||
#endif
|
||||
|
||||
#ifndef SSNES_FALSE
|
||||
#define SSNES_FALSE 0
|
||||
#endif
|
||||
|
||||
#define SSNES_COLOR_FORMAT_XRGB1555 0
|
||||
#define SSNES_COLOR_FORMAT_ARGB8888 1
|
||||
@ -222,7 +234,7 @@ typedef struct ssnes_video_driver
|
||||
// A human-readable identification of the video driver.
|
||||
const char *ident;
|
||||
|
||||
// Needs to be defined to SSNES_API_VERSION.
|
||||
// Needs to be defined to SSNES_GRAPHICS_API_VERSION.
|
||||
// This is used to detect API mismatches.
|
||||
int api_version;
|
||||
} ssnes_video_driver_t;
|
||||
|
@ -437,6 +437,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
||||
},
|
||||
{
|
||||
DECLARE_BIND(player2_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||
@ -470,6 +471,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
||||
},
|
||||
{
|
||||
DECLARE_BIND(player3_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||
@ -503,6 +505,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
||||
},
|
||||
{
|
||||
DECLARE_BIND(player4_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||
@ -536,6 +539,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
||||
},
|
||||
{
|
||||
DECLARE_BIND(player5_a, SNES_DEVICE_ID_JOYPAD_A)
|
||||
@ -569,6 +573,7 @@ static const struct bind_map bind_maps[MAX_PLAYERS][MAX_BINDS - 1] = {
|
||||
DECLARE_BIND(cheat_index_minus, SSNES_CHEAT_INDEX_MINUS)
|
||||
DECLARE_BIND(cheat_toggle, SSNES_CHEAT_TOGGLE)
|
||||
DECLARE_BIND(screenshot, SSNES_SCREENSHOT)
|
||||
DECLARE_BIND(dsp_config, SSNES_DSP_CONFIG)
|
||||
},
|
||||
};
|
||||
|
||||
|
27
ssnes.c
27
ssnes.c
@ -1347,6 +1347,21 @@ static void check_screenshot(void)
|
||||
old_pressed = pressed;
|
||||
}
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
static void check_dsp_config(void)
|
||||
{
|
||||
if (!g_extern.audio_data.dsp_plugin || !g_extern.audio_data.dsp_plugin->config)
|
||||
return;
|
||||
|
||||
static bool old_pressed = false;
|
||||
bool pressed = driver.input->key_pressed(driver.input_data, SSNES_DSP_CONFIG);
|
||||
if (pressed && !old_pressed)
|
||||
g_extern.audio_data.dsp_plugin->config(g_extern.audio_data.dsp_handle);
|
||||
|
||||
old_pressed = pressed;
|
||||
}
|
||||
#endif
|
||||
|
||||
static void do_state_checks(void)
|
||||
{
|
||||
if (!g_extern.netplay)
|
||||
@ -1374,10 +1389,20 @@ static void do_state_checks(void)
|
||||
#ifdef HAVE_XML
|
||||
check_shader_dir();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
check_dsp_config();
|
||||
#endif
|
||||
}
|
||||
|
||||
check_fullscreen();
|
||||
check_input_rate();
|
||||
|
||||
#ifdef HAVE_DYLIB
|
||||
// DSP plugin doesn't use variable input rate.
|
||||
if (!g_extern.audio_data.dsp_plugin)
|
||||
#endif
|
||||
check_input_rate();
|
||||
|
||||
check_screenshot();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user