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,
void *task_data, void *user_data, const char *error)
{
bool contentless = false;
bool is_inited = false;
content_get_status(&contentless, &is_inited);
if (!is_inited)
uint8_t flags = content_get_flags();
if (!(flags & CONTENT_ST_FLAG_IS_INITED))
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)
{
char reply[4096] = {0};
bool contentless = false;
bool is_inited = false;
runloop_state_t *runloop_st = runloop_state_get_ptr();
char reply[4096];
uint8_t flags = content_get_flags();
content_get_status(&contentless, &is_inited);
if (!is_inited)
strlcpy(reply, "GET_STATUS CONTENTLESS", sizeof(reply));
else
if (flags & CONTENT_ST_FLAG_IS_INITED)
{
/* add some content info */
const char *status = "PLAYING";
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
int content_crc32 = content_get_crc();
const char* system_id = NULL;
core_info_t *core_info = NULL;
/* add some content info */
runloop_state_t *runloop_st = runloop_state_get_ptr();
const char *status = "PLAYING";
const char *content_name = path_basename(path_get(RARCH_PATH_BASENAME)); /* filename only without ext */
int content_crc32 = content_get_crc();
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)
status = "PAUSED";
if (core_info)
system_id = core_info->system_id;
if (!system_id)
system_id = runloop_st->system.info.library_name;
core_info_get_current_core(&core_info);
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));

View File

@ -84,8 +84,7 @@ bool content_undo_load_state(void);
/* Restores the last savestate file which was overwritten */
bool content_undo_save_state(void);
void content_get_status(bool *contentless,
bool *is_inited);
uint8_t content_get_flags(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:
{
bool load_dummy_core = data ? *(bool*)data : true;
bool contentless = false;
bool is_inited = false;
content_ctx_info_t content_info = {0};
global_t *global = global_get_ptr();
rarch_system_info_t *sys_info = &runloop_st->system;
content_get_status(&contentless, &is_inited);
uint8_t flags = content_get_flags();
runloop_st->core_running = false;
@ -1941,11 +1938,15 @@ bool command_event(enum event_command cmd, void *data)
video_driver_restore_cached(settings);
if (is_inited && load_dummy_core)
if ( (flags & CONTENT_ST_FLAG_IS_INITED)
&& load_dummy_core)
{
#ifdef HAVE_MENU
if ( (settings->uints.quit_on_close_content == QUIT_ON_CLOSE_CONTENT_CLI && global->launched_from_cli)
|| settings->uints.quit_on_close_content == QUIT_ON_CLOSE_CONTENT_ENABLED
if ( ((settings->uints.quit_on_close_content ==
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);
#endif
@ -1971,7 +1972,7 @@ bool command_event(enum event_command cmd, void *data)
audio_st->callback.callback = NULL;
audio_st->callback.set_state = NULL;
}
if (is_inited)
if (flags & CONTENT_ST_FLAG_IS_INITED)
{
runloop_st->subsystem_current_count = 0;
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,
settings_t *settings)
{
bool contentless = false;
bool is_inited = false;
const enum rarch_core_type
last_core_type = runloop_st->last_core_type;
rarch_system_info_t *info = &runloop_st->system;
unsigned num_active_users = settings->uints.input_max_users;
uint8_t flags = content_get_flags();
if ( last_core_type != CORE_TYPE_PLAIN ||
!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();
content_get_status(&contentless, &is_inited);
runloop_st->secondary_core.inited = is_inited;
runloop_st->secondary_core.inited = (flags & CONTENT_ST_FLAG_IS_INITED);
/* Load Content */
/* 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)
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.retro_load_game(NULL);
@ -5137,8 +5135,6 @@ static bool event_init_content(
input_driver_state_t *input_st)
{
runloop_state_t *runloop_st = &runloop_state;
bool contentless = false;
bool is_inited = false;
#ifdef HAVE_CHEEVOS
bool cheevos_enable =
settings->bools.cheevos_enable;
@ -5146,8 +5142,7 @@ static bool event_init_content(
settings->bools.cheevos_hardcore_mode_enable;
#endif
const enum rarch_core_type current_core_type = runloop_st->current_core_type;
content_get_status(&contentless, &is_inited);
uint8_t flags = content_get_flags();
runloop_st->use_sram = (current_core_type == CORE_TYPE_PLAIN);
@ -5158,12 +5153,10 @@ static bool event_init_content(
content_set_subsystem_info();
content_get_status(&contentless, &is_inited);
/* If core is contentless, just initialise SRAM
* interface, otherwise fill all content-related
* paths */
if (contentless)
if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
runloop_path_init_savefile_internal();
else
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 contentless = false;
bool is_inited = false;
bool game_loaded = false;
runloop_state_t *runloop_st = &runloop_state;
uint8_t flags = content_get_flags();
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();
#endif
content_get_status(&contentless, &is_inited);
set_save_state_in_background(false);
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);
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);
else if (contentless)
else if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
game_loaded = runloop_st->current_core.retro_load_game(NULL);
runloop_st->current_core.game_loaded = game_loaded;

View File

@ -1252,19 +1252,17 @@ static void content_file_set_attributes(
}
else
{
const char *content_path = path_get(RARCH_PATH_CONTENT);
bool contentless = false;
bool is_inited = false;
union string_list_elem_attr attr;
content_get_status(&contentless, &is_inited);
const char *content_path = path_get(RARCH_PATH_CONTENT);
uint8_t flags = content_get_flags();
CONTENT_FILE_ATTR_RESET(attr);
CONTENT_FILE_ATTR_SET_BLOCK_EXTRACT(attr, content_ctx->flags &
CONTENT_INFO_FLAG_BLOCK_EXTRACT);
CONTENT_FILE_ATTR_SET_NEED_FULLPATH(attr, content_ctx->flags &
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 runahead is supported and we are not using
@ -1277,8 +1275,9 @@ CONTENT_INFO_FLAG_NEED_FULLPATH);
if (string_is_empty(content_path))
{
if (contentless &&
content_ctx->flags & CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE)
if ( (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
&& content_ctx->flags
& CONTENT_INFO_FLAG_SET_SUPPORTS_NO_GAME_ENABLE)
string_list_append(content, "", attr);
}
else
@ -1553,14 +1552,12 @@ static void task_push_to_history_list(
bool launched_from_cli,
bool launched_from_companion_ui)
{
bool contentless = false;
bool is_inited = false;
runloop_state_t *runloop_st = runloop_state_get_ptr();
content_get_status(&contentless, &is_inited);
uint8_t flags = content_get_flags();
/* 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];
const char *path_content = path_get(RARCH_PATH_CONTENT);
@ -2764,15 +2761,10 @@ bool task_push_load_subsystem_with_core(
#endif
}
void content_get_status(
bool *contentless,
bool *is_inited)
uint8_t content_get_flags(void)
{
content_state_t *p_content = content_state_get_ptr();
*contentless = (p_content->flags &
CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT);
*is_inited = (p_content->flags & CONTENT_ST_FLAG_IS_INITED);
return p_content->flags;
}
/* 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;
retro_task_t *task;
const char *pcore;
bool contentless, is_inited;
uint8_t flags;
/* Do not run more than one CRC scan task at a time. */
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"))
return false; /* Nothing to reload. */
data = (struct netplay_crc_scan_data*)calloc(1, sizeof(*data));
task = task_init();
data = (struct netplay_crc_scan_data*)calloc(1, sizeof(*data));
task = task_init();
if (!data || !task)
{
@ -894,12 +894,10 @@ bool task_push_netplay_content_reload(const char *hostname)
if (hostname)
strlcpy(data->hostname, hostname, sizeof(data->hostname));
content_get_status(&contentless, &is_inited);
if (contentless)
{
flags = content_get_flags();
if (flags & CONTENT_ST_FLAG_CORE_DOES_NOT_NEED_CONTENT)
scan_state.state |= STATE_LOAD_CONTENTLESS;
}
else if (is_inited)
else if (flags & CONTENT_ST_FLAG_IS_INITED)
{
const char *psubsystem = path_get(RARCH_PATH_SUBSYSTEM);

View File

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