1
0
mirror of https://github.com/libretro/RetroArch synced 2024-07-08 12:15:49 +00:00

Rollback runloop changes - will require a rethink in how we approach

this
This commit is contained in:
twinaphex 2021-05-25 20:41:39 +02:00
parent 3c6ac487d0
commit 0a5d4288f5
7 changed files with 3274 additions and 3298 deletions

View File

@ -232,7 +232,6 @@ endif
OBJ += frontend/frontend_driver.o \
retroarch.o \
runloop.o \
command.o \
msg_hash.o \
intl/msg_hash_us.o \

View File

@ -1191,7 +1191,6 @@ GIT
RETROARCH
============================================================ */
#include "../retroarch.c"
#include "../runloop.c"
#include "../command.c"
#include "../libretro-common/queues/task_queue.c"

File diff suppressed because it is too large Load Diff

View File

@ -27,12 +27,6 @@
#include <retro_inline.h>
#include <retro_common_api.h>
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
#endif
#include <streams/interface_stream.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -47,11 +41,8 @@
#include "audio/audio_defines.h"
#include "gfx/video_shader_parse.h"
#include "configuration.h"
#include "core_type.h"
#include "core.h"
#include "core_option_manager.h"
#include "performance_counters.h"
#ifdef HAVE_MENU
#include "menu/menu_defines.h"
@ -88,32 +79,6 @@ RETRO_BEGIN_DECLS
* 3 - Late
*/
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
#define MAGIC_INDEX 0
#define SERIALIZER_INDEX 1
#define CRC_INDEX 2
#define STATE_SIZE_INDEX 3
#ifdef HAVE_BSV_MOVIE
#define BSV_MAGIC 0x42535631
#define BSV_MOVIE_IS_PLAYBACK_ON(runloop) (runloop->bsv_movie_state_handle && runloop->bsv_movie_state.movie_playback)
#define BSV_MOVIE_IS_PLAYBACK_OFF(runloop) (runloop->bsv_movie_state_handle && !runloop->bsv_movie_state.movie_playback)
#define BSV_MOVIE_IS_EOF(runloop) || (runloop->bsv_movie_state.movie_end && runloop->bsv_movie_state.eof_exit)
#else
#define BSV_MOVIE_IS_EOF(runloop)
#endif
#ifdef HAVE_THREADS
#define RUNLOOP_MSG_QUEUE_LOCK(runloop) slock_lock(runloop->msg_queue_lock)
#define RUNLOOP_MSG_QUEUE_UNLOCK(runloop) slock_unlock(runloop->msg_queue_lock)
#else
#define RUNLOOP_MSG_QUEUE_LOCK(p_runloop)
#define RUNLOOP_MSG_QUEUE_UNLOCK(p_runloop)
#endif
enum rarch_ctl_state
{
RARCH_CTL_NONE = 0,
@ -235,56 +200,6 @@ enum runloop_action
RUNLOOP_ACTION_AUTOSAVE
};
enum input_game_focus_cmd_type
{
GAME_FOCUS_CMD_OFF = 0,
GAME_FOCUS_CMD_ON,
GAME_FOCUS_CMD_TOGGLE,
GAME_FOCUS_CMD_REAPPLY
};
#ifdef HAVE_BSV_MOVIE
enum rarch_movie_type
{
RARCH_MOVIE_PLAYBACK = 0,
RARCH_MOVIE_RECORD
};
struct bsv_state
{
/* Movie playback/recording support. */
char movie_path[PATH_MAX_LENGTH];
/* Immediate playback/recording. */
char movie_start_path[PATH_MAX_LENGTH];
bool movie_start_recording;
bool movie_start_playback;
bool movie_playback;
bool eof_exit;
bool movie_end;
};
struct bsv_movie
{
intfstream_t *file;
uint8_t *state;
/* A ring buffer keeping track of positions
* in the file for each frame. */
size_t *frame_pos;
size_t frame_mask;
size_t frame_ptr;
size_t min_file_pos;
size_t state_size;
bool playback;
bool first_rewind;
bool did_rewind;
};
typedef struct bsv_movie bsv_movie_t;
#endif
struct rarch_main_wrap
{
char **argv;
@ -406,12 +321,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data);
int retroarch_get_capabilities(enum rarch_capabilities type,
char *s, size_t len);
bool retroarch_validate_game_options(
char *s, size_t len, bool mkdir);
bool retroarch_validate_folder_options(
char *s, size_t len, bool mkdir);
void retroarch_override_setting_set(enum rarch_override_setting enum_idx, void *data);
void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void *data);
@ -2110,350 +2019,6 @@ typedef enum apple_view_type
APPLE_VIEW_TYPE_METAL
} apple_view_type_t;
typedef struct input_game_focus_state
{
bool enabled;
bool core_requested;
} input_game_focus_state_t;
typedef struct runloop runloop_state_t;
struct runloop
{
double audio_source_ratio_original;
double audio_source_ratio_current;
struct retro_system_av_info av_info; /* double alignment */
retro_time_t libretro_core_runtime_last;
retro_time_t libretro_core_runtime_usec;
retro_time_t frame_limit_minimum_time;
retro_time_t frame_limit_last_time;
retro_time_t frame_time_samples[
MEASURE_FRAME_TIME_SAMPLES_COUNT];
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
rarch_timer_t shader_delay_timer; /* int64_t alignment */
#endif
retro_usec_t frame_time_last; /* int64_t alignment */
uint64_t frame_time_count;
uint64_t frame_count;
#ifdef HAVE_RUNAHEAD
uint64_t last_frame_count_runahead;
#endif
uint64_t free_audio_samples_count;
float *audio_output_samples_buf;
float *audio_input_data;
int16_t *audio_output_samples_conv_buf;
#ifdef HAVE_REWIND
int16_t *audio_rewind_buf;
#endif
struct retro_audio_callback audio_callback; /* ptr alignment */
msg_queue_t msg_queue; /* ptr alignment */
#ifdef HAVE_THREADS
slock_t *msg_queue_lock;
slock_t *display_lock;
slock_t *context_lock;
#endif
struct string_list *subsystem_fullpaths;
core_option_manager_t *core_options;
retro_keyboard_event_t key_event; /* ptr alignment */
retro_keyboard_event_t frontend_key_event; /* ptr alignment */
rarch_system_info_t system; /* ptr alignment */
struct retro_frame_time_callback frame_time; /* ptr alignment */
struct retro_audio_buffer_status_callback audio_buffer_status; /* ptr alignment */
#ifdef HAVE_BSV_MOVIE
bsv_movie_t *bsv_movie_state_handle; /* ptr alignment */
#endif
bool *load_no_content_hook;
void *audio_context_audio_data;
void *audio_resampler_data;
#ifdef HAVE_REWIND
size_t audio_rewind_ptr;
size_t audio_rewind_size;
#endif
#ifdef HAVE_RUNAHEAD
size_t runahead_save_state_size;
#endif
size_t audio_buffer_size;
size_t audio_data_ptr;
size_t audio_chunk_size;
size_t audio_chunk_nonblock_size;
size_t audio_chunk_block_size;
size_t msg_queue_size;
unsigned pending_windowed_scale;
unsigned max_frames;
unsigned audio_latency;
unsigned free_audio_samples_buf[
AUDIO_BUFFER_FREE_SAMPLES_COUNT];
struct retro_fastforwarding_override fastmotion_override; /* float alignment */
float audio_rate_control_delta;
float audio_input_sample_rate;
float audio_volume_gain;
#ifdef HAVE_AUDIOMIXER
float audio_mixer_volume_gain;
#endif
#ifdef HAVE_BSV_MOVIE
struct bsv_state bsv_movie_state; /* char alignment */
#endif
char current_savefile_dir[PATH_MAX_LENGTH];
char current_savestate_dir[PATH_MAX_LENGTH];
char path_default_shader_preset[PATH_MAX_LENGTH];
char subsystem_path[PATH_MAX_LENGTH];
char runtime_content_path[PATH_MAX_LENGTH];
char runtime_core_path[PATH_MAX_LENGTH];
char path_content[PATH_MAX_LENGTH];
char path_libretro[PATH_MAX_LENGTH];
char path_config_file[PATH_MAX_LENGTH];
char path_config_append_file[PATH_MAX_LENGTH];
char path_core_options_file[PATH_MAX_LENGTH];
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
char cli_shader[PATH_MAX_LENGTH];
char runtime_shader_preset[PATH_MAX_LENGTH];
#endif
char path_main_basename[8192];
char current_library_name[256];
char current_library_version[256];
char current_valid_extensions[256];
input_game_focus_state_t game_focus_state; /* bool alignment */
#ifdef HAVE_GFX_WIDGETS
bool widgets_active;
bool widgets_persisting;
bool widgets_paused;
bool widgets_fast_forward;
bool widgets_rewinding;
#endif
bool audio_active;
bool audio_use_float;
bool audio_suspended;
bool audio_control;
bool audio_mute_enable;
#ifdef HAVE_AUDIOMIXER
bool audio_mixer_mute_enable;
bool audio_mixer_active;
#endif
bool missing_bios;
bool force_nonblock;
bool paused;
bool idle;
bool slowmotion;
bool fastmotion;
bool shutdown_initiated;
bool core_shutdown_initiated;
bool core_running;
bool perfcnt_enable;
bool video_active;
bool video_started_fullscreen;
#ifdef HAVE_RUNAHEAD
bool runahead_video_active;
#endif
bool game_options_active;
bool folder_options_active;
bool autosave;
#ifdef HAVE_CONFIGFILE
bool overrides_active;
bool remaps_core_active;
bool remaps_game_active;
bool remaps_content_dir_active;
#endif
#ifdef HAVE_SCREENSHOTS
bool max_frames_screenshot;
char max_frames_screenshot_path[PATH_MAX_LENGTH];
#endif
#ifdef HAVE_NETWORKING
/* Only used before init_netplay */
bool netplay_enabled;
bool netplay_is_client;
/* Used to avoid recursive netplay calls */
bool in_netplay;
bool netplay_client_deferred;
bool is_mitm;
#endif
bool has_set_username;
bool rarch_error_on_init;
bool rarch_force_fullscreen;
bool has_set_core;
bool has_set_verbosity;
bool has_set_libretro;
bool has_set_libretro_directory;
bool has_set_save_path;
bool has_set_state_path;
#ifdef HAVE_PATCH
bool has_set_ups_pref;
bool has_set_bps_pref;
bool has_set_ips_pref;
#endif
#ifdef HAVE_QT
bool qt_is_inited;
#endif
bool has_set_log_to_file;
bool rarch_is_inited;
bool rarch_is_switching_display_mode;
bool rarch_is_sram_load_disabled;
bool rarch_is_sram_save_disabled;
bool rarch_use_sram;
bool rarch_ups_pref;
bool rarch_bps_pref;
bool rarch_ips_pref;
#ifdef HAVE_PATCH
bool rarch_patch_blocked;
#endif
bool video_driver_window_title_update;
/**
* dynamic.c:dynamic_request_hw_context will try to set
* flag data when the context
* is in the middle of being rebuilt; in these cases we will save flag
* data and set this to true.
* When the context is reinit, it checks this, reads from
* deferred_flag_data and cleans it.
*
* TODO - Dirty hack, fix it better
*/
bool deferred_video_context_driver_set_flags;
bool ignore_environment_cb;
bool core_set_shared_context;
/* Graphics driver requires RGBA byte order data (ABGR on little-endian)
* for 32-bit.
* This takes effect for overlay and shader cores that wants to load
* data into graphics driver. Kinda hackish to place it here, it is only
* used for GLES.
* TODO: Refactor this better. */
bool video_driver_use_rgba;
/* If set during context deinit, the driver should keep
* graphics context alive to avoid having to reset all
* context state. */
bool video_driver_cache_context;
/* Set to true by driver if context caching succeeded. */
bool video_driver_cache_context_ack;
#ifdef HAVE_ACCESSIBILITY
/* Is text-to-speech accessibility turned on? */
bool accessibility_enabled;
#endif
#ifdef HAVE_CONFIGFILE
bool rarch_block_config_read;
#endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
bool cli_shader_disable;
#endif
bool location_driver_active;
bool bluetooth_driver_active;
bool wifi_driver_active;
bool camera_driver_active;
#ifdef HAVE_VIDEO_FILTER
bool video_driver_state_out_rgb32;
#endif
bool video_driver_crt_switching_active;
bool video_driver_crt_dynamic_super_width;
bool video_driver_threaded;
#ifdef HAVE_RUNAHEAD
bool has_variable_update;
bool runahead_save_state_size_known;
bool request_fast_savestate;
bool hard_disable_audio;
bool input_is_dirty;
#endif
#if defined(HAVE_NETWORKING)
bool has_set_netplay_mode;
bool has_set_netplay_ip_address;
bool has_set_netplay_ip_port;
bool has_set_netplay_stateless_mode;
bool has_set_netplay_check_frames;
#endif
bool input_driver_keyboard_linefeed_enable;
bool input_driver_block_hotkey;
bool input_driver_block_libretro_input;
bool input_driver_nonblock_state;
bool input_driver_grab_mouse_state;
#ifdef HAVE_MENU
bool menu_input_dialog_keyboard_display;
/* Is the menu driver still running? */
bool menu_driver_alive;
/* Are we binding a button inside the menu? */
bool menu_driver_is_binding;
#endif
bool recording_enable;
bool streaming_enable;
bool midi_drv_input_enabled;
bool midi_drv_output_enabled;
bool midi_drv_output_pending;
bool main_ui_companion_is_on_foreground;
bool keyboard_mapping_blocked;
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
bool shader_presets_need_reload;
#endif
#ifdef HAVE_RUNAHEAD
bool runahead_available;
bool runahead_secondary_core_available;
bool runahead_force_input_dirty;
#endif
};
bool retroarch_validate_per_core_options(char *s,
size_t len, bool mkdir,
const char *core_name, const char *game_name);
void core_option_manager_flush(
config_file_t *conf,
core_option_manager_t *opt);
#ifdef HAVE_BSV_MOVIE
bool bsv_movie_check(
runloop_state_t *p_runloop,
settings_t *settings);
void bsv_movie_deinit(runloop_state_t *p_runloop);
bool bsv_movie_init(runloop_state_t *p_runloop);
#endif
void runloop_system_info_free(runloop_state_t *p_runloop);
void runloop_fastmotion_override_free(settings_t *settings,
runloop_state_t *p_runloop);
void runloop_game_focus_free(runloop_state_t *p_runloop);
void runloop_audio_buffer_status_free(runloop_state_t *p_runloop);
void runloop_frame_time_free(runloop_state_t *p_runloop);
retro_time_t runloop_set_frame_limit(
const struct retro_system_av_info *av_info,
float fastforward_ratio);
float runloop_get_fastforward_ratio(
settings_t *settings,
struct retro_fastforwarding_override *fastmotion_override);
void runloop_msg_queue_deinit(runloop_state_t *p_runloop);
void runloop_msg_queue_init(runloop_state_t *p_runloop);
#ifdef HAVE_RUNAHEAD
void runloop_runahead_clear_variables(runloop_state_t *p_runloop);
#endif
#ifdef HAVE_THREADS
void runloop_autosave_deinit(runloop_state_t *p_runloop);
#endif
RETRO_END_DECLS
#endif

View File

@ -62,8 +62,24 @@
#define DEBUG_INFO_FILENAME "debug_info.txt"
#define MAGIC_INDEX 0
#define SERIALIZER_INDEX 1
#define CRC_INDEX 2
#define STATE_SIZE_INDEX 3
#ifdef HAVE_BSV_MOVIE
#define BSV_MAGIC 0x42535631
#define BSV_MOVIE_IS_PLAYBACK_ON() (p_rarch->bsv_movie_state_handle && p_rarch->bsv_movie_state.movie_playback)
#define BSV_MOVIE_IS_PLAYBACK_OFF() (p_rarch->bsv_movie_state_handle && !p_rarch->bsv_movie_state.movie_playback)
#endif
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
#define TIME_TO_FPS(last_time, new_time, frames) ((1000000.0f * (frames)) / ((new_time) - (last_time)))
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
#define MENU_SOUND_FORMATS "ogg|mod|xm|s3m|mp3|flac|wav"
#define MIDI_DRIVER_BUF_SIZE 4096
@ -92,33 +108,33 @@
#define DECLARE_META_BIND(level, base, bind, desc) { #base, desc, level, bind, true }
#ifdef HAVE_THREADS
#define VIDEO_DRIVER_IS_THREADED_INTERNAL() ((!video_driver_is_hw_context() && runloop_state.video_driver_threaded) ? true : false)
#define VIDEO_DRIVER_IS_THREADED_INTERNAL() ((!video_driver_is_hw_context() && p_rarch->video_driver_threaded) ? true : false)
#else
#define VIDEO_DRIVER_IS_THREADED_INTERNAL() (false)
#endif
#ifdef HAVE_THREADS
#define VIDEO_DRIVER_LOCK() \
if (runloop_state.display_lock) \
slock_lock(runloop_state.display_lock)
if (p_rarch->display_lock) \
slock_lock(p_rarch->display_lock)
#define VIDEO_DRIVER_UNLOCK() \
if (runloop_state.display_lock) \
slock_unlock(runloop_state.display_lock)
if (p_rarch->display_lock) \
slock_unlock(p_rarch->display_lock)
#define VIDEO_DRIVER_CONTEXT_LOCK() \
if (runloop_state.context_lock) \
slock_lock(runloop_state.context_lock)
if (p_rarch->context_lock) \
slock_lock(p_rarch->context_lock)
#define VIDEO_DRIVER_CONTEXT_UNLOCK() \
if (runloop_state.context_lock) \
slock_unlock(runloop_state.context_lock)
if (p_rarch->context_lock) \
slock_unlock(p_rarch->context_lock)
#define VIDEO_DRIVER_LOCK_FREE() \
slock_free(runloop_state.display_lock); \
slock_free(runloop_state.context_lock); \
runloop_state.display_lock = NULL; \
runloop_state.context_lock = NULL
slock_free(p_rarch->display_lock); \
slock_free(p_rarch->context_lock); \
p_rarch->display_lock = NULL; \
p_rarch->context_lock = NULL
#define VIDEO_DRIVER_THREADED_LOCK(is_threaded) \
if (is_threaded) \
@ -138,13 +154,27 @@
#endif
#ifdef HAVE_THREADS
#define VIDEO_DRIVER_GET_PTR_INTERNAL(video_driver_data) ((VIDEO_DRIVER_IS_THREADED_INTERNAL()) ? video_thread_get_ptr(video_driver_data) : video_driver_data)
#define VIDEO_DRIVER_GET_PTR_INTERNAL(p_rarch) ((VIDEO_DRIVER_IS_THREADED_INTERNAL()) ? video_thread_get_ptr(p_rarch) : p_rarch->video_driver_data)
#else
#define VIDEO_DRIVER_GET_PTR_INTERNAL(video_driver_data) (video_driver_data)
#define VIDEO_DRIVER_GET_PTR_INTERNAL(p_rarch) (p_rarch->video_driver_data)
#endif
#define VIDEO_DRIVER_GET_HW_CONTEXT_INTERNAL(p_rarch) (&p_rarch->hw_render)
#ifdef HAVE_THREADS
#define RUNLOOP_MSG_QUEUE_LOCK(runloop) slock_lock(runloop.msg_queue_lock)
#define RUNLOOP_MSG_QUEUE_UNLOCK(runloop) slock_unlock(runloop.msg_queue_lock)
#else
#define RUNLOOP_MSG_QUEUE_LOCK(p_runloop)
#define RUNLOOP_MSG_QUEUE_UNLOCK(p_runloop)
#endif
#ifdef HAVE_BSV_MOVIE
#define BSV_MOVIE_IS_EOF(p_rarch) || (p_rarch->bsv_movie_state.movie_end && p_rarch->bsv_movie_state.eof_exit)
#else
#define BSV_MOVIE_IS_EOF(p_rarch)
#endif
/* Time to exit out of the main loop?
* Reasons for exiting:
* a) Shutdown environment callback was invoked.
@ -153,7 +183,7 @@
* d) Video driver no longer alive.
* e) End of BSV movie and BSV EOF exit is true. (TODO/FIXME - explain better)
*/
#define TIME_TO_EXIT(quit_key_pressed) (runloop_state.shutdown_initiated || quit_key_pressed || !is_alive BSV_MOVIE_IS_EOF(p_runloop) || ((runloop_state.max_frames != 0) && (frame_count >= runloop_state.max_frames)) || runloop_exec)
#define TIME_TO_EXIT(quit_key_pressed) (runloop_state.shutdown_initiated || quit_key_pressed || !is_alive BSV_MOVIE_IS_EOF(p_rarch) || ((runloop_state.max_frames != 0) && (frame_count >= runloop_state.max_frames)) || runloop_exec)
/* Depends on ASCII character values */
#define ISPRINT(c) (((int)(c) >= ' ' && (int)(c) <= '~') ? 1 : 0)
@ -165,9 +195,15 @@
#if HAVE_DYNAMIC
#define RUNAHEAD_RUN_SECONDARY(p_rarch) \
if (!secondary_core_run_use_last_input(p_rarch)) \
runloop_state.runahead_secondary_core_available = false
p_rarch->runahead_secondary_core_available = false
#endif
#define RUNAHEAD_RESUME_VIDEO(p_rarch) \
if (p_rarch->runahead_video_driver_is_active) \
p_rarch->video_driver_active = true; \
else \
p_rarch->video_driver_active = false
#define _PSUPP_BUF(buf, var, name, desc) \
strlcat(buf, " ", sizeof(buf)); \
strlcat(buf, name, sizeof(buf)); \
@ -1235,6 +1271,12 @@ enum runloop_state
RUNLOOP_STATE_QUIT
};
enum rarch_movie_type
{
RARCH_MOVIE_PLAYBACK = 0,
RARCH_MOVIE_RECORD
};
enum poll_type_override_t
{
POLL_TYPE_OVERRIDE_DONTCARE = 0,
@ -1250,6 +1292,14 @@ enum auto_shader_operation
AUTO_SHADER_OP_EXISTS
};
enum input_game_focus_cmd_type
{
GAME_FOCUS_CMD_OFF = 0,
GAME_FOCUS_CMD_ON,
GAME_FOCUS_CMD_TOGGLE,
GAME_FOCUS_CMD_REAPPLY
};
typedef struct runloop_ctx_msg_info
{
const char *msg;
@ -1275,6 +1325,40 @@ struct rarch_dir_shader_list
bool remember_last_preset_dir;
};
#ifdef HAVE_BSV_MOVIE
struct bsv_state
{
/* Movie playback/recording support. */
char movie_path[PATH_MAX_LENGTH];
/* Immediate playback/recording. */
char movie_start_path[PATH_MAX_LENGTH];
bool movie_start_recording;
bool movie_start_playback;
bool movie_playback;
bool eof_exit;
bool movie_end;
};
struct bsv_movie
{
intfstream_t *file;
uint8_t *state;
/* A ring buffer keeping track of positions
* in the file for each frame. */
size_t *frame_pos;
size_t frame_mask;
size_t frame_ptr;
size_t min_file_pos;
size_t state_size;
bool playback;
bool first_rewind;
bool did_rewind;
};
#endif
typedef struct video_pixel_scaler
{
struct scaler_ctx *scaler;
@ -1304,6 +1388,10 @@ struct input_remote
bool state[RARCH_BIND_LIST_END];
};
#ifdef HAVE_BSV_MOVIE
typedef struct bsv_movie bsv_movie_t;
#endif
typedef struct input_remote input_remote_t;
typedef struct input_remote_state
@ -1412,6 +1500,12 @@ struct input_keyboard_line
bool enabled;
};
typedef struct input_game_focus_state
{
bool enabled;
bool core_requested;
} input_game_focus_state_t;
#ifdef HAVE_RUNAHEAD
typedef bool(*runahead_load_state_function)(const void*, size_t);
#endif
@ -1567,15 +1661,79 @@ struct discord_state
typedef struct discord_state discord_state_t;
#endif
struct runloop
{
retro_usec_t frame_time_last; /* int64_t alignment */
msg_queue_t msg_queue; /* ptr alignment */
#ifdef HAVE_THREADS
slock_t *msg_queue_lock;
#endif
size_t msg_queue_size;
core_option_manager_t *core_options;
retro_keyboard_event_t key_event; /* ptr alignment */
retro_keyboard_event_t frontend_key_event; /* ptr alignment */
rarch_system_info_t system; /* ptr alignment */
struct retro_frame_time_callback frame_time; /* ptr alignment */
struct retro_audio_buffer_status_callback audio_buffer_status; /* ptr alignment */
unsigned pending_windowed_scale;
unsigned max_frames;
unsigned audio_latency;
struct retro_fastforwarding_override fastmotion_override; /* float alignment */
bool missing_bios;
bool force_nonblock;
bool paused;
bool idle;
bool slowmotion;
bool fastmotion;
bool shutdown_initiated;
bool core_shutdown_initiated;
bool core_running;
bool perfcnt_enable;
bool game_options_active;
bool folder_options_active;
bool autosave;
#ifdef HAVE_CONFIGFILE
bool overrides_active;
bool remaps_core_active;
bool remaps_game_active;
bool remaps_content_dir_active;
#endif
#ifdef HAVE_SCREENSHOTS
bool max_frames_screenshot;
char max_frames_screenshot_path[PATH_MAX_LENGTH];
#endif
};
typedef struct runloop runloop_state_t;
struct rarch_state
{
double audio_source_ratio_original;
double audio_source_ratio_current;
struct retro_system_av_info video_driver_av_info; /* double alignment */
videocrt_switch_t crt_switch_st; /* double alignment */
retro_time_t frame_limit_minimum_time;
retro_time_t frame_limit_last_time;
retro_time_t libretro_core_runtime_last;
retro_time_t libretro_core_runtime_usec;
retro_time_t video_driver_frame_time_samples[
MEASURE_FRAME_TIME_SAMPLES_COUNT];
struct global g_extern; /* retro_time_t alignment */
#ifdef HAVE_MENU
menu_input_t menu_input_state; /* retro_time_t alignment */
#endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
rarch_timer_t shader_delay_timer; /* int64_t alignment */
#endif
#ifdef HAVE_DISCORD
discord_state_t discord_st; /* int64_t alignment */
#endif
@ -1595,6 +1753,14 @@ struct rarch_state
#endif
#endif
uint64_t audio_driver_free_samples_count;
#ifdef HAVE_RUNAHEAD
uint64_t runahead_last_frame_count;
#endif
uint64_t video_driver_frame_time_count;
uint64_t video_driver_frame_count;
struct retro_camera_callback camera_cb; /* uint64_t alignment */
gfx_animation_t anim; /* uint64_t alignment */
gfx_thumbnail_state_t gfx_thumb_state; /* uint64_t alignment */
@ -1602,6 +1768,7 @@ struct rarch_state
input_remote_state_t remote_st_ptr; /* uint64_t alignment */
#endif
struct string_list *subsystem_fullpaths;
struct string_list *midi_drv_inputs;
struct string_list *midi_drv_outputs;
struct string_list *audio_driver_devices_list;
@ -1609,6 +1776,8 @@ struct rarch_state
uint8_t *video_driver_record_gpu_buffer;
uint8_t *midi_drv_input_buffer;
uint8_t *midi_drv_output_buffer;
bool *load_no_content_hook;
float *audio_driver_output_samples_buf;
char *osk_grid[45];
#if defined(HAVE_RUNAHEAD)
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
@ -1623,6 +1792,10 @@ struct rarch_state
const record_driver_t *recording_driver;
void *recording_data;
#ifdef HAVE_THREADS
slock_t *display_lock;
slock_t *context_lock;
#endif
const camera_driver_t *camera_driver;
void *camera_data;
@ -1670,12 +1843,19 @@ struct rarch_state
void *video_context_data;
#ifdef HAVE_REWIND
int16_t *audio_driver_rewind_buf;
#endif
int16_t *audio_driver_output_samples_conv_buf;
#ifdef HAVE_DSP_FILTER
retro_dsp_filter_t *audio_driver_dsp;
#endif
const retro_resampler_t *audio_driver_resampler;
void *audio_driver_resampler_data;
const audio_driver_t *current_audio;
void *audio_driver_context_audio_data;
#ifdef HAVE_OVERLAY
input_overlay_t *overlay_ptr;
#endif
@ -1737,10 +1917,14 @@ struct rarch_state
const input_device_driver_t *joypad; /* ptr alignment */
#ifdef HAVE_MFI
const input_device_driver_t *sec_joypad; /* ptr alignment */
#endif
#ifdef HAVE_BSV_MOVIE
bsv_movie_t *bsv_movie_state_handle; /* ptr alignment */
#endif
gfx_display_t dispgfx; /* ptr alignment */
input_keyboard_press_t keyboard_press_cb; /* ptr alignment */
retro_input_state_t input_state_callback_original; /* ptr alignment */
struct retro_audio_callback audio_callback; /* ptr alignment */
video_driver_frame_t frame_bak; /* ptr alignment */
struct rarch_dir_shader_list dir_shader_list; /* ptr alignment */
#ifdef HAVE_RUNAHEAD
@ -1786,6 +1970,21 @@ struct rarch_state
size_t frame_cache_pitch;
size_t audio_driver_chunk_size;
size_t audio_driver_chunk_nonblock_size;
size_t audio_driver_chunk_block_size;
#ifdef HAVE_REWIND
size_t audio_driver_rewind_ptr;
size_t audio_driver_rewind_size;
#endif
size_t audio_driver_buffer_size;
size_t audio_driver_data_ptr;
#ifdef HAVE_RUNAHEAD
size_t runahead_save_state_size;
#endif
jmp_buf error_sjlj_context; /* 4-byte alignment,
put it right before long */
@ -1852,12 +2051,23 @@ struct rarch_state
unsigned server_port_deferred;
#endif
unsigned audio_driver_free_samples_buf[
AUDIO_BUFFER_FREE_SAMPLES_COUNT];
unsigned perf_ptr_rarch;
unsigned perf_ptr_libretro;
float *audio_driver_input_data;
float video_driver_core_hz;
float video_driver_aspect_ratio;
#ifdef HAVE_AUDIOMIXER
float audio_driver_mixer_volume_gain;
#endif
float audio_driver_rate_control_delta;
float audio_driver_input;
float audio_driver_volume_gain;
float input_driver_axis_threshold;
enum osk_type osk_idx;
@ -1899,6 +2109,10 @@ struct rarch_state
retro_bits_t has_set_libretro_device; /* uint32_t alignment */
input_mapper_t input_driver_mapper; /* uint32_t alignment */
#ifdef HAVE_BSV_MOVIE
struct bsv_state bsv_movie_state; /* char alignment */
#endif
char cached_video_driver[32];
char video_driver_title_buf[64];
char video_driver_gpu_device_string[128];
@ -1912,11 +2126,201 @@ struct rarch_state
#ifdef HAVE_NETWORKING
char server_address_deferred[512];
#endif
char current_library_name[256];
char current_library_version[256];
char current_valid_extensions[256];
char launch_arguments[4096];
char path_main_basename[8192];
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
char cli_shader[PATH_MAX_LENGTH];
char runtime_shader_preset[PATH_MAX_LENGTH];
#endif
char runtime_content_path[PATH_MAX_LENGTH];
char runtime_core_path[PATH_MAX_LENGTH];
char subsystem_path[PATH_MAX_LENGTH];
char path_default_shader_preset[PATH_MAX_LENGTH];
char path_content[PATH_MAX_LENGTH];
char path_libretro[PATH_MAX_LENGTH];
char path_config_file[PATH_MAX_LENGTH];
char path_config_append_file[PATH_MAX_LENGTH];
char path_core_options_file[PATH_MAX_LENGTH];
char dir_system[PATH_MAX_LENGTH];
char dir_savefile[PATH_MAX_LENGTH];
char current_savefile_dir[PATH_MAX_LENGTH];
char current_savestate_dir[PATH_MAX_LENGTH];
char dir_savestate[PATH_MAX_LENGTH];
#ifdef HAVE_GFX_WIDGETS
bool widgets_active;
bool widgets_persisting;
#endif
#ifdef HAVE_NETWORKING
/* Only used before init_netplay */
bool netplay_enabled;
bool netplay_is_client;
/* Used to avoid recursive netplay calls */
bool in_netplay;
bool netplay_client_deferred;
bool is_mitm;
#endif
bool has_set_username;
bool rarch_error_on_init;
bool rarch_force_fullscreen;
bool has_set_core;
bool has_set_verbosity;
bool has_set_libretro;
bool has_set_libretro_directory;
bool has_set_save_path;
bool has_set_state_path;
#ifdef HAVE_PATCH
bool has_set_ups_pref;
bool has_set_bps_pref;
bool has_set_ips_pref;
#endif
#ifdef HAVE_QT
bool qt_is_inited;
#endif
bool has_set_log_to_file;
bool rarch_is_inited;
bool rarch_is_switching_display_mode;
bool rarch_is_sram_load_disabled;
bool rarch_is_sram_save_disabled;
bool rarch_use_sram;
bool rarch_ups_pref;
bool rarch_bps_pref;
bool rarch_ips_pref;
#ifdef HAVE_PATCH
bool rarch_patch_blocked;
#endif
bool video_driver_window_title_update;
/**
* dynamic.c:dynamic_request_hw_context will try to set
* flag data when the context
* is in the middle of being rebuilt; in these cases we will save flag
* data and set this to true.
* When the context is reinit, it checks this, reads from
* deferred_flag_data and cleans it.
*
* TODO - Dirty hack, fix it better
*/
bool deferred_video_context_driver_set_flags;
bool ignore_environment_cb;
bool core_set_shared_context;
/* Graphics driver requires RGBA byte order data (ABGR on little-endian)
* for 32-bit.
* This takes effect for overlay and shader cores that wants to load
* data into graphics driver. Kinda hackish to place it here, it is only
* used for GLES.
* TODO: Refactor this better. */
bool video_driver_use_rgba;
/* If set during context deinit, the driver should keep
* graphics context alive to avoid having to reset all
* context state. */
bool video_driver_cache_context;
/* Set to true by driver if context caching succeeded. */
bool video_driver_cache_context_ack;
#ifdef HAVE_GFX_WIDGETS
bool gfx_widgets_paused;
bool gfx_widgets_fast_forward;
bool gfx_widgets_rewinding;
#endif
#ifdef HAVE_ACCESSIBILITY
/* Is text-to-speech accessibility turned on? */
bool accessibility_enabled;
#endif
#ifdef HAVE_CONFIGFILE
bool rarch_block_config_read;
#endif
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
bool cli_shader_disable;
#endif
bool location_driver_active;
bool bluetooth_driver_active;
bool wifi_driver_active;
bool video_driver_active;
bool audio_driver_active;
bool camera_driver_active;
#ifdef HAVE_VIDEO_FILTER
bool video_driver_state_out_rgb32;
#endif
bool video_driver_crt_switching_active;
bool video_driver_crt_dynamic_super_width;
bool video_driver_threaded;
bool video_started_fullscreen;
bool audio_driver_control;
bool audio_driver_mute_enable;
bool audio_driver_use_float;
bool audio_suspended;
#ifdef HAVE_RUNAHEAD
bool has_variable_update;
bool runahead_save_state_size_known;
bool request_fast_savestate;
bool hard_disable_audio;
bool input_is_dirty;
#endif
#if defined(HAVE_NETWORKING)
bool has_set_netplay_mode;
bool has_set_netplay_ip_address;
bool has_set_netplay_ip_port;
bool has_set_netplay_stateless_mode;
bool has_set_netplay_check_frames;
#endif
bool input_driver_keyboard_linefeed_enable;
bool input_driver_block_hotkey;
bool input_driver_block_libretro_input;
bool input_driver_nonblock_state;
bool input_driver_grab_mouse_state;
input_game_focus_state_t game_focus_state; /* bool alignment */
#ifdef HAVE_MENU
bool menu_input_dialog_keyboard_display;
/* Is the menu driver still running? */
bool menu_driver_alive;
/* Are we binding a button inside the menu? */
bool menu_driver_is_binding;
#endif
bool recording_enable;
bool streaming_enable;
bool midi_drv_input_enabled;
bool midi_drv_output_enabled;
bool midi_drv_output_pending;
bool main_ui_companion_is_on_foreground;
bool keyboard_mapping_blocked;
retro_bits_512_t keyboard_mapping_bits;
#if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_SLANG) || defined(HAVE_HLSL)
bool shader_presets_need_reload;
#endif
#ifdef HAVE_RUNAHEAD
bool runahead_video_driver_is_active;
bool runahead_available;
bool runahead_secondary_core_available;
bool runahead_force_input_dirty;
#endif
#ifdef HAVE_AUDIOMIXER
bool audio_driver_mixer_mute_enable;
bool audio_mixer_active;
#endif
};
static struct rarch_state rarch_st;
@ -2219,7 +2623,7 @@ struct key_desc key_descriptors[RARCH_MAX_KEYS] =
{RETROK_BREAK, "Break"},
{RETROK_MENU, "Menu"},
{RETROK_POWER, "Power"},
{RETROK_EURO, {-30, -126, -84, 0}}, /* "€" */
{RETROK_EURO, {-30, -126, -84, 0}}, /* "€" */
{RETROK_UNDO, "Undo"},
{RETROK_OEM_102, "OEM-102"}
};

View File

@ -44,20 +44,13 @@ static bool midi_driver_set_all_sounds_off(struct rarch_state *p_rarch);
static const void *midi_driver_find_handle(int index);
static bool midi_driver_flush(void);
retro_time_t runloop_core_runtime_tick(
runloop_state_t *p_runloop,
float slowmotion_ratio,
retro_time_t current_time);
void runloop_deinit_core_options(
runloop_state_t *p_runloop,
const char *path_core_options);
core_option_manager_t *runloop_init_core_variables(
runloop_state_t *p_runloop,
settings_t *settings,
static void retroarch_deinit_core_options(struct rarch_state *p_rarch,
const char *p);
static void retroarch_init_core_variables(
struct rarch_state *p_rarch,
const struct retro_variable *vars);
core_option_manager_t *runloop_init_core_options(
runloop_state_t *p_runloop,
settings_t *settings,
static void rarch_init_core_options(
struct rarch_state *p_rarch,
const struct retro_core_option_definition *option_defs);
#ifdef HAVE_RUNAHEAD
#if defined(HAVE_DYNAMIC) || defined(HAVE_DYLIB)
@ -130,6 +123,13 @@ static bool video_driver_find_driver(
settings_t *settings,
const char *prefix, bool verbosity_enabled);
#ifdef HAVE_BSV_MOVIE
static void bsv_movie_deinit(struct rarch_state *p_rarch);
static bool bsv_movie_init(struct rarch_state *p_rarch);
static bool bsv_movie_check(struct rarch_state *p_rarch,
settings_t *settings);
#endif
static void driver_uninit(struct rarch_state *p_rarch, int flags);
static void drivers_init(struct rarch_state *p_rarch,
settings_t *settings,
@ -207,7 +207,6 @@ static int menu_input_post_iterate(
static bool retroarch_apply_shader(
struct rarch_state *p_rarch,
runloop_state_t *p_runloop,
settings_t *settings,
enum rarch_shader_type type, const char *preset_path,
bool message);

1248
runloop.c

File diff suppressed because it is too large Load Diff