Get rid of driver_t and driver_get_ptr

This commit is contained in:
twinaphex 2015-12-05 16:54:03 +01:00
parent 67a0623ebf
commit 5b939e810c
10 changed files with 30 additions and 33 deletions

View File

@ -584,7 +584,6 @@ static bool event_init_content(void)
static bool event_init_core(void)
{
global_t *global = global_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
/* auto overrides: apply overrides */
@ -618,7 +617,7 @@ static bool event_init_core(void)
if (!event_init_content())
return false;
retro_init_libretro_cbs(&driver->retro_ctx);
retro_init_libretro_cbs(&retro_ctx);
rarch_init_system_av_info();
return true;
@ -917,7 +916,6 @@ bool event_command(enum event_command cmd)
{
unsigned i = 0;
bool boolean = false;
driver_t *driver = driver_get_ptr();
global_t *global = global_get_ptr();
settings_t *settings = config_get_ptr();
rarch_system_info_t *info = rarch_system_info_get_ptr();

View File

@ -26,6 +26,7 @@
#include "camera/camera_driver.h"
#include "record/record_driver.h"
#include "location/location_driver.h"
#include "libretro_version_1.h"
#ifdef HAVE_MENU
#include "menu/menu.h"
@ -35,19 +36,12 @@
#include "config.h"
#endif
driver_t *driver_get_ptr(void)
{
static driver_t g_driver;
return &g_driver;
}
void driver_free(void)
{
driver_t *driver = driver_get_ptr();
video_driver_ctl(RARCH_DISPLAY_CTL_DESTROY, NULL);
audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY, NULL);
input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL);
memset(driver, 0, sizeof(driver_t));
retro_uninit_libretro_cbs();
}
void driver_clear_state(void)
@ -360,8 +354,6 @@ static void menu_update_libretro_info(void)
**/
void init_drivers(int flags)
{
driver_t *driver = driver_get_ptr();
if (flags & DRIVER_VIDEO)
video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER, NULL);
if (flags & DRIVER_AUDIO)
@ -436,8 +428,6 @@ void init_drivers(int flags)
**/
void uninit_drivers(int flags)
{
driver_t *driver = driver_get_ptr();
#ifdef HAVE_MENU
if (flags & DRIVER_MENU)
{

View File

@ -26,7 +26,6 @@
#include <retro_miscellaneous.h>
#include "libretro_private.h"
#include "libretro_version_1.h"
#ifdef HAVE_CONFIG_H
#include "config.h"
@ -192,11 +191,6 @@ enum
* Typically, if a driver intends to make use of this, it should
* set this to true at the end of its 'init' function. */
typedef struct driver
{
struct retro_callbacks retro_ctx;
} driver_t;
/**
* init_drivers:
* @flags : Bitmask of drivers to initialize.
@ -295,8 +289,6 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info);
**/
int find_driver_index(const char * label, const char *drv);
driver_t *driver_get_ptr(void);
void driver_free(void);
void driver_clear_state(void);

View File

@ -29,6 +29,7 @@
#include "../general.h"
#include "../performance.h"
#include "../string_list_special.h"
#include "../libretro_version_1.h"
#ifdef HAVE_MENU
#include "../menu/menu_hash.h"
@ -1136,7 +1137,6 @@ void video_driver_set_pixel_format(enum retro_pixel_format fmt)
**/
static bool video_driver_cached_frame(void)
{
driver_t *driver = driver_get_ptr();
void *recording = recording_driver_get_data_ptr();
if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL))
@ -1149,8 +1149,8 @@ static bool video_driver_cached_frame(void)
* freed the memory, but no known implementations do this.
* It would be really stupid at any rate ...
*/
if (driver->retro_ctx.frame_cb)
driver->retro_ctx.frame_cb(
if (retro_ctx.frame_cb)
retro_ctx.frame_cb(
(video_driver_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID)
? NULL : video_driver_state.frame_cache.data,
video_driver_state.frame_cache.width,

View File

@ -34,6 +34,8 @@
#include "netplay.h"
#endif
struct retro_callbacks retro_ctx;
/**
* retro_set_default_callbacks:
* @data : pointer to retro_callbacks object
@ -54,6 +56,17 @@ void retro_set_default_callbacks(void *data)
cbs->poll_cb = input_poll;
}
void retro_uninit_libretro_cbs(void)
{
struct retro_callbacks *cbs = (struct retro_callbacks*)&retro_ctx;
cbs->frame_cb = NULL;
cbs->sample_cb = NULL;
cbs->sample_batch_cb = NULL;
cbs->state_cb = NULL;
cbs->poll_cb = NULL;
}
/**
* retro_init_libretro_cbs:
* @data : pointer to retro_callbacks object

View File

@ -33,6 +33,8 @@ typedef struct retro_callbacks
retro_input_poll_t poll_cb;
} retro_callbacks_t;
retro_callbacks_t retro_ctx;
/**
* retro_init_libretro_cbs:
* @data : pointer to retro_callbacks object
@ -73,6 +75,8 @@ void retro_set_rewind_callbacks(void);
**/
bool retro_flush_audio(const int16_t *data, size_t samples);
void retro_uninit_libretro_cbs(void);
#ifdef __cplusplus
}
#endif

View File

@ -36,6 +36,7 @@
#include "../general.h"
#include "../cheats.h"
#include "../performance.h"
#include "../libretro_version_1.h"
#include "../input/input_joypad_driver.h"
#include "../input/input_remapping.h"
#include "../input/input_config.h"
@ -1183,14 +1184,13 @@ unsigned menu_input_frame_retropad(retro_input_t input, retro_input_t trigger_in
bool set_scroll = false;
size_t new_scroll_accel = 0;
menu_input_t *menu_input = menu_input_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
if (!driver || !menu_input)
if (!menu_input)
return 0;
if (driver->retro_ctx.poll_cb)
driver->retro_ctx.poll_cb();
if (retro_ctx.poll_cb)
retro_ctx.poll_cb();
/* don't run anything first frame, only capture held inputs
* for old_input_state. */

View File

@ -281,7 +281,6 @@ bool recording_init(void)
char recording_file[PATH_MAX_LENGTH] = {0};
struct ffemu_params params = {0};
global_t *global = global_get_ptr();
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
struct retro_system_av_info *av_info = video_viewport_get_system_av_info();
const struct retro_hw_render_callback *hw_render =

View File

@ -25,6 +25,7 @@
#include "msg_hash.h"
#include "rewind.h"
#include "movie.h"
#include "libretro_version_1.h"
#include "performance.h"
#include "verbosity.h"
#include "audio/audio_driver.h"

View File

@ -46,6 +46,7 @@
#include "record/record_driver.h"
#include "input/input_driver.h"
#include "ui/ui_companion_driver.h"
#include "libretro_version_1.h"
#include "msg_hash.h"
@ -1017,7 +1018,6 @@ int rarch_main_iterate(unsigned *sleep_ms)
static retro_time_t frame_limit_minimum_time = 0.0;
static retro_time_t frame_limit_last_time = 0.0;
static retro_input_t last_input = 0;
driver_t *driver = driver_get_ptr();
settings_t *settings = config_get_ptr();
global_t *global = global_get_ptr();
retro_input_t input = input_keys_pressed();
@ -1157,7 +1157,7 @@ int rarch_main_iterate(unsigned *sleep_ms)
if (!runloop_ctl(RUNLOOP_CTL_CHECK_STATE, &cmd))
{
/* RetroArch has been paused. */
driver->retro_ctx.poll_cb();
retro_ctx.poll_cb();
*sleep_ms = 10;
return 1;
}