From d36f6d8a1d4f877ff12816dcc72e4811b0ed9071 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 24 Jul 2019 15:02:25 +0200 Subject: [PATCH] Turn more functions static --- command.h | 1 - retroarch.c | 187 +++++++++++++++++++++++----------------------------- retroarch.h | 70 +++++++------------- 3 files changed, 106 insertions(+), 152 deletions(-) diff --git a/command.h b/command.h index a3c4886511..ab375eca2e 100644 --- a/command.h +++ b/command.h @@ -120,7 +120,6 @@ enum event_command CMD_EVENT_VIDEO_SET_BLOCKING_STATE, /* Sets current aspect ratio index. */ CMD_EVENT_VIDEO_SET_ASPECT_RATIO, - CMD_EVENT_RESET_CONTEXT, /* Restarts RetroArch. */ CMD_EVENT_RESTART_RETROARCH, /* Shutdown the OS */ diff --git a/retroarch.c b/retroarch.c index 9c751f625e..3bc2ecd286 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1655,6 +1655,26 @@ static char *secondary_library_path = NULL; #endif /* Forward declarations */ +static bool audio_driver_stop(void); +static bool audio_driver_start(bool is_shutdown); + +static bool recording_init(void); +static bool recording_deinit(void); + +static void video_driver_gpu_record_deinit(void); + +static void video_driver_set_nonblock_state(bool toggle); + +static void input_overlay_set_alpha_mod(input_overlay_t *ol, float mod); +static void input_overlay_set_scale_factor(input_overlay_t *ol, float scale); +static void input_overlay_load_active(input_overlay_t *ol, float opacity); +static void retroarch_overlay_init(void); +static void retroarch_overlay_deinit(void); + +static void bsv_movie_deinit(void); +static bool bsv_movie_init(void); +static bool bsv_movie_check(void); + static void driver_uninit(int flags); static void drivers_init(int flags); static void core_free_retro_game_info(struct retro_game_info *dest); @@ -4028,12 +4048,7 @@ TODO: Add a setting for these tweaks */ msg_hash_to_str(MSG_AUDIO_MUTED): msg_hash_to_str(MSG_AUDIO_UNMUTED); - if (!audio_driver_toggle_mute()) - { - RARCH_ERR("%s.\n", - msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO)); - return false; - } + audio_driver_mute_enable = !audio_driver_mute_enable; #if defined(HAVE_MENU) && defined(HAVE_MENU_WIDGETS) if (!menu_widgets_volume_update_and_show()) @@ -4052,8 +4067,21 @@ TODO: Add a setting for these tweaks */ } break; case CMD_EVENT_OVERLAY_NEXT: + /* Switch to the next available overlay screen. */ #ifdef HAVE_OVERLAY - retroarch_overlay_next(); + if (!overlay_ptr) + return false; + + overlay_ptr->index = overlay_ptr->next_index; + overlay_ptr->active = &overlay_ptr->overlays[overlay_ptr->index]; + + { + settings_t *settings = configuration_settings; + input_overlay_load_active(overlay_ptr, settings->floats.input_overlay_opacity); + } + + overlay_ptr->blocked = true; + overlay_ptr->next_index = (unsigned)((overlay_ptr->index + 1) % overlay_ptr->size); #endif break; case CMD_EVENT_DSP_FILTER_INIT: @@ -4071,13 +4099,13 @@ TODO: Add a setting for these tweaks */ } break; case CMD_EVENT_RECORD_DEINIT: - recording_set_state(false); + recording_enable = false; streaming_set_state(false); if (!recording_deinit()) return false; break; case CMD_EVENT_RECORD_INIT: - recording_set_state(true); + recording_enable = true; if (!recording_init()) { command_event(CMD_EVENT_RECORD_DEINIT, NULL); @@ -4204,7 +4232,7 @@ TODO: Add a setting for these tweaks */ struct retro_hw_render_callback *hwr = NULL; command_event_runtime_log_deinit(); content_reset_savestate_backups(); - hwr = video_driver_get_hw_context(); + hwr = video_driver_get_hw_context_internal(); command_event_deinit_core(true); if (hwr) @@ -4228,36 +4256,26 @@ TODO: Add a setting for these tweaks */ break; case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR: #ifdef HAVE_OVERLAY - retroarch_overlay_set_scale_factor(); + { + settings_t *settings = configuration_settings; + input_overlay_set_scale_factor(overlay_ptr, settings->floats.input_overlay_scale); + } #endif break; case CMD_EVENT_OVERLAY_SET_ALPHA_MOD: + /* Sets a modulating factor for alpha channel. Default is 1.0. + * The alpha factor is applied for all overlays. */ #ifdef HAVE_OVERLAY - retroarch_overlay_set_alpha_mod(); + { + settings_t *settings = configuration_settings; + input_overlay_set_alpha_mod(overlay_ptr, settings->floats.input_overlay_opacity); + } #endif break; case CMD_EVENT_AUDIO_REINIT: driver_uninit(DRIVER_AUDIO_MASK); drivers_init(DRIVER_AUDIO_MASK); break; - case CMD_EVENT_RESET_CONTEXT: - { - /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we - * need to make sure to keep a copy */ - struct retro_hw_render_callback hwr_copy; - struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); - const struct retro_hw_render_context_negotiation_interface *iface = - video_driver_get_context_negotiation_interface(); - memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); - - driver_uninit(DRIVERS_CMD_ALL); - - memcpy(hwr, &hwr_copy, sizeof(*hwr)); - video_driver_set_context_negotiation_interface(iface); - - drivers_init(DRIVERS_CMD_ALL); - } - break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push(msg_hash_to_str(MSG_VALUE_SHUTTING_DOWN), 1, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO); @@ -7263,7 +7281,7 @@ static bool rarch_environment_cb(unsigned cmd, void *data) const struct retro_hw_render_context_negotiation_interface *iface = (const struct retro_hw_render_context_negotiation_interface*)data; RARCH_LOG("Environ SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE.\n"); - video_driver_set_context_negotiation_interface(iface); + hw_render_context_negotiation = iface; break; } @@ -8828,7 +8846,7 @@ static void recording_dump_frame(const void *data, unsigned width, recording_driver->push_video(recording_data, &ffemu_data); } -bool recording_deinit(void) +static bool recording_deinit(void) { if (!recording_data || !recording_driver) return false; @@ -8852,11 +8870,6 @@ bool recording_is_enabled(void) return recording_enable; } -void recording_set_state(bool state) -{ - recording_enable = state; -} - bool streaming_is_enabled(void) { return streaming_enable; @@ -8875,7 +8888,7 @@ static bool video_driver_gpu_record_init(unsigned size) return true; } -void video_driver_gpu_record_deinit(void) +static void video_driver_gpu_record_deinit(void) { free(video_driver_record_gpu_buffer); video_driver_record_gpu_buffer = NULL; @@ -8888,7 +8901,7 @@ void video_driver_gpu_record_deinit(void) * * Returns: true (1) if successful, otherwise false (0). **/ -bool recording_init(void) +static bool recording_init(void) { char output[PATH_MAX_LENGTH]; char buf[PATH_MAX_LENGTH]; @@ -9391,7 +9404,7 @@ static bool bsv_movie_init_handle(const char *path, return true; } -bool bsv_movie_init(void) +static bool bsv_movie_init(void) { bool set_granularity = false; @@ -9460,7 +9473,7 @@ void bsv_movie_set_path(const char *path) path, sizeof(bsv_movie_state.movie_path)); } -void bsv_movie_deinit(void) +static void bsv_movie_deinit(void) { if (!bsv_movie_state_handle) return; @@ -9514,7 +9527,7 @@ static bool runloop_check_movie_init(void) return true; } -bool bsv_movie_check(void) +static bool bsv_movie_check(void) { if (!bsv_movie_state_handle) return runloop_check_movie_init(); @@ -10333,51 +10346,13 @@ static void input_poll_overlay(input_overlay_t *ol, float opacity, input_overlay_poll_clear(ol, opacity); } -/** - * retroarch_overlay_next: - * @ol : Overlay handle. - * - * Switch to the next available overlay - * screen. - **/ -void retroarch_overlay_next(void) -{ - settings_t *settings = configuration_settings; - float opacity = settings->floats.input_overlay_opacity; - - if (!overlay_ptr) - return; - - overlay_ptr->index = overlay_ptr->next_index; - overlay_ptr->active = &overlay_ptr->overlays[overlay_ptr->index]; - - input_overlay_load_active(overlay_ptr, opacity); - - overlay_ptr->blocked = true; - overlay_ptr->next_index = (unsigned)((overlay_ptr->index + 1) % overlay_ptr->size); -} - -void retroarch_overlay_set_scale_factor(void) -{ - settings_t *settings = configuration_settings; - input_overlay_set_scale_factor(overlay_ptr, settings->floats.input_overlay_scale); -} - -void retroarch_overlay_set_alpha_mod(void) -{ -#ifdef HAVE_OVERLAY - settings_t *settings = configuration_settings; - input_overlay_set_alpha_mod(overlay_ptr, settings->floats.input_overlay_opacity); -#endif -} - -void retroarch_overlay_deinit(void) +static void retroarch_overlay_deinit(void) { input_overlay_free(overlay_ptr); overlay_ptr = NULL; } -void retroarch_overlay_init(void) +static void retroarch_overlay_init(void) { settings_t *settings = configuration_settings; #if defined(GEKKO) @@ -16191,12 +16166,6 @@ bool audio_driver_has_callback(void) return false; } -bool audio_driver_toggle_mute(void) -{ - audio_driver_mute_enable = !audio_driver_mute_enable; - return true; -} - #ifdef HAVE_AUDIOMIXER bool audio_driver_mixer_toggle_mute(void) { @@ -16214,7 +16183,7 @@ static INLINE bool audio_driver_alive(void) return false; } -bool audio_driver_start(bool is_shutdown) +static bool audio_driver_start(bool is_shutdown) { if (!current_audio || !current_audio->start || !audio_driver_context_audio_data) @@ -16231,7 +16200,7 @@ error: return false; } -bool audio_driver_stop(void) +static bool audio_driver_stop(void) { if (!current_audio || !current_audio->stop || !audio_driver_context_audio_data) @@ -17638,7 +17607,7 @@ void video_driver_hide_mouse(void) video_driver_poke->show_mouse(video_driver_data, false); } -void video_driver_set_nonblock_state(bool toggle) +static void video_driver_set_nonblock_state(bool toggle) { if (current_video->set_nonblock_state) current_video->set_nonblock_state(video_driver_data, toggle); @@ -17825,6 +17794,24 @@ void video_driver_save_settings(config_file_t *conf) global->console.screen.flicker_filter_index); } +static void video_driver_reinit_context(void) +{ + /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we + * need to make sure to keep a copy */ + struct retro_hw_render_callback hwr_copy; + struct retro_hw_render_callback *hwr = video_driver_get_hw_context_internal(); + const struct retro_hw_render_context_negotiation_interface *iface = + video_driver_get_context_negotiation_interface(); + memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); + + driver_uninit(DRIVERS_CMD_ALL); + + memcpy(hwr, &hwr_copy, sizeof(*hwr)); + hw_render_context_negotiation = iface; + + drivers_init(DRIVERS_CMD_ALL); +} + void video_driver_reinit(void) { struct retro_hw_render_callback *hwr = @@ -17836,7 +17823,7 @@ void video_driver_reinit(void) video_driver_cache_context = false; video_driver_cache_context_ack = false; - command_event(CMD_EVENT_RESET_CONTEXT, NULL); + video_driver_reinit_context(); video_driver_cache_context = false; } @@ -17857,12 +17844,6 @@ const struct retro_hw_render_context_negotiation_interface * return hw_render_context_negotiation; } -void video_driver_set_context_negotiation_interface( - const struct retro_hw_render_context_negotiation_interface *iface) -{ - hw_render_context_negotiation = iface; -} - bool video_driver_is_video_cache_context(void) { return video_driver_cache_context; @@ -17873,11 +17854,6 @@ void video_driver_set_video_cache_context_ack(void) video_driver_cache_context_ack = true; } -void video_driver_unset_video_cache_context_ack(void) -{ - video_driver_cache_context_ack = false; -} - bool video_driver_get_viewport_info(struct video_viewport *viewport) { if (!current_video || !current_video->viewport_info) @@ -19659,8 +19635,7 @@ static void drivers_init(int flags) if (!video_driver_cache_context_ack && hwr->context_reset) hwr->context_reset(); - video_driver_unset_video_cache_context_ack(); - + video_driver_cache_context_ack = false; runloop_frame_time_last = 0; } @@ -21106,7 +21081,7 @@ static void retroarch_parse_input_and_config(int argc, char *argv[]) strlcpy(global->record.path, optarg, sizeof(global->record.path)); if (recording_enable) - recording_set_state(true); + recording_enable = true; break; #ifdef HAVE_DYNAMIC diff --git a/retroarch.h b/retroarch.h index d108af0c85..2c4d2a7c64 100644 --- a/retroarch.h +++ b/retroarch.h @@ -537,8 +537,6 @@ const void *audio_driver_find_handle(int index); **/ const char *audio_driver_find_ident(int index); -void audio_driver_set_nonblocking_state(bool enable); - /** * config_get_audio_driver_options: * @@ -564,12 +562,6 @@ bool audio_driver_callback(void); bool audio_driver_has_callback(void); -bool audio_driver_toggle_mute(void); - -bool audio_driver_start(bool is_shutdown); - -bool audio_driver_stop(void); - void audio_driver_frame_is_reverse(void); void audio_set_float(enum audio_action action, float val); @@ -766,21 +758,8 @@ const void *record_driver_find_handle(int idx); **/ const char *record_driver_find_ident(int idx); -bool recording_deinit(void); - -/** - * recording_init: - * - * Initializes recording. - * - * Returns: true (1) if successful, otherwise false (0). - **/ -bool recording_init(void); - bool recording_is_enabled(void); -void recording_set_state(bool state); - void streaming_set_state(bool state); bool recording_is_enabled(void); @@ -1582,45 +1561,64 @@ bool video_driver_has_focus(void); bool video_driver_cached_frame_has_valid_framebuffer(void); void video_driver_set_cached_frame_ptr(const void *data); + void video_driver_set_stub_frame(void); + void video_driver_unset_stub_frame(void); bool video_driver_supports_viewport_read(void); bool video_driver_prefer_viewport_read(void); + bool video_driver_supports_read_frame_raw(void); + void video_driver_set_viewport_config(void); + void video_driver_set_viewport_square_pixel(void); + void video_driver_set_viewport_core(void); + void video_driver_reset_custom_viewport(void); + void video_driver_set_rgba(void); + void video_driver_unset_rgba(void); + bool video_driver_supports_rgba(void); + bool video_driver_get_next_video_out(void); + bool video_driver_get_prev_video_out(void); + void video_driver_monitor_reset(void); + void video_driver_set_aspect_ratio(void); + void video_driver_update_viewport(struct video_viewport* vp, bool force_full, bool keep_aspect); + void video_driver_show_mouse(void); + void video_driver_hide_mouse(void); -void video_driver_set_nonblock_state(bool toggle); + void video_driver_apply_state_changes(void); + bool video_driver_read_viewport(uint8_t *buffer, bool is_idle); + bool video_driver_cached_frame(void); + void video_driver_default_settings(void); + void video_driver_load_settings(config_file_t *conf); + void video_driver_save_settings(config_file_t *conf); + bool video_driver_is_hw_context(void); + struct retro_hw_render_callback *video_driver_get_hw_context(void); const struct retro_hw_render_context_negotiation_interface *video_driver_get_context_negotiation_interface(void); -void video_driver_set_context_negotiation_interface(const struct - retro_hw_render_context_negotiation_interface *iface); - -void video_driver_gpu_record_deinit(void); - bool video_driver_is_video_cache_context(void); void video_driver_set_video_cache_context_ack(void); @@ -1701,8 +1699,6 @@ void video_driver_get_size(unsigned *width, unsigned *height); void video_driver_set_size(unsigned *width, unsigned *height); -void video_driver_unset_video_cache_context_ack(void); - float video_driver_get_aspect_ratio(void); void video_driver_set_aspect_ratio_value(float value); @@ -2009,16 +2005,10 @@ extern const shader_backend_t gl_cg_backend; /* BSV Movie */ -void bsv_movie_deinit(void); - -bool bsv_movie_init(void); - void bsv_movie_frame_rewind(void); void bsv_movie_set_path(const char *path); -bool bsv_movie_check(void); - /* Location */ typedef struct location_driver @@ -2128,16 +2118,6 @@ const void *camera_driver_find_handle(int index); **/ const char *camera_driver_find_ident(int index); -void retroarch_overlay_next(void); - -void retroarch_overlay_set_scale_factor(void); - -void retroarch_overlay_set_alpha_mod(void); - -void retroarch_overlay_deinit(void); - -void retroarch_overlay_init(void); - RETRO_END_DECLS #endif