Add shutdown to frontend_context.c - bake frontend_context in for all versions

This commit is contained in:
twinaphex 2013-07-27 16:36:55 +02:00
parent 78f757e0dc
commit 40d5fcc472
8 changed files with 52 additions and 74 deletions

View File

@ -3,6 +3,7 @@ include config.mk
TARGET = retroarch tools/retroarch-joyconfig tools/retrolaunch/retrolaunch
OBJ = frontend/frontend.o \
frontend/frontend_context.o \
retroarch.o \
file.o \
file_path.o \

View File

@ -2,6 +2,7 @@ TARGET = retroarch.exe
JTARGET = tools/retroarch-joyconfig.exe
OBJ = frontend/frontend.o \
frontend/frontend_context.o \
retroarch.o \
file.o \
file_path.o \

View File

@ -18,10 +18,8 @@
#include "../conf/config_file.h"
#include "../file.h"
#if defined(RARCH_CONSOLE)
#include "frontend_context.h"
frontend_ctx_driver_t *frontend_ctx;
#endif
#if defined(__QNX__)
#include <bps/bps.h>
@ -94,17 +92,6 @@ static bool libretro_install_core(const char *path_prefix,
}
#endif
static void system_preinit(void)
{
#if defined(__QNX__) && !defined(HAVE_BB10)
//Initialize BPS libraries
bps_initialize();
#elif defined(RARCH_CONSOLE)
if (frontend_ctx->init)
frontend_ctx->init();
#endif
}
static void rarch_get_environment(int argc, char *argv[])
{
#if defined(__QNX__) && !defined(HAVE_BB10)
@ -125,7 +112,7 @@ static void rarch_get_environment(int argc, char *argv[])
#endif
g_extern.verbose = true;
if (frontend_ctx->get_environment_settings)
if (frontend_ctx && frontend_ctx->get_environment_settings)
frontend_ctx->get_environment_settings(argc, argv);
MAKE_DIR(default_paths.port_dir, "port_dir");
@ -184,16 +171,6 @@ static void system_shutdown(void)
#endif
}
static int system_ctx_init(void)
{
#ifdef RARCH_CONSOLE
if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL)
return -1;
#endif
return 0;
}
#if defined(__APPLE__)
static pthread_mutex_t apple_event_queue_lock = PTHREAD_MUTEX_INITIALIZER;
@ -250,10 +227,16 @@ void* rarch_main(void* args)
int rarch_main(int argc, char *argv[])
#endif
{
if (system_ctx_init() != 0)
return 0;
if ((frontend_ctx = (frontend_ctx_driver_t*)frontend_ctx_init_first()) == NULL)
RARCH_WARN("Could not find valid frontend context.\n");
system_preinit();
#if defined(__QNX__) && !defined(HAVE_BB10)
//Initialize BPS libraries
bps_initialize();
#endif
if (frontend_ctx && frontend_ctx->init)
frontend_ctx->init();
#if !defined(__APPLE__)
rarch_main_clear_state();
@ -290,9 +273,10 @@ int rarch_main(int argc, char *argv[])
menu_init();
#ifdef RARCH_CONSOLE
if (frontend_ctx->process_args)
if (frontend_ctx && frontend_ctx->process_args)
frontend_ctx->process_args(argc, argv);
#ifdef RARCH_CONSOLE
g_extern.lifecycle_mode_state |= 1ULL << MODE_LOAD_GAME;
#else
g_extern.lifecycle_mode_state |= 1ULL << MODE_GAME;
@ -336,10 +320,9 @@ int rarch_main(int argc, char *argv[])
{
#ifdef RARCH_CONSOLE
driver.input->poll(NULL);
#endif
if (driver.video_poke->set_aspect_ratio)
driver.video_poke->set_aspect_ratio(driver.video_data, g_settings.video.aspect_ratio_idx);
#endif
while ((g_extern.is_paused && !g_extern.is_oneshot) ? rarch_main_idle_iterate() : rarch_main_iterate())
{
@ -413,7 +396,6 @@ int rarch_main(int argc, char *argv[])
rarch_perf_log();
#endif
#ifdef RARCH_CONSOLE
#if defined(HAVE_LOGGER)
logger_shutdown();
#elif defined(HAVE_FILE_LOGGER)
@ -421,12 +403,13 @@ int rarch_main(int argc, char *argv[])
fclose(g_extern.log_file);
g_extern.log_file = NULL;
#endif
if (frontend_ctx->deinit)
if (frontend_ctx && frontend_ctx->deinit)
frontend_ctx->deinit();
if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN) && frontend_ctx->exitspawn)
if (g_extern.lifecycle_mode_state & (1ULL << MODE_EXITSPAWN) && frontend_ctx
&& frontend_ctx->exitspawn)
frontend_ctx->exitspawn();
#endif
rarch_main_clear_state();

View File

@ -40,6 +40,7 @@ typedef struct frontend_ctx_driver
int (*process_args)(int argc, char *argv[]);
void (*exec)(const char *, bool);
void (*shutdown)(bool);
// Human readable string.
const char *ident;

View File

@ -444,11 +444,13 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath)
argv->length = len;
DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length);
}
#endif
// WARNING: after we move any data into EXECUTE_ADDR, we can no longer use any
// heap memory and are restricted to the stack only
static void system_exec(const char *path, bool should_load_game)
{
#ifdef HW_RVL
char game_path[PATH_MAX];
RARCH_LOG("Attempt to load executable: [%s] %d.\n", path, sizeof(game_path));
@ -507,19 +509,16 @@ static void system_exec(const char *path, bool should_load_game)
RARCH_LOG("jumping to %08x\n", (unsigned) BOOTER_ADDR);
SYS_ResetSystem(SYS_SHUTDOWN,0,0);
__lwp_thread_stopmultitasking((void (*)(void)) BOOTER_ADDR);
}
#endif
}
const frontend_ctx_driver_t frontend_ctx_gx = {
get_environment_settings,
system_init,
system_deinit,
system_exitspawn,
system_process_args,
#ifdef HW_RVL
system_exec,
#else
NULL,
#endif
get_environment_settings, /* get_environment_settings */
system_init, /* init */
system_deinit, /* deinit */
system_exitspawn, /* exitspawn */
system_process_args, /* process_args */
system_exec, /* exec */
NULL, /* shutdown */
"gx",
};

View File

@ -110,13 +110,9 @@ static void salamander_init_settings(void)
}
if (!config_file_exists || !strcmp(default_paths.libretro_path, ""))
{
find_and_set_first_file();
}
else
{
RARCH_LOG("Start [%s] found in retroarch.cfg.\n", default_paths.libretro_path);
}
if (!config_file_exists)
{
@ -469,11 +465,12 @@ static void system_exec(const char *path, bool should_load_game)
}
const frontend_ctx_driver_t frontend_ctx_ps3 = {
get_environment_settings,
system_init,
system_deinit,
system_exitspawn,
system_process_args,
system_exec,
get_environment_settings, /* get_environment_settings */
system_init, /* init */
system_deinit, /* deinit */
system_exitspawn, /* exitspawn */
system_process_args, /* process_args */
system_exec, /* exec */
NULL, /* shutdown */
"ps3",
};

View File

@ -109,16 +109,13 @@ static void system_deinit(void)
sceKernelExitGame();
}
static void system_exitspawn(void)
{
}
const frontend_ctx_driver_t frontend_ctx_xdk = {
get_environment_settings,
system_init,
system_deinit,
system_exitspawn,
system_process_args,
NULL,
get_environment_settings, /* get_environment_settings */
system_init, /* init */
system_deinit, /* deinit */
NULL, /* exitspawn */
system_process_args, /* process_args */
NULL, /* exec */
NULL, /* shutdown */
"psp",
};

View File

@ -299,8 +299,6 @@ static int system_process_args(int argc, char *argv[])
return 0;
}
static void system_deinit(void) {}
static void system_exitspawn(void)
{
#ifdef IS_SALAMANDER
@ -351,11 +349,12 @@ static void system_exec(const char *path, bool should_load_game)
}
const frontend_ctx_driver_t frontend_ctx_xdk = {
get_environment_settings,
system_init,
system_deinit,
system_exitspawn,
system_process_args,
system_exec,
get_environment_settings, /* get_environment_settings */
system_init, /* init */
NULL, /* deinit */
system_exitspawn, /* exitspawn */
system_process_args, /* process_args */
system_exec, /* exec */
NULL, /* shutdown */
"xdk",
};