Get rid of some unnecessary function callback wrapper functions

This commit is contained in:
twinaphex 2017-05-21 09:30:32 +02:00
parent 0bb1de9561
commit a0924a414f
4 changed files with 26 additions and 53 deletions

14
core.h
View File

@ -141,14 +141,6 @@ typedef struct retro_ctx_environ_info
retro_environment_t env; retro_environment_t env;
} retro_ctx_environ_info_t; } retro_ctx_environ_info_t;
typedef struct retro_ctx_frame_info
{
const void *data;
unsigned width;
unsigned height;
size_t pitch;
} retro_ctx_frame_info_t;
typedef struct retro_callbacks typedef struct retro_callbacks
{ {
retro_video_refresh_t frame_cb; retro_video_refresh_t frame_cb;
@ -185,10 +177,6 @@ bool core_unload_game(void);
bool core_reset(void); bool core_reset(void);
void core_frame(retro_ctx_frame_info_t *info);
bool core_poll(void);
bool core_set_environment(retro_ctx_environ_info_t *info); bool core_set_environment(retro_ctx_environ_info_t *info);
bool core_serialize_size(retro_ctx_size_info_t *info); bool core_serialize_size(retro_ctx_size_info_t *info);
@ -249,6 +237,8 @@ bool core_is_inited(void);
bool core_is_game_loaded(void); bool core_is_game_loaded(void);
extern struct retro_callbacks retro_ctx;
RETRO_END_DECLS RETRO_END_DECLS
#endif #endif

View File

@ -44,9 +44,22 @@
#include "gfx/video_driver.h" #include "gfx/video_driver.h"
#include "audio/audio_driver.h" #include "audio/audio_driver.h"
static struct retro_callbacks retro_ctx; struct retro_callbacks retro_ctx;
struct retro_core_t current_core; struct retro_core_t current_core;
static void retro_run_null(void)
{
}
static void retro_frame_null(const void *data, unsigned width,
unsigned height, size_t pitch)
{
}
static void retro_input_poll_null(void)
{
}
static void core_input_state_poll_maybe(void) static void core_input_state_poll_maybe(void)
{ {
if (current_core.poll_type == POLL_TYPE_NORMAL) if (current_core.poll_type == POLL_TYPE_NORMAL)
@ -133,11 +146,11 @@ bool core_deinit(void *data)
if (!cbs) if (!cbs)
return false; return false;
cbs->frame_cb = NULL; cbs->frame_cb = retro_frame_null;
cbs->sample_cb = NULL; cbs->sample_cb = NULL;
cbs->sample_batch_cb = NULL; cbs->sample_batch_cb = NULL;
cbs->state_cb = NULL; cbs->state_cb = NULL;
cbs->poll_cb = NULL; cbs->poll_cb = retro_input_poll_null;
current_core.inited = false; current_core.inited = false;
@ -244,10 +257,6 @@ void core_uninit_symbols(void)
current_core.symbols_inited = false; current_core.symbols_inited = false;
} }
static void retro_run_null(void)
{
}
bool core_init_symbols(enum rarch_core_type *type) bool core_init_symbols(enum rarch_core_type *type)
{ {
if (!type) if (!type)
@ -308,9 +317,7 @@ bool core_get_system_info(struct retro_system_info *system)
bool core_unserialize(retro_ctx_serialize_info_t *info) bool core_unserialize(retro_ctx_serialize_info_t *info)
{ {
if (!info) if (!info || !current_core.retro_unserialize(info->data_const, info->size))
return false;
if (!current_core.retro_unserialize(info->data_const, info->size))
return false; return false;
#if HAVE_NETWORKING #if HAVE_NETWORKING
@ -322,9 +329,7 @@ bool core_unserialize(retro_ctx_serialize_info_t *info)
bool core_serialize(retro_ctx_serialize_info_t *info) bool core_serialize(retro_ctx_serialize_info_t *info)
{ {
if (!info) if (!info || !current_core.retro_serialize(info->data, info->size))
return false;
if (!current_core.retro_serialize(info->data, info->size))
return false; return false;
return true; return true;
} }
@ -347,21 +352,6 @@ void core_set_serialization_quirks(uint64_t quirks)
current_core.serialization_quirks_v = quirks; current_core.serialization_quirks_v = quirks;
} }
void core_frame(retro_ctx_frame_info_t *info)
{
if (retro_ctx.frame_cb)
retro_ctx.frame_cb(
info->data, info->width, info->height, info->pitch);
}
bool core_poll(void)
{
if (!retro_ctx.poll_cb)
return false;
retro_ctx.poll_cb();
return true;
}
bool core_set_environment(retro_ctx_environ_info_t *info) bool core_set_environment(retro_ctx_environ_info_t *info)
{ {
if (!info) if (!info)

View File

@ -1363,23 +1363,16 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt)
**/ **/
bool video_driver_cached_frame(void) bool video_driver_cached_frame(void)
{ {
retro_ctx_frame_info_t info;
void *recording = recording_driver_get_data_ptr(); void *recording = recording_driver_get_data_ptr();
/* Cannot allow recording when pushing duped frames. */ /* Cannot allow recording when pushing duped frames. */
recording_data = NULL; recording_data = NULL;
/* Not 100% safe, since the library might have retro_ctx.frame_cb(
* freed the memory, but no known implementations do this. (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID)
* It would be really stupid at any rate ... ? frame_cache_data : NULL,
*/ frame_cache_width,
info.data = (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID) frame_cache_height, frame_cache_pitch);
? frame_cache_data : NULL;
info.width = frame_cache_width;
info.height = frame_cache_height;
info.pitch = frame_cache_pitch;
core_frame(&info);
recording_data = recording; recording_data = recording;

View File

@ -2664,7 +2664,7 @@ int runloop_iterate(unsigned *sleep_ms)
unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS)); unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS));
uint64_t current_input = 0; uint64_t current_input = 0;
core_poll(); retro_ctx.poll_cb();
current_input = current_input =
#ifdef HAVE_MENU #ifdef HAVE_MENU