Turn content_get_status into content_get_flags

This commit is contained in:
LibretroAdmin 2022-10-09 20:32:39 +02:00
parent d3384fd89d
commit 479e3b23d9
8 changed files with 62 additions and 88 deletions

View File

@ -1321,12 +1321,8 @@ static void audio_driver_mixer_play_stream_internal(
static void audio_driver_load_menu_bgm_callback(retro_task_t *task, static void audio_driver_load_menu_bgm_callback(retro_task_t *task,
void *task_data, void *user_data, const char *error) void *task_data, void *user_data, const char *error)
{ {
bool contentless = false; uint8_t flags = content_get_flags();
bool is_inited = false; if (!(flags & CONTENT_ST_FLAG_IS_INITED))
content_get_status(&contentless, &is_inited);
if (!is_inited)
audio_driver_mixer_play_menu_sound_looped(AUDIO_MIXER_SYSTEM_SLOT_BGM); audio_driver_mixer_play_menu_sound_looped(AUDIO_MIXER_SYSTEM_SLOT_BGM);
} }

View File

@ -797,35 +797,35 @@ uint8_t *command_memory_get_pointer(
bool command_get_status(command_t *cmd, const char* arg) bool command_get_status(command_t *cmd, const char* arg)
{ {
char reply[4096] = {0}; char reply[4096];
bool contentless = false; uint8_t flags = content_get_flags();
bool is_inited = false;
runloop_state_t *runloop_st = runloop_state_get_ptr();
content_get_status(&contentless, &is_inited); if (flags & CONTENT_ST_FLAG_IS_INITED)
if (!is_inited)
strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
else
{ {
/* add some content info */ /* add some content info */
const char *status = "PLAYING"; runloop_state_t *runloop_st = runloop_state_get_ptr();
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */ const char *status = "PLAYING";
int content_crc32 = content_get_crc(); const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
const char* system_id = NULL; int content_crc32 = content_get_crc();
core_info_t *core_info = NULL; const char* system_id = NULL;
core_info_t *core_info = NULL;
core_info_get_current_core(&core_info); reply[0] = '\0';
if (runloop_st->paused) core_info_get_current_core(&core_info);
status = "PAUSED";
if (core_info)
system_id = core_info->system_id;
if (!system_id)
system_id = runloop_st->system.info.library_name;
snprintf(reply, sizeof(reply), "GET_STATUS %s %s,%s,crc32=%x\n", status, system_id, content_name, content_crc32); if (runloop_st->paused)
status = "PAUSED";
if (core_info)
system_id = core_info->system_id;
if (!system_id)
system_id = runloop_st->system.info.library_name;
snprintf(reply, sizeof(reply), "GET_STATUS %s %s,%s,crc32=%x\n",
status, system_id, content_name, content_crc32);
} }
else
strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
cmd->replier(cmd, reply, strlen(reply)); cmd->replier(cmd, reply, strlen(reply));

View File

@ -84,8 +84,7 @@ bool content_undo_load_state(void);
/* Restores the last savestate file which was overwritten */ /* Restores the last savestate file which was overwritten */
bool content_undo_save_state(void); bool content_undo_save_state(void);
void content_get_status(bool *contentless, uint8_t content_get_flags(void);
bool *is_inited);
void content_set_does_not_need_content(void); void content_set_does_not_need_content(void);

View File

@ -1880,13 +1880,10 @@ bool command_event(enum event_command cmd, void *data)
case CMD_EVENT_UNLOAD_CORE: case CMD_EVENT_UNLOAD_CORE:
{ {
bool load_dummy_core = data ? *(bool*)data : true; bool load_dummy_core = data ? *(bool*)data : true;
bool contentless = false;
bool is_inited = false;
content_ctx_info_t content_info = {0}; content_ctx_info_t content_info = {0};
global_t *global = global_get_ptr(); global_t *global = global_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system; rarch_system_info_t *sys_info = &runloop_st->system;
uint8_t flags = content_get_flags();
content_get_status(&contentless, &is_inited);
runloop_st->core_running = false; runloop_st->core_running = false;
@ -1941,11 +1938,15 @@ bool command_event(enum event_command cmd, void *data)
video_driver_restore_cached(settings); video_driver_restore_cached(settings);
if (is_inited && load_dummy_core) if ( (flags & CONTENT_ST_FLAG_IS_INITED)
&& load_dummy_core)
{ {
#ifdef HAVE_MENU #ifdef HAVE_MENU
if ( (settings->uints.quit_on_close_content == QUIT_ON_CLOSE_CONTENT_CLI && global->launched_from_cli) if ( ((settings->uints.quit_on_close_content ==
|| settings->uints.quit_on_close_content == QUIT_ON_CLOSE_CONTENT_ENABLED QUIT_ON_CLOSE_CONTENT_CLI)
&& global->launched_from_cli)
|| (settings->uints.quit_on_close_content ==
QUIT_ON_CLOSE_CONTENT_ENABLED)
) )
command_event(CMD_EVENT_QUIT, NULL); command_event(CMD_EVENT_QUIT, NULL);
#endif #endif
@ -1971,7 +1972,7 @@ bool command_event(enum event_command cmd, void *data)
audio_st->callback.callback = NULL; audio_st->callback.callback = NULL;
audio_st->callback.set_state = NULL; audio_st->callback.set_state = NULL;
} }
if (is_inited) if (flags & CONTENT_ST_FLAG_IS_INITED)
{ {
runloop_st->subsystem_current_count = 0; runloop_st->subsystem_current_count = 0;
content_clear_subsystem(); content_clear_subsystem();

View File

@ -4024,12 +4024,11 @@ static void runloop_clear_controller_port_map(void)
static bool secondary_core_create(runloop_state_t *runloop_st, static bool secondary_core_create(runloop_state_t *runloop_st,
settings_t *settings) settings_t *settings)
{ {
bool contentless = false;
bool is_inited = false;
const enum rarch_core_type const enum rarch_core_type
last_core_type = runloop_st->last_core_type; last_core_type = runloop_st->last_core_type;
rarch_system_info_t *info = &runloop_st->system; rarch_system_info_t *info = &runloop_st->system;
unsigned num_active_users = settings->uints.input_max_users; unsigned num_active_users = settings->uints.input_max_users;
uint8_t flags = content_get_flags();
if ( last_core_type != CORE_TYPE_PLAIN || if ( last_core_type != CORE_TYPE_PLAIN ||
!runloop_st->load_content_info || !runloop_st->load_content_info ||
@ -4062,8 +4061,7 @@ static bool secondary_core_create(runloop_state_t *runloop_st,
runloop_st->secondary_core.retro_init(); runloop_st->secondary_core.retro_init();
content_get_status(&contentless, &is_inited); runloop_st->secondary_core.inited = (flags & CONTENT_ST_FLAG_IS_INITED);
runloop_st->secondary_core.inited = is_inited;
/* Load Content */ /* Load Content */
/* disabled due to crashes */ /* disabled due to crashes */
@ -4080,7 +4078,7 @@ static bool secondary_core_create(runloop_state_t *runloop_st,
if (!runloop_st->secondary_core.game_loaded) if (!runloop_st->secondary_core.game_loaded)
goto error; goto error;
} }
else if (contentless) else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
{ {
runloop_st->secondary_core.game_loaded = runloop_st->secondary_core.game_loaded =
runloop_st->secondary_core.retro_load_game(NULL); runloop_st->secondary_core.retro_load_game(NULL);
@ -5137,8 +5135,6 @@ static bool event_init_content(
input_driver_state_t *input_st) input_driver_state_t *input_st)
{ {
runloop_state_t *runloop_st = &runloop_state; runloop_state_t *runloop_st = &runloop_state;
bool contentless = false;
bool is_inited = false;
#ifdef HAVE_CHEEVOS #ifdef HAVE_CHEEVOS
bool cheevos_enable = bool cheevos_enable =
settings->bools.cheevos_enable; settings->bools.cheevos_enable;
@ -5146,8 +5142,7 @@ static bool event_init_content(
settings->bools.cheevos_hardcore_mode_enable; settings->bools.cheevos_hardcore_mode_enable;
#endif #endif
const enum rarch_core_type current_core_type = runloop_st->current_core_type; const enum rarch_core_type current_core_type = runloop_st->current_core_type;
uint8_t flags = content_get_flags();
content_get_status(&contentless, &is_inited);
runloop_st->use_sram = (current_core_type == CORE_TYPE_PLAIN); runloop_st->use_sram = (current_core_type == CORE_TYPE_PLAIN);
@ -5158,12 +5153,10 @@ static bool event_init_content(
content_set_subsystem_info(); content_set_subsystem_info();
content_get_status(&contentless, &is_inited);
/* If core is contentless, just initialise SRAM /* If core is contentless, just initialise SRAM
* interface, otherwise fill all content-related * interface, otherwise fill all content-related
* paths */ * paths */
if (contentless) if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
runloop_path_init_savefile_internal(); runloop_path_init_savefile_internal();
else else
runloop_path_fill_names(); runloop_path_fill_names();
@ -8387,10 +8380,9 @@ bool core_get_memory(retro_ctx_memory_info_t *info)
bool core_load_game(retro_ctx_load_content_info_t *load_info) bool core_load_game(retro_ctx_load_content_info_t *load_info)
{ {
bool contentless = false;
bool is_inited = false;
bool game_loaded = false; bool game_loaded = false;
runloop_state_t *runloop_st = &runloop_state; runloop_state_t *runloop_st = &runloop_state;
uint8_t flags = content_get_flags();
video_driver_set_cached_frame_ptr(NULL); video_driver_set_cached_frame_ptr(NULL);
@ -8399,7 +8391,6 @@ bool core_load_game(retro_ctx_load_content_info_t *load_info)
runloop_clear_controller_port_map(); runloop_clear_controller_port_map();
#endif #endif
content_get_status(&contentless, &is_inited);
set_save_state_in_background(false); set_save_state_in_background(false);
if (load_info && load_info->special) if (load_info && load_info->special)
@ -8407,7 +8398,7 @@ bool core_load_game(retro_ctx_load_content_info_t *load_info)
load_info->special->id, load_info->info, load_info->content->size); load_info->special->id, load_info->info, load_info->content->size);
else if (load_info && !string_is_empty(load_info->content->elems[0].data)) else if (load_info && !string_is_empty(load_info->content->elems[0].data))
game_loaded = runloop_st->current_core.retro_load_game(load_info->info); game_loaded = runloop_st->current_core.retro_load_game(load_info->info);
else if (contentless) else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
game_loaded = runloop_st->current_core.retro_load_game(NULL); game_loaded = runloop_st->current_core.retro_load_game(NULL);
runloop_st->current_core.game_loaded = game_loaded; runloop_st->current_core.game_loaded = game_loaded;

View File

@ -1252,19 +1252,17 @@ static void content_file_set_attributes(
} }
else else
{ {
const char *content_path = path_get(RARCH_PATH_CONTENT);
bool contentless = false;
bool is_inited = false;
union string_list_elem_attr attr; union string_list_elem_attr attr;
const char *content_path = path_get(RARCH_PATH_CONTENT);
content_get_status(&contentless, &is_inited); uint8_t flags = content_get_flags();
CONTENT_FILE_ATTR_RESET(attr); CONTENT_FILE_ATTR_RESET(attr);
CONTENT_FILE_ATTR_SET_BLOCK_EXTRACT(attr, content_ctx->flags & CONTENT_FILE_ATTR_SET_BLOCK_EXTRACT(attr, content_ctx->flags &
CONTENT_INFO_FLAG_BLOCK_EXTRACT); CONTENT_INFO_FLAG_BLOCK_EXTRACT);
CONTENT_FILE_ATTR_SET_NEED_FULLPATH(attr, content_ctx->flags & CONTENT_FILE_ATTR_SET_NEED_FULLPATH(attr, content_ctx->flags &
CONTENT_INFO_FLAG_NEED_FULLPATH); CONTENT_INFO_FLAG_NEED_FULLPATH);
CONTENT_FILE_ATTR_SET_REQUIRED(attr, !contentless); CONTENT_FILE_ATTR_SET_REQUIRED(attr, (!(flags &
CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)));
#if defined(HAVE_RUNAHEAD) #if defined(HAVE_RUNAHEAD)
/* If runahead is supported and we are not using /* If runahead is supported and we are not using
@ -1277,8 +1275,9 @@ CONTENT_INFO_FLAG_NEED_FULLPATH);
if (string_is_empty(content_path)) if (string_is_empty(content_path))
{ {
if (contentless && if ( (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
content_ctx->flags & CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE) && content_ctx->flags
& CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE)
string_list_append(content, "", attr); string_list_append(content, "", attr);
} }
else else
@ -1553,14 +1552,12 @@ static void task_push_to_history_list(
bool launched_from_cli, bool launched_from_cli,
bool launched_from_companion_ui) bool launched_from_companion_ui)
{ {
bool contentless = false;
bool is_inited = false;
runloop_state_t *runloop_st = runloop_state_get_ptr(); runloop_state_t *runloop_st = runloop_state_get_ptr();
uint8_t flags = content_get_flags();
content_get_status(&contentless, &is_inited);
/* Push entry to top of history playlist */ /* Push entry to top of history playlist */
if (is_inited || contentless) if ( (flags & CONTENT_ST_FLAG_IS_INITED)
|| (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT))
{ {
char tmp[PATH_MAX_LENGTH]; char tmp[PATH_MAX_LENGTH];
const char *path_content = path_get(RARCH_PATH_CONTENT); const char *path_content = path_get(RARCH_PATH_CONTENT);
@ -2764,15 +2761,10 @@ bool task_push_load_subsystem_with_core(
#endif #endif
} }
void content_get_status( uint8_t content_get_flags(void)
bool *contentless,
bool *is_inited)
{ {
content_state_t *p_content = content_state_get_ptr(); content_state_t *p_content = content_state_get_ptr();
return p_content->flags;
*contentless = (p_content->flags &
CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT);
*is_inited = (p_content->flags & CONTENT_ST_FLAG_IS_INITED);
} }
/* Clears the pending subsystem rom buffer*/ /* Clears the pending subsystem rom buffer*/

View File

@ -865,7 +865,7 @@ bool task_push_netplay_content_reload(const char *hostname)
struct netplay_crc_scan_data *data; struct netplay_crc_scan_data *data;
retro_task_t *task; retro_task_t *task;
const char *pcore; const char *pcore;
bool contentless, is_inited; uint8_t flags;
/* Do not run more than one CRC scan task at a time. */ /* Do not run more than one CRC scan task at a time. */
if (scan_state.running) if (scan_state.running)
@ -875,8 +875,8 @@ bool task_push_netplay_content_reload(const char *hostname)
if (string_is_empty(pcore) || string_is_equal(pcore, "builtin")) if (string_is_empty(pcore) || string_is_equal(pcore, "builtin"))
return false; /* Nothing to reload. */ return false; /* Nothing to reload. */
data = (struct netplay_crc_scan_data*)calloc(1, sizeof(*data)); data = (struct netplay_crc_scan_data*)calloc(1, sizeof(*data));
task = task_init(); task = task_init();
if (!data || !task) if (!data || !task)
{ {
@ -894,12 +894,10 @@ bool task_push_netplay_content_reload(const char *hostname)
if (hostname) if (hostname)
strlcpy(data->hostname, hostname, sizeof(data->hostname)); strlcpy(data->hostname, hostname, sizeof(data->hostname));
content_get_status(&contentless, &is_inited); flags = content_get_flags();
if (contentless) if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
{
scan_state.state |= STATE_LOAD_CONTENTLESS; scan_state.state |= STATE_LOAD_CONTENTLESS;
} else if (flags & CONTENT_ST_FLAG_IS_INITED)
else if (is_inited)
{ {
const char *psubsystem = path_get(RARCH_PATH_SUBSYSTEM); const char *psubsystem = path_get(RARCH_PATH_SUBSYSTEM);

View File

@ -3637,12 +3637,9 @@ TreeView* MainWindow::dirTreeView()
void MainWindow::onTimeout() void MainWindow::onTimeout()
{ {
bool contentless = false; uint8_t flags = content_get_flags();
bool is_inited = false;
content_get_status(&contentless, &is_inited); if (flags & CONTENT_ST_FLAG_IS_INITED)
if (is_inited)
{ {
if (m_runPushButton->isVisible()) if (m_runPushButton->isVisible())
m_runPushButton->hide(); m_runPushButton->hide();