mirror of
https://github.com/libretro/RetroArch
synced 2025-02-06 18:40:49 +00:00
(runloop) Move data sources to struct
This commit is contained in:
parent
f2d2e9a4f1
commit
c45d3f60a1
@ -433,6 +433,8 @@ struct runloop
|
|||||||
bool is_menu;
|
bool is_menu;
|
||||||
bool is_slowmotion;
|
bool is_slowmotion;
|
||||||
|
|
||||||
|
struct
|
||||||
|
{
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
@ -454,6 +456,10 @@ struct runloop
|
|||||||
} db;
|
} db;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
nbio_handle_t nbio;
|
||||||
|
|
||||||
|
} data;
|
||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
struct
|
struct
|
||||||
@ -478,7 +484,6 @@ struct runloop
|
|||||||
uint64_t frame_time_samples_count;
|
uint64_t frame_time_samples_count;
|
||||||
} measure_data;
|
} measure_data;
|
||||||
|
|
||||||
nbio_handle_t nbio;
|
|
||||||
msg_queue_t *msg_queue;
|
msg_queue_t *msg_queue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -286,8 +286,8 @@ static int action_ok_core_updater_list(const char *path,
|
|||||||
|
|
||||||
strlcat(url_path, "|cb_core_updater_list", sizeof(url_path));
|
strlcat(url_path, "|cb_core_updater_list", sizeof(url_path));
|
||||||
|
|
||||||
msg_queue_clear(g_runloop.http.msg_queue);
|
msg_queue_clear(g_runloop.data.http.msg_queue);
|
||||||
msg_queue_push(g_runloop.http.msg_queue, url_path, 0, 1);
|
msg_queue_push(g_runloop.data.http.msg_queue, url_path, 0, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return menu_list_push_stack_refresh(
|
return menu_list_push_stack_refresh(
|
||||||
@ -426,8 +426,8 @@ static int action_ok_menu_wallpaper_load(const char *path,
|
|||||||
strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper));
|
strlcpy(g_settings.menu.wallpaper, wallpaper_path, sizeof(g_settings.menu.wallpaper));
|
||||||
strlcat(wallpaper_path, "|cb_menu_wallpaper", sizeof(wallpaper_path));
|
strlcat(wallpaper_path, "|cb_menu_wallpaper", sizeof(wallpaper_path));
|
||||||
|
|
||||||
msg_queue_clear(g_runloop.nbio.image.msg_queue);
|
msg_queue_clear(g_runloop.data.nbio.image.msg_queue);
|
||||||
msg_queue_push(g_runloop.nbio.image.msg_queue, wallpaper_path, 0, 1);
|
msg_queue_push(g_runloop.data.nbio.image.msg_queue, wallpaper_path, 0, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
menu_list_pop_stack_by_needle(menu->menu_list, setting->name);
|
menu_list_pop_stack_by_needle(menu->menu_list, setting->name);
|
||||||
@ -904,8 +904,8 @@ static int action_ok_core_updater_download(const char *path,
|
|||||||
|
|
||||||
strlcat(core_path, "|cb_core_updater_download", sizeof(core_path));
|
strlcat(core_path, "|cb_core_updater_download", sizeof(core_path));
|
||||||
|
|
||||||
msg_queue_clear(g_runloop.http.msg_queue);
|
msg_queue_clear(g_runloop.data.http.msg_queue);
|
||||||
msg_queue_push(g_runloop.http.msg_queue, core_path, 0, 1);
|
msg_queue_push(g_runloop.data.http.msg_queue, core_path, 0, 1);
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
12
retroarch.c
12
retroarch.c
@ -2618,13 +2618,13 @@ bool rarch_main_command(unsigned cmd)
|
|||||||
if (!g_runloop.msg_queue)
|
if (!g_runloop.msg_queue)
|
||||||
rarch_assert(g_runloop.msg_queue = msg_queue_new(8));
|
rarch_assert(g_runloop.msg_queue = msg_queue_new(8));
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (!g_runloop.http.msg_queue)
|
if (!g_runloop.data.http.msg_queue)
|
||||||
rarch_assert(g_runloop.http.msg_queue = msg_queue_new(8));
|
rarch_assert(g_runloop.data.http.msg_queue = msg_queue_new(8));
|
||||||
#endif
|
#endif
|
||||||
if (!g_runloop.nbio.msg_queue)
|
if (!g_runloop.data.nbio.msg_queue)
|
||||||
rarch_assert(g_runloop.nbio.msg_queue = msg_queue_new(8));
|
rarch_assert(g_runloop.data.nbio.msg_queue = msg_queue_new(8));
|
||||||
if (!g_runloop.nbio.image.msg_queue)
|
if (!g_runloop.data.nbio.image.msg_queue)
|
||||||
rarch_assert(g_runloop.nbio.image.msg_queue = msg_queue_new(8));
|
rarch_assert(g_runloop.data.nbio.image.msg_queue = msg_queue_new(8));
|
||||||
break;
|
break;
|
||||||
case RARCH_CMD_BSV_MOVIE_DEINIT:
|
case RARCH_CMD_BSV_MOVIE_DEINIT:
|
||||||
if (g_extern.bsv.movie)
|
if (g_extern.bsv.movie)
|
||||||
|
@ -37,7 +37,7 @@ static int rarch_main_iterate_http_transfer(void)
|
|||||||
{
|
{
|
||||||
size_t pos = 0, tot = 0;
|
size_t pos = 0, tot = 0;
|
||||||
|
|
||||||
if (!net_http_update(g_runloop.http.handle, &pos, &tot))
|
if (!net_http_update(g_runloop.data.http.handle, &pos, &tot))
|
||||||
{
|
{
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
RARCH_LOG("%.9I64u / %.9I64u \r", (unsigned long long)pos, (unsigned long long)tot);
|
RARCH_LOG("%.9I64u / %.9I64u \r", (unsigned long long)pos, (unsigned long long)tot);
|
||||||
@ -52,22 +52,22 @@ static int rarch_main_iterate_http_transfer(void)
|
|||||||
|
|
||||||
static int rarch_main_iterate_http_conn_transfer(void)
|
static int rarch_main_iterate_http_conn_transfer(void)
|
||||||
{
|
{
|
||||||
if (!net_http_connection_iterate(g_runloop.http.connection.handle))
|
if (!net_http_connection_iterate(g_runloop.data.http.connection.handle))
|
||||||
return -1;
|
return -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int rarch_main_iterate_http_conn_parse(void)
|
static int rarch_main_iterate_http_conn_parse(void)
|
||||||
{
|
{
|
||||||
if (net_http_connection_done(g_runloop.http.connection.handle))
|
if (net_http_connection_done(g_runloop.data.http.connection.handle))
|
||||||
{
|
{
|
||||||
if (g_runloop.http.connection.handle && g_runloop.http.connection.cb)
|
if (g_runloop.data.http.connection.handle && g_runloop.data.http.connection.cb)
|
||||||
g_runloop.http.connection.cb(g_runloop.http.connection.handle, 0);
|
g_runloop.data.http.connection.cb(g_runloop.data.http.connection.handle, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
net_http_connection_free(g_runloop.http.connection.handle);
|
net_http_connection_free(g_runloop.data.http.connection.handle);
|
||||||
|
|
||||||
g_runloop.http.connection.handle = NULL;
|
g_runloop.data.http.connection.handle = NULL;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -75,37 +75,37 @@ static int rarch_main_iterate_http_conn_parse(void)
|
|||||||
static int rarch_main_iterate_http_parse(void)
|
static int rarch_main_iterate_http_parse(void)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
char *data = (char*)net_http_data(g_runloop.http.handle, &len, false);
|
char *data = (char*)net_http_data(g_runloop.data.http.handle, &len, false);
|
||||||
|
|
||||||
if (data && g_runloop.http.cb)
|
if (data && g_runloop.data.http.cb)
|
||||||
g_runloop.http.cb(data, len);
|
g_runloop.data.http.cb(data, len);
|
||||||
|
|
||||||
net_http_delete(g_runloop.http.handle);
|
net_http_delete(g_runloop.data.http.handle);
|
||||||
|
|
||||||
g_runloop.http.handle = NULL;
|
g_runloop.data.http.handle = NULL;
|
||||||
msg_queue_clear(g_runloop.http.msg_queue);
|
msg_queue_clear(g_runloop.data.http.msg_queue);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int cb_http_conn_default(void *data_, size_t len)
|
static int cb_http_conn_default(void *data_, size_t len)
|
||||||
{
|
{
|
||||||
g_runloop.http.handle = net_http_new(g_runloop.http.connection.handle);
|
g_runloop.data.http.handle = net_http_new(g_runloop.data.http.connection.handle);
|
||||||
|
|
||||||
if (!g_runloop.http.handle)
|
if (!g_runloop.data.http.handle)
|
||||||
{
|
{
|
||||||
RARCH_ERR("Could not create new HTTP session handle.\n");
|
RARCH_ERR("Could not create new HTTP session handle.\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_runloop.http.cb = NULL;
|
g_runloop.data.http.cb = NULL;
|
||||||
|
|
||||||
if (g_runloop.http.connection.elem1[0] != '\0')
|
if (g_runloop.data.http.connection.elem1[0] != '\0')
|
||||||
{
|
{
|
||||||
if (!strcmp(g_runloop.http.connection.elem1, "cb_core_updater_download"))
|
if (!strcmp(g_runloop.data.http.connection.elem1, "cb_core_updater_download"))
|
||||||
g_runloop.http.cb = &cb_core_updater_download;
|
g_runloop.data.http.cb = &cb_core_updater_download;
|
||||||
if (!strcmp(g_runloop.http.connection.elem1, "cb_core_updater_list"))
|
if (!strcmp(g_runloop.data.http.connection.elem1, "cb_core_updater_list"))
|
||||||
g_runloop.http.cb = &cb_core_updater_list;
|
g_runloop.data.http.cb = &cb_core_updater_list;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -128,13 +128,13 @@ static int rarch_main_iterate_http_poll(void)
|
|||||||
{
|
{
|
||||||
char elem0[PATH_MAX_LENGTH];
|
char elem0[PATH_MAX_LENGTH];
|
||||||
struct string_list *str_list = NULL;
|
struct string_list *str_list = NULL;
|
||||||
const char *url = msg_queue_pull(g_runloop.http.msg_queue);
|
const char *url = msg_queue_pull(g_runloop.data.http.msg_queue);
|
||||||
|
|
||||||
if (!url)
|
if (!url)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
/* Can only deal with one HTTP transfer at a time for now */
|
/* Can only deal with one HTTP transfer at a time for now */
|
||||||
if (g_runloop.http.handle)
|
if (g_runloop.data.http.handle)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
str_list = string_split(url, "|");
|
str_list = string_split(url, "|");
|
||||||
@ -145,17 +145,17 @@ static int rarch_main_iterate_http_poll(void)
|
|||||||
if (str_list->size > 0)
|
if (str_list->size > 0)
|
||||||
strlcpy(elem0, str_list->elems[0].data, sizeof(elem0));
|
strlcpy(elem0, str_list->elems[0].data, sizeof(elem0));
|
||||||
|
|
||||||
g_runloop.http.connection.handle = net_http_connection_new(elem0);
|
g_runloop.data.http.connection.handle = net_http_connection_new(elem0);
|
||||||
|
|
||||||
if (!g_runloop.http.connection.handle)
|
if (!g_runloop.data.http.connection.handle)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
g_runloop.http.connection.cb = &cb_http_conn_default;
|
g_runloop.data.http.connection.cb = &cb_http_conn_default;
|
||||||
|
|
||||||
if (str_list->size > 1)
|
if (str_list->size > 1)
|
||||||
strlcpy(g_runloop.http.connection.elem1,
|
strlcpy(g_runloop.data.http.connection.elem1,
|
||||||
str_list->elems[1].data,
|
str_list->elems[1].data,
|
||||||
sizeof(g_runloop.http.connection.elem1));
|
sizeof(g_runloop.data.http.connection.elem1));
|
||||||
|
|
||||||
string_list_free(str_list);
|
string_list_free(str_list);
|
||||||
|
|
||||||
@ -533,16 +533,16 @@ void do_data_nbio_state_checks(nbio_handle_t *nbio)
|
|||||||
|
|
||||||
void do_data_state_checks(void)
|
void do_data_state_checks(void)
|
||||||
{
|
{
|
||||||
do_data_nbio_state_checks(&g_runloop.nbio);
|
do_data_nbio_state_checks(&g_runloop.data.nbio);
|
||||||
|
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
if (g_runloop.http.connection.handle)
|
if (g_runloop.data.http.connection.handle)
|
||||||
{
|
{
|
||||||
if (!rarch_main_iterate_http_conn_transfer())
|
if (!rarch_main_iterate_http_conn_transfer())
|
||||||
rarch_main_iterate_http_conn_parse();
|
rarch_main_iterate_http_conn_parse();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (g_runloop.http.handle)
|
if (g_runloop.data.http.handle)
|
||||||
{
|
{
|
||||||
if (!rarch_main_iterate_http_transfer())
|
if (!rarch_main_iterate_http_transfer())
|
||||||
rarch_main_iterate_http_parse();
|
rarch_main_iterate_http_parse();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user