From 96ae2e98826f5842f717effdd98dd007ac9f3b4f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 15 Mar 2015 02:00:11 +0100 Subject: [PATCH] Move code over to runloop.h --- general.h | 72 +------------------------------------ menu/menu_entries_cbs_ok.c | 13 +++---- retroarch.c | 11 ++---- runloop.h | 74 ++++++++++++++++++++++++++++++++++++++ runloop_data.c | 19 ++++++++-- settings.c | 2 ++ 6 files changed, 104 insertions(+), 87 deletions(-) diff --git a/general.h b/general.h index 4168f5f314..749399d0a4 100644 --- a/general.h +++ b/general.h @@ -33,12 +33,6 @@ #include #include "gfx/video_viewport.h" -#include -#ifndef IS_SALAMANDER -#include -#include -#endif - #include "playlist.h" #ifdef HAVE_CONFIG_H @@ -404,55 +398,7 @@ typedef struct rarch_resolution #define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024) #define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024) -typedef int (*transfer_cb_t )(void *data, size_t len); - -typedef struct nbio_image_handle -{ -#ifndef IS_SALAMANDER - struct texture_image ti; -#endif - bool is_blocking; - bool is_blocking_on_processing; - bool is_finished; - bool is_finished_with_processing; - transfer_cb_t cb; - struct rpng_t *handle; - unsigned processing_pos_increment; - unsigned pos_increment; - uint64_t frame_count; - uint64_t processing_frame_count; - int processing_final_state; - msg_queue_t *msg_queue; -} nbio_image_handle_t; - -typedef struct nbio_handle -{ - nbio_image_handle_t image; - bool is_blocking; - bool is_finished; - transfer_cb_t cb; - struct nbio_t *handle; - unsigned pos_increment; - uint64_t frame_count; - msg_queue_t *msg_queue; -} nbio_handle_t; - -#ifdef HAVE_NETWORKING -typedef struct http_handle -{ - struct - { - struct http_connection_t *handle; - transfer_cb_t cb; - char elem1[PATH_MAX_LENGTH]; - } connection; - msg_queue_t *msg_queue; - struct http_t *handle; - transfer_cb_t cb; -} http_handle_t; -#endif - -/* All runloop-related globals go here. */ +/* All libretro runloop-related globals go here. */ struct runloop { @@ -462,22 +408,6 @@ struct runloop bool is_menu; bool is_slowmotion; - struct - { -#ifdef HAVE_NETWORKING - http_handle_t http; -#endif - -#ifdef HAVE_LIBRETRODB - struct - { - } db; -#endif - - nbio_handle_t nbio; - - } data; - struct { struct diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index cebb1edbb8..522e4fc607 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -22,6 +22,7 @@ #include "menu_navigation.h" #include "../retroarch.h" +#include "../runloop.h" #ifdef HAVE_NETWORKING #include "../net_http.h" @@ -284,8 +285,8 @@ static int action_ok_core_updater_list(const char *path, fill_pathname_join(url_path, g_settings.network.buildbot_url, ".index", sizeof(url_path)); - msg_queue_clear(g_runloop.data.http.msg_queue); - msg_queue_push_string_list(g_runloop.data.http.msg_queue, url_path, "cb_core_updater_list", 0, 1); + msg_queue_clear(g_data_runloop.http.msg_queue); + msg_queue_push_string_list(g_data_runloop.http.msg_queue, url_path, "cb_core_updater_list", 0, 1); #endif return menu_list_push_stack_refresh( @@ -423,8 +424,8 @@ static int action_ok_menu_wallpaper_load(const char *path, { strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper)); - msg_queue_clear(g_runloop.data.nbio.image.msg_queue); - msg_queue_push_string_list(g_runloop.data.nbio.image.msg_queue, wallpaper_path, "cb_menu_wallpaper", 0, 1); + msg_queue_clear(g_data_runloop.nbio.image.msg_queue); + msg_queue_push_string_list(g_data_runloop.nbio.image.msg_queue, wallpaper_path, "cb_menu_wallpaper", 0, 1); } menu_list_pop_stack_by_needle(menu->menu_list, setting->name); @@ -900,8 +901,8 @@ static int action_ok_core_updater_download(const char *path, msg_queue_clear(g_runloop.msg_queue); msg_queue_push(g_runloop.msg_queue, msg, 1, 90); - msg_queue_clear(g_runloop.data.http.msg_queue); - msg_queue_push_string_list(g_runloop.data.http.msg_queue, core_path, "cb_core_updater_download", 0, 1); + msg_queue_clear(g_data_runloop.http.msg_queue); + msg_queue_push_string_list(g_data_runloop.http.msg_queue, core_path, "cb_core_updater_download", 0, 1); #endif return 0; } diff --git a/retroarch.c b/retroarch.c index 323e2abcbb..420ee98e48 100644 --- a/retroarch.c +++ b/retroarch.c @@ -29,6 +29,7 @@ #include #include "general.h" #include "retroarch.h" +#include "runloop.h" #include "settings.h" #include #include "screenshot.h" @@ -1626,6 +1627,7 @@ static void main_clear_state_extern(void) memset(&g_extern, 0, sizeof(g_extern)); memset(&g_runloop, 0, sizeof(g_runloop)); + memset(&g_data_runloop, 0, sizeof(g_data_runloop)); } /** @@ -2650,14 +2652,7 @@ bool rarch_main_command(unsigned cmd) rarch_main_command(RARCH_CMD_MSG_QUEUE_DEINIT); if (!g_runloop.msg_queue) rarch_assert(g_runloop.msg_queue = msg_queue_new(8)); -#ifdef HAVE_NETWORKING - if (!g_runloop.data.http.msg_queue) - rarch_assert(g_runloop.data.http.msg_queue = msg_queue_new(8)); -#endif - if (!g_runloop.data.nbio.msg_queue) - rarch_assert(g_runloop.data.nbio.msg_queue = msg_queue_new(8)); - if (!g_runloop.data.nbio.image.msg_queue) - rarch_assert(g_runloop.data.nbio.image.msg_queue = msg_queue_new(8)); + rarch_main_data_init_queues(); break; case RARCH_CMD_BSV_MOVIE_DEINIT: if (g_extern.bsv.movie) diff --git a/runloop.h b/runloop.h index 0a6d6a4e56..7fa9874445 100644 --- a/runloop.h +++ b/runloop.h @@ -17,10 +17,82 @@ #ifndef __RETROARCH_RUNLOOP_H #define __RETROARCH_RUNLOOP_H +#include +#include +#include +#include + #ifdef __cplusplus extern "C" { #endif +typedef int (*transfer_cb_t )(void *data, size_t len); + +typedef struct nbio_image_handle +{ +#ifndef IS_SALAMANDER + struct texture_image ti; +#endif + bool is_blocking; + bool is_blocking_on_processing; + bool is_finished; + bool is_finished_with_processing; + transfer_cb_t cb; + struct rpng_t *handle; + unsigned processing_pos_increment; + unsigned pos_increment; + uint64_t frame_count; + uint64_t processing_frame_count; + int processing_final_state; + msg_queue_t *msg_queue; +} nbio_image_handle_t; + +typedef struct nbio_handle +{ + nbio_image_handle_t image; + bool is_blocking; + bool is_finished; + transfer_cb_t cb; + struct nbio_t *handle; + unsigned pos_increment; + uint64_t frame_count; + msg_queue_t *msg_queue; +} nbio_handle_t; + +#ifdef HAVE_NETWORKING +typedef struct http_handle +{ + struct + { + struct http_connection_t *handle; + transfer_cb_t cb; + char elem1[PATH_MAX_LENGTH]; + } connection; + msg_queue_t *msg_queue; + struct http_t *handle; + transfer_cb_t cb; +} http_handle_t; +#endif + +/* All data runloop-related globals go here. */ + +struct data_runloop +{ +#ifdef HAVE_NETWORKING + http_handle_t http; +#endif + +#ifdef HAVE_LIBRETRODB + struct + { + } db; +#endif + + nbio_handle_t nbio; +}; + +extern struct data_runloop g_data_runloop; + /** * rarch_main_iterate: * @@ -33,6 +105,8 @@ int rarch_main_iterate(void); void rarch_main_data_iterate(void); +void rarch_main_data_init_queues(void); + #ifdef __cplusplus } #endif diff --git a/runloop_data.c b/runloop_data.c index ec486cde20..0c9ffd2ea3 100644 --- a/runloop_data.c +++ b/runloop_data.c @@ -13,7 +13,10 @@ * If not, see . */ +#include +#include "runloop.h" #include "general.h" +#include "input/input_overlay.h" #ifdef HAVE_NETWORKING #include "net_http.h" @@ -643,14 +646,26 @@ static void rarch_main_data_overlay_iterate(void) } #endif +void rarch_main_data_init_queues(void) +{ +#ifdef HAVE_NETWORKING + if (!g_data_runloop.http.msg_queue) + rarch_assert(g_data_runloop.http.msg_queue = msg_queue_new(8)); +#endif + if (!g_data_runloop.nbio.msg_queue) + rarch_assert(g_data_runloop.nbio.msg_queue = msg_queue_new(8)); + if (!g_data_runloop.nbio.image.msg_queue) + rarch_assert(g_data_runloop.nbio.image.msg_queue = msg_queue_new(8)); +} + void rarch_main_data_iterate(void) { #ifdef HAVE_OVERLAY rarch_main_data_overlay_iterate(); #endif - rarch_main_data_nbio_iterate(&g_runloop.data.nbio); + rarch_main_data_nbio_iterate(&g_data_runloop.nbio); #ifdef HAVE_NETWORKING - rarch_main_data_http_iterate(&g_runloop.data.http); + rarch_main_data_http_iterate(&g_data_runloop.http); #endif rarch_main_data_db_iterate(); } diff --git a/settings.c b/settings.c index f80a32512f..d0bb85adc7 100644 --- a/settings.c +++ b/settings.c @@ -26,6 +26,7 @@ #include "gfx/video_viewport.h" #include "settings.h" #include "general.h" +#include "runloop.h" #ifdef HAVE_CONFIG_H #include "config.h" @@ -36,6 +37,7 @@ struct settings g_settings; struct global g_extern; struct runloop g_runloop; +struct data_runloop g_data_runloop; struct defaults g_defaults; /**