diff --git a/content.c b/content.c index 269034ca5d..89b2cb763a 100644 --- a/content.c +++ b/content.c @@ -828,10 +828,6 @@ static void content_load_init_wrap( /** * content_load: - * @argc : Argument count. - * @argv : Argument variable list. - * @args : Arguments passed from callee. - * @environ_get : Function passed for environment_get function. * * Loads content file and starts up RetroArch. * If no content file can be loaded, will start up RetroArch @@ -839,16 +835,15 @@ static void content_load_init_wrap( * * Returns: false (0) if rarch_main_init failed, otherwise true (1). **/ -bool content_load(int argc, char **argv, void *args, - environment_get_t environ_get) +static bool content_load(content_ctx_info_t *info) { unsigned i; bool retval = true; int rarch_argc = 0; char *rarch_argv[MAX_ARGS] = {NULL}; char *argv_copy [MAX_ARGS] = {NULL}; - char **rarch_argv_ptr = (char**)argv; - int *rarch_argc_ptr = (int*)&argc; + char **rarch_argv_ptr = (char**)info->argv; + int *rarch_argc_ptr = (int*)&info->argc; struct rarch_main_wrap *wrap_args = (struct rarch_main_wrap*) calloc(1, sizeof(*wrap_args)); @@ -857,8 +852,9 @@ bool content_load(int argc, char **argv, void *args, retro_assert(wrap_args); - if (environ_get) - environ_get(rarch_argc_ptr, rarch_argv_ptr, args, wrap_args); + if (info->environ_get) + info->environ_get(rarch_argc_ptr, + rarch_argv_ptr, info->args, wrap_args); if (wrap_args->touched) { @@ -1761,6 +1757,8 @@ bool content_ctl(enum content_ctl_state state, void *data) stream->a, stream->b, stream->c); } break; + case CONTENT_CTL_LOAD: + return content_load((content_ctx_info_t*)data); case CONTENT_CTL_NONE: default: break; diff --git a/content.h b/content.h index 978626150e..f06eed1688 100644 --- a/content.h +++ b/content.h @@ -46,6 +46,11 @@ enum content_ctl_state CONTENT_CTL_DEINIT, + /* Loads content file and starts up RetroArch. + * If no content file can be loaded, will start up RetroArch + * as-is. */ + CONTENT_CTL_LOAD, + CONTENT_CTL_GET_CRC, /* Load a RAM state from disk to memory. */ @@ -82,21 +87,13 @@ typedef struct content_stream uint32_t crc; } content_stream_t; -/** - * main_load_content: - * @argc : Argument count. - * @argv : Argument variable list. - * @args : Arguments passed from callee. - * @environ_get : Function passed for environment_get function. - * - * Loads content file and starts up RetroArch. - * If no content file can be loaded, will start up RetroArch - * as-is. - * - * Returns: false (0) if rarch_main_init failed, otherwise true (1). - **/ -bool content_load(int argc, char **argv, - void *args, environment_get_t environ_get); +typedef struct content_ctx_info +{ + int argc; /* Argument count. */ + char **argv; /* Argument variable list. */ + void *args; /* Arguments passed from callee */ + environment_get_t environ_get; /* Function passed for environment_get function */ +} content_ctx_info_t; void content_push_to_history_playlist(bool do_push, const char *path, void *data); diff --git a/frontend/frontend.c b/frontend/frontend.c index 0eddcc29d0..33ee3c3877 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -117,11 +117,15 @@ int rarch_main(int argc, char *argv[], void *data) if (frontend_driver_is_inited()) { - ret = content_load(argc, argv, args, - frontend_driver_environment_get_ptr()); + content_ctx_info_t info; - if (!ret) - return ret; + info.argc = argc; + info.argv = argv; + info.args = args; + info.environ_get = frontend_driver_environment_get_ptr(); + + if (!content_ctl(CONTENT_CTL_LOAD, &info)) + return 0; } runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); diff --git a/menu/menu_content.c b/menu/menu_content.c index 78c3108911..f92c3c330f 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -85,6 +85,7 @@ static void menu_content_environment_get(int *argc, char *argv[], static bool menu_content_load(void) { + content_ctx_info_t content_info; char name[PATH_MAX_LENGTH]; char msg[PATH_MAX_LENGTH]; bool msg_force = true; @@ -98,7 +99,12 @@ static bool menu_content_load(void) if (*fullpath) fill_pathname_base(name, fullpath, sizeof(name)); - if (!(content_load(0, NULL, NULL, menu_content_environment_get))) + content_info.argc = 0; + content_info.argv = NULL; + content_info.args = NULL; + content_info.environ_get = menu_content_environment_get; + + if (!content_ctl(CONTENT_CTL_LOAD, &content_info)) goto error; if (*fullpath)