diff --git a/driver.c b/driver.c index 99caba7330..0f3f1e639d 100644 --- a/driver.c +++ b/driver.c @@ -38,8 +38,6 @@ void driver_free(void) { if (g_driver) free(g_driver); - - g_driver = NULL; } static driver_t *driver_new(void) diff --git a/driver.h b/driver.h index f77af8debf..83e4d3f185 100644 --- a/driver.h +++ b/driver.h @@ -194,7 +194,7 @@ enum typedef struct driver { - const frontend_ctx_driver_t *frontend_ctx; + frontend_ctx_driver_t *frontend_ctx; const ui_companion_driver_t *ui_companion; const audio_driver_t *audio; const video_driver_t *video; diff --git a/frontend/drivers/platform_android.c b/frontend/drivers/platform_android.c index 822532f5cb..1983a69806 100644 --- a/frontend/drivers/platform_android.c +++ b/frontend/drivers/platform_android.c @@ -1048,7 +1048,7 @@ static int frontend_android_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_android = { +frontend_ctx_driver_t frontend_ctx_android = { frontend_android_get_environment_settings, frontend_android_init, frontend_android_deinit, diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 917b35c367..b6fa2c294a 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -223,7 +223,7 @@ static int frontend_ctr_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_ctr = { +frontend_ctx_driver_t frontend_ctx_ctr = { frontend_ctr_get_environment_settings, frontend_ctr_init, frontend_ctr_deinit, diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 23f057f2ab..778157f647 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -609,7 +609,7 @@ static int frontend_darwin_parse_drive_list(void *data) return ret; } -const frontend_ctx_driver_t frontend_ctx_darwin = { +frontend_ctx_driver_t frontend_ctx_darwin = { frontend_darwin_get_environment_settings, NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index f8a1e57d45..2af1113b92 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -409,7 +409,7 @@ static int frontend_gx_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_gx = { +frontend_ctx_driver_t frontend_ctx_gx = { frontend_gx_get_environment_settings, frontend_gx_init, frontend_gx_deinit, diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index fb23e6cb16..71ab01e0e8 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -465,7 +465,7 @@ static void frontend_linux_get_os(char *s, size_t len, int *major, int *minor) strlcpy(s, "Linux", len); } -const frontend_ctx_driver_t frontend_ctx_linux = { +frontend_ctx_driver_t frontend_ctx_linux = { NULL, /* environment_get */ NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_null.c b/frontend/drivers/platform_null.c index 8eefa693fa..f8d051dad2 100644 --- a/frontend/drivers/platform_null.c +++ b/frontend/drivers/platform_null.c @@ -21,7 +21,7 @@ #include #include -const frontend_ctx_driver_t frontend_ctx_null = { +frontend_ctx_driver_t frontend_ctx_null = { NULL, /* environment_get */ NULL, /* init */ NULL, /* deinit */ diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index f7d7dc472d..80927e4a3c 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -57,6 +57,10 @@ static bool multiman_detected = false; static bool exit_spawn = false; static bool exitspawn_start_game = false; +static void frontend_ps3_shutdown(bool unused) +{ + sys_process_exit(0); +} #ifdef HAVE_SYSUTILS static void callback_sysutil_exit(uint64_t status, @@ -73,10 +77,13 @@ static void callback_sysutil_exit(uint64_t status, { case CELL_SYSUTIL_REQUEST_EXITGAME: { + frontend_ctx_driver_t *frontend = frontend_get_ptr(); rarch_system_info_t *system = rarch_system_info_get_ptr(); if (system) system->shutdown = true; + if (frontend) + frontend->shutdown = frontend_ps3_shutdown; } break; } @@ -313,47 +320,12 @@ static void frontend_ps3_deinit(void *data) #endif } -static void frontend_ps3_exec(const char *path, bool should_load_game); - static void frontend_ps3_set_fork(bool exit, bool start_game) { exit_spawn = exitspawn; exitspawn_start_game = start_game; } -static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) -{ -#ifdef HAVE_RARCH_EXEC - bool should_load_game = false; - -#ifndef IS_SALAMANDER - global_t *global = global_get_ptr(); - bool original_verbose = global->verbosity; - global->verbosity = true; - - should_load_game = exitspawn_start_game; - - if (!exit_spawn) - return; -#endif - - frontend_ps3_exec(core_path, should_load_game); - -#ifdef IS_SALAMANDER - cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); - cellSysmoduleLoadModule(CELL_SYSMODULE_FS); - cellSysmoduleLoadModule(CELL_SYSMODULE_IO); -#else - -#endif - -#ifndef IS_SALAMANDER - global->verbosity = original_verbose; -#endif -#endif -} - - static void frontend_ps3_exec(const char *path, bool should_load_game) { unsigned i; @@ -439,6 +411,44 @@ static void frontend_ps3_exec(const char *path, bool should_load_game) #endif } +static void frontend_ps3_exitspawn(char *core_path, size_t core_path_size) +{ +#ifdef HAVE_RARCH_EXEC + bool should_load_game = false; + +#ifndef IS_SALAMANDER + global_t *global = global_get_ptr(); + bool original_verbose = global->verbosity; + global->verbosity = true; + + should_load_game = exitspawn_start_game; + + if (!exit_spawn) + { + frontend_ctx_driver_t *frontend = frontend_get_ptr(); + + if (frontend) + frontend->shutdown = frontend_ps3_shutdown; + return; + } +#endif + + frontend_ps3_exec(core_path, should_load_game); + +#ifdef IS_SALAMANDER + cellSysmoduleUnloadModule(CELL_SYSMODULE_SYSUTIL_GAME); + cellSysmoduleLoadModule(CELL_SYSMODULE_FS); + cellSysmoduleLoadModule(CELL_SYSMODULE_IO); +#endif + +#ifndef IS_SALAMANDER + global->verbosity = original_verbose; +#endif +#endif + + return; +} + static int frontend_ps3_get_rating(void) { return 10; @@ -481,7 +491,7 @@ static int frontend_ps3_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_ps3 = { +frontend_ctx_driver_t frontend_ctx_ps3 = { frontend_ps3_get_environment_settings, frontend_ps3_init, frontend_ps3_deinit, diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 453ddc9fe4..8ed2075a7b 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -290,7 +290,7 @@ static int frontend_psp_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_psp = { +frontend_ctx_driver_t frontend_ctx_psp = { frontend_psp_get_environment_settings, frontend_psp_init, frontend_psp_deinit, diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index e661d04521..20cb293f4e 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -64,7 +64,7 @@ enum frontend_architecture frontend_qnx_get_architecture(void) return FRONTEND_ARCH_ARM; } -const frontend_ctx_driver_t frontend_ctx_qnx = { +frontend_ctx_driver_t frontend_ctx_qnx = { frontend_qnx_get_environment_settings, frontend_qnx_init, NULL, /* deinit */ diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index ce1d59bcdc..d68633ee39 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -227,7 +227,7 @@ static int frontend_win32_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_win32 = { +frontend_ctx_driver_t frontend_ctx_win32 = { NULL, /* environment_get */ frontend_win32_init, NULL, /* deinit */ diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 5bfc2692cc..de5b159138 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -407,7 +407,7 @@ static int frontend_xdk_parse_drive_list(void *data) return 0; } -const frontend_ctx_driver_t frontend_ctx_xdk = { +frontend_ctx_driver_t frontend_ctx_xdk = { frontend_xdk_get_environment_settings, frontend_xdk_init, NULL, /* deinit */ diff --git a/frontend/frontend_driver.c b/frontend/frontend_driver.c index 74885e3cad..6157f9cae7 100644 --- a/frontend/frontend_driver.c +++ b/frontend/frontend_driver.c @@ -22,7 +22,7 @@ #include "../config.h" #endif -static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { +static frontend_ctx_driver_t *frontend_ctx_drivers[] = { #if defined(__CELLOS_LV2__) &frontend_ctx_ps3, #endif @@ -65,7 +65,7 @@ static const frontend_ctx_driver_t *frontend_ctx_drivers[] = { * * Returns: pointer to driver if successful, otherwise NULL. **/ -const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) +frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) { unsigned i; @@ -85,10 +85,10 @@ const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident) * * Returns: pointer to first suitable driver, otherwise NULL. **/ -const frontend_ctx_driver_t *frontend_ctx_init_first(void) +frontend_ctx_driver_t *frontend_ctx_init_first(void) { unsigned i; - const frontend_ctx_driver_t *frontend = NULL; + frontend_ctx_driver_t *frontend = NULL; for (i = 0; frontend_ctx_drivers[i]; i++) { @@ -100,7 +100,7 @@ const frontend_ctx_driver_t *frontend_ctx_init_first(void) } #ifndef IS_SALAMANDER -const frontend_ctx_driver_t *frontend_get_ptr(void) +frontend_ctx_driver_t *frontend_get_ptr(void) { driver_t *driver = driver_get_ptr(); if (!driver) @@ -110,7 +110,7 @@ const frontend_ctx_driver_t *frontend_get_ptr(void) int frontend_driver_parse_drive_list(void *data) { - const frontend_ctx_driver_t *frontend = frontend_get_ptr(); + frontend_ctx_driver_t *frontend = frontend_get_ptr(); if (!frontend || !frontend->parse_drive_list) return -1; diff --git a/frontend/frontend_driver.h b/frontend/frontend_driver.h index 5ae9c9de6e..f082a138a6 100644 --- a/frontend/frontend_driver.h +++ b/frontend/frontend_driver.h @@ -76,17 +76,17 @@ typedef struct frontend_ctx_driver const struct video_driver *(*get_video_driver)(void); } frontend_ctx_driver_t; -extern const frontend_ctx_driver_t frontend_ctx_gx; -extern const frontend_ctx_driver_t frontend_ctx_ps3; -extern const frontend_ctx_driver_t frontend_ctx_xdk; -extern const frontend_ctx_driver_t frontend_ctx_qnx; -extern const frontend_ctx_driver_t frontend_ctx_darwin; -extern const frontend_ctx_driver_t frontend_ctx_android; -extern const frontend_ctx_driver_t frontend_ctx_linux; -extern const frontend_ctx_driver_t frontend_ctx_psp; -extern const frontend_ctx_driver_t frontend_ctx_ctr; -extern const frontend_ctx_driver_t frontend_ctx_win32; -extern const frontend_ctx_driver_t frontend_ctx_null; +extern frontend_ctx_driver_t frontend_ctx_gx; +extern frontend_ctx_driver_t frontend_ctx_ps3; +extern frontend_ctx_driver_t frontend_ctx_xdk; +extern frontend_ctx_driver_t frontend_ctx_qnx; +extern frontend_ctx_driver_t frontend_ctx_darwin; +extern frontend_ctx_driver_t frontend_ctx_android; +extern frontend_ctx_driver_t frontend_ctx_linux; +extern frontend_ctx_driver_t frontend_ctx_psp; +extern frontend_ctx_driver_t frontend_ctx_ctr; +extern frontend_ctx_driver_t frontend_ctx_win32; +extern frontend_ctx_driver_t frontend_ctx_null; /** * frontend_ctx_find_driver: @@ -96,9 +96,9 @@ extern const frontend_ctx_driver_t frontend_ctx_null; * * Returns: pointer to driver if successful, otherwise NULL. **/ -const frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); +frontend_ctx_driver_t *frontend_ctx_find_driver(const char *ident); -const frontend_ctx_driver_t *frontend_get_ptr(void); +frontend_ctx_driver_t *frontend_get_ptr(void); /** * frontend_ctx_init_first: @@ -107,7 +107,7 @@ const frontend_ctx_driver_t *frontend_get_ptr(void); * * Returns: pointer to first suitable driver, otherwise NULL. **/ -const frontend_ctx_driver_t *frontend_ctx_init_first(void); +frontend_ctx_driver_t *frontend_ctx_init_first(void); int frontend_driver_parse_drive_list(void *data); diff --git a/runloop.c b/runloop.c index 932af3b0b3..f44cc3b47a 100644 --- a/runloop.c +++ b/runloop.c @@ -894,7 +894,6 @@ void rarch_main_global_free(void) return; free(g_extern); - g_extern = NULL; } bool rarch_main_verbosity(void)