diff --git a/libretro-common/include/queues/message_queue.h b/libretro-common/include/queues/message_queue.h index 7e2b96df9c..560bb488e7 100644 --- a/libretro-common/include/queues/message_queue.h +++ b/libretro-common/include/queues/message_queue.h @@ -56,9 +56,6 @@ msg_queue_t *msg_queue_new(size_t size); void msg_queue_push(msg_queue_t *queue, const char *msg, unsigned prio, unsigned duration); -void msg_queue_push_string_list(msg_queue_t *queue, const char *msg, - const char *msg2, unsigned prio, unsigned duration); - /** * msg_queue_pull: * @queue : pointer to queue object diff --git a/libretro-common/queues/message_queue.c b/libretro-common/queues/message_queue.c index 06ff49c42a..d1cbab7992 100644 --- a/libretro-common/queues/message_queue.c +++ b/libretro-common/queues/message_queue.c @@ -134,18 +134,6 @@ void msg_queue_push(msg_queue_t *queue, const char *msg, } } -void msg_queue_push_string_list(msg_queue_t *queue, const char *msg, - const char *msg2, unsigned prio, unsigned duration) -{ - char new_msg[8192]; - - strlcpy(new_msg, msg, sizeof(new_msg)); - strlcat(new_msg, "|", sizeof(new_msg)); - strlcat(new_msg, msg2, sizeof(new_msg)); - - msg_queue_push(queue, new_msg, prio, duration); -} - /** * msg_queue_clear: * @queue : pointer to queue object diff --git a/menu/menu_entries_cbs_ok.c b/menu/menu_entries_cbs_ok.c index c92067ab5c..0a72a96ff6 100644 --- a/menu/menu_entries_cbs_ok.c +++ b/menu/menu_entries_cbs_ok.c @@ -285,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_data_runloop.http.msg_queue); - msg_queue_push_string_list(g_data_runloop.http.msg_queue, url_path, "cb_core_updater_list", 0, 1); + rarch_main_data_msg_queue_push(DATA_TYPE_HTTP, url_path, "cb_core_updater_list", 0, 1, + true); #endif return menu_list_push_stack_refresh( @@ -424,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_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); + rarch_main_data_msg_queue_push(DATA_TYPE_IMAGE, wallpaper_path, "cb_menu_wallpaper", 0, 1, + true); } menu_list_pop_stack_by_needle(menu->menu_list, setting->name); @@ -900,8 +900,8 @@ static int action_ok_core_updater_download(const char *path, rarch_main_msg_queue_push(msg, 1, 90, true); - 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); + rarch_main_data_msg_queue_push(DATA_TYPE_HTTP, core_path, + "cb_core_updater_download", 0, 1, true); #endif return 0; } diff --git a/runloop.h b/runloop.h index 4a0ba03228..26fb9f7c32 100644 --- a/runloop.h +++ b/runloop.h @@ -37,6 +37,14 @@ extern "C" { typedef int (*transfer_cb_t )(void *data, size_t len); +enum runloop_data_type +{ + DATA_TYPE_NONE = 0, + DATA_TYPE_FILE, + DATA_TYPE_IMAGE, + DATA_TYPE_HTTP, +}; + typedef struct nbio_image_handle { #ifndef IS_SALAMANDER @@ -185,6 +193,10 @@ void rarch_main_msg_queue_free(void); void rarch_main_msg_queue_init(void); +void rarch_main_data_msg_queue_push(unsigned type, + const char *msg, const char *msg2, + unsigned prio, unsigned duration, bool flush); + void rarch_main_data_iterate(void); void rarch_main_data_init_queues(void); diff --git a/runloop_data.c b/runloop_data.c index c4153fabba..62ee91d4c5 100644 --- a/runloop_data.c +++ b/runloop_data.c @@ -662,6 +662,40 @@ void rarch_main_data_init_queues(void) rarch_assert(g_data_runloop.nbio.image.msg_queue = msg_queue_new(8)); } +void rarch_main_data_msg_queue_push(unsigned type, + const char *msg, const char *msg2, + unsigned prio, unsigned duration, bool flush) +{ + char new_msg[PATH_MAX_LENGTH]; + msg_queue_t *queue = NULL; + + strlcpy(new_msg, msg, sizeof(new_msg)); + strlcat(new_msg, "|", sizeof(new_msg)); + strlcat(new_msg, msg2, sizeof(new_msg)); + + switch(type) + { + case DATA_TYPE_NONE: + break; + case DATA_TYPE_FILE: + queue = g_data_runloop.nbio.msg_queue; + break; + case DATA_TYPE_IMAGE: + queue = g_data_runloop.nbio.image.msg_queue; + break; + case DATA_TYPE_HTTP: + queue = g_data_runloop.http.msg_queue; + break; + } + + if (!queue) + return; + + if (flush) + msg_queue_clear(queue); + msg_queue_push(queue, new_msg, prio, duration); +} + void rarch_main_data_iterate(void) { #ifdef HAVE_OVERLAY