Create wrapper functions for passing a message to the runloop's

message queue
This commit is contained in:
twinaphex 2015-03-15 02:47:23 +01:00
parent 96ae2e9882
commit 00239a30d6
47 changed files with 200 additions and 152 deletions

View File

@ -22,6 +22,7 @@
#include "../driver.h"
#include "../general.h"
#include "../retroarch.h"
#include "../runloop.h"
static const audio_driver_t *audio_drivers[] = {
#ifdef HAVE_ALSA

View File

@ -19,6 +19,7 @@
#include "camera_driver.h"
#include "../driver.h"
#include "../general.h"
#include "../runloop.h"
static const camera_driver_t *camera_drivers[] = {
#ifdef HAVE_V4L2

View File

@ -16,6 +16,7 @@
#include "cheats.h"
#include "general.h"
#include "runloop.h"
#include "dynamic.h"
#include <file/config_file.h>
#include <file/file_path.h>
@ -232,7 +233,6 @@ void cheat_manager_free(cheat_manager_t *handle)
void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
{
msg_queue_clear(g_runloop.msg_queue);
char msg[256];
snprintf(msg, sizeof(msg), "Cheat: #%u [%s]: %s",
@ -240,7 +240,7 @@ void cheat_manager_update(cheat_manager_t *handle, unsigned handle_idx)
(handle->cheats[handle_idx].desc) ?
(handle->cheats[handle_idx].desc) : (handle->cheats[handle_idx].code)
);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
}

View File

@ -22,6 +22,7 @@
#endif
#include "general.h"
#include "runloop.h"
#include "compat/strl.h"
#include "compat/posix_string.h"
#include <file/file_path.h>
@ -230,10 +231,8 @@ static bool cmd_set_shader(const char *arg)
if (type == RARCH_SHADER_NONE)
return false;
msg_queue_clear(g_runloop.msg_queue);
snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg);
msg_queue_push(g_runloop.msg_queue, msg, 1, 120);
rarch_main_msg_queue_push(msg, 1, 120, true);
RARCH_LOG("Applying shader \"%s\".\n", arg);
return driver.video->set_shader(driver.video_data, type, arg);

View File

@ -20,6 +20,7 @@
#include "file_ops.h"
#include "file_extract.h"
#include "general.h"
#include "runloop.h"
#include <file/file_path.h>
#include "file_ext.h"
#include <file/dir_list.h>
@ -84,8 +85,7 @@ void database_info_write_rdl_free(database_info_rdl_handle_t *dbl)
string_list_free(dbl->list);
free(dbl);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, "Scanning of directory finished.\n", 1, 180);
rarch_main_msg_queue_push("Scanning of directory finished.\n", 1, 180, true);
}
int database_info_write_rdl_iterate(database_info_rdl_handle_t *dbl)
@ -141,8 +141,7 @@ int database_info_write_rdl_iterate(database_info_rdl_handle_t *dbl)
snprintf(msg, sizeof(msg), "%zu/%zu: Scanning %s...\n",
dbl->list_ptr, dbl->list->size, name);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, true);
crc = crc32_calculate(ret_buf, ret);

View File

@ -17,6 +17,7 @@
#include "driver.h"
#include "general.h"
#include "retroarch.h"
#include "runloop.h"
#include "compat/posix_string.h"
#include "gfx/video_monitor.h"
#include "audio/audio_monitor.h"
@ -281,7 +282,7 @@ bool driver_update_system_av_info(const struct retro_system_av_info *info)
if (driver.recording_data)
{
static const char *msg = "Restarting recording due to driver reinit.";
msg_queue_push(g_runloop.msg_queue, msg, 2, 180);
rarch_main_msg_queue_push(msg, 2, 180, false);
RARCH_WARN("%s\n", msg);
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
rarch_main_command(RARCH_CMD_RECORD_INIT);

View File

@ -31,6 +31,7 @@
#include "libretro_private.h"
#include "dynamic_dummy.h"
#include "retroarch.h"
#include "runloop.h"
#include "input/input_sensor.h"
@ -674,11 +675,7 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
const struct retro_message *msg = (const struct retro_message*)data;
RARCH_LOG("Environ SET_MESSAGE: %s\n", msg->msg);
if (g_runloop.msg_queue)
{
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg->msg, 1, msg->frames);
}
rarch_main_msg_queue_push(msg->msg, 1, msg->frames, true);
break;
}

View File

@ -395,71 +395,6 @@ typedef struct rarch_resolution
unsigned id;
} rarch_resolution_t;
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
/* All libretro runloop-related globals go here. */
struct runloop
{
/* Lifecycle state checks. */
bool is_paused;
bool is_idle;
bool is_menu;
bool is_slowmotion;
struct
{
struct
{
unsigned count;
unsigned max;
struct
{
struct
{
struct
{
bool is_updated;
} label;
struct
{
bool is_active;
} animation;
struct
{
bool dirty;
} framebuf;
struct
{
bool active;
} action;
} menu;
} current;
} video;
struct
{
retro_time_t minimum_time;
retro_time_t last_time;
} limit;
} frames;
struct
{
unsigned buffer_free_samples[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
uint64_t buffer_free_samples_count;
retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
uint64_t frame_time_samples_count;
} measure_data;
msg_queue_t *msg_queue;
};
/* All run-time- / command line flag-related globals go here. */
struct global
@ -783,7 +718,6 @@ struct global
/* Public data structures. */
extern struct settings g_settings;
extern struct runloop g_runloop;
extern struct global g_extern;
extern struct defaults g_defaults;

View File

@ -32,6 +32,7 @@
#include "../../general.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include "../video_viewport.h"
#include "../video_monitor.h"
#include "../font_renderer_driver.h"
@ -1432,7 +1433,7 @@ static bool exynos_gfx_frame(void *data, const void *frame, unsigned width,
char buffer[128], buffer_fps[128];
video_monitor_get_fps(buffer, sizeof(buffer),
g_settings.fps_show ? buffer_fps : NULL, sizeof(buffer_fps));
msg_queue_push(g_runloop.msg_queue, buffer_fps, 1, 1);
rarch_main_msg_queue_push(buffer_fps, 1, 1, false);
}
/* If at this point the dimension parameters are still zero, setup some *

View File

@ -30,6 +30,7 @@
#include <string.h>
#include "../../general.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include <math.h>
#ifdef HAVE_CONFIG_H

View File

@ -21,6 +21,7 @@
#include <string.h>
#include "../../general.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include "../../performance.h"
#include <gfx/scaler/scaler.h>
#include "../video_viewport.h"

View File

@ -16,6 +16,7 @@
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
@ -271,7 +272,7 @@ static void android_gfx_ctx_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static bool android_gfx_ctx_set_video_mode(void *data,

View File

@ -16,6 +16,7 @@
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
@ -358,7 +359,7 @@ static void gfx_ctx_qnx_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static bool gfx_ctx_qnx_set_video_mode(void *data,

View File

@ -18,6 +18,7 @@
#include "../d3d/d3d.h"
#include "win32_common.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#ifdef _MSC_VER
@ -144,7 +145,7 @@ static void gfx_ctx_d3d_update_title(void *data)
stat.dwAvailPhys/(1024.0f*1024.0f), stat.dwTotalPhys/(1024.0f*1024.0f));
strlcat(buffer_fps, mem, sizeof(buffer_fps));
#endif
msg_queue_push(g_runloop.msg_queue, buffer_fps, 1, 1);
rarch_main_msg_queue_push(buffer_fps, 1, 1, false);
}
}

View File

@ -19,6 +19,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
#include <file/dir_list.h>
@ -268,7 +269,7 @@ static void gfx_ctx_drm_egl_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push( buf_fps, 1, 1, false);
}
static void gfx_ctx_drm_egl_get_video_size(void *data, unsigned *width, unsigned *height)

View File

@ -15,6 +15,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../video_monitor.h"
@ -92,7 +93,7 @@ static void gfx_ctx_emscripten_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_emscripten_get_video_size(void *data,

View File

@ -15,6 +15,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
#include "x11_common.h"
@ -212,7 +213,7 @@ static void gfx_ctx_glx_update_window_title(void *data)
buf_fps, sizeof(buf_fps)))
XStoreName(glx->g_dpy, glx->g_win, buf);
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_glx_get_video_size(void *data,

View File

@ -15,6 +15,7 @@
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
@ -204,7 +205,7 @@ static void gfx_ctx_mali_fbdev_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static bool gfx_ctx_mali_fbdev_set_video_mode(void *data,

View File

@ -15,6 +15,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../../ps3/sdk_defines.h"
#ifdef HAVE_LIBDBGFONT
@ -220,7 +221,7 @@ static void gfx_ctx_ps3_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_ps3_get_video_size(void *data,

View File

@ -15,6 +15,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
@ -290,7 +291,7 @@ static void sdl_ctx_update_window_title(void *data)
#endif
}
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void sdl_ctx_check_window(void *data, bool *quit, bool *resize,unsigned *width,

View File

@ -15,6 +15,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../video_monitor.h"
@ -124,7 +125,7 @@ static void gfx_ctx_vc_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_vc_get_video_size(void *data,

View File

@ -16,6 +16,7 @@
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
@ -193,7 +194,7 @@ static void gfx_ctx_vivante_update_window_title(void *data)
video_monitor_get_fps(buf, sizeof(buf),
buf_fps, sizeof(buf_fps));
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static bool gfx_ctx_vivante_set_video_mode(void *data,

View File

@ -16,6 +16,7 @@
#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"
@ -341,7 +342,7 @@ static void gfx_ctx_wl_update_window_title(void *data)
wl_shell_surface_set_title(wl->g_shell_surf, buf);
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_wl_get_video_size(void *data,

View File

@ -22,6 +22,7 @@
#endif
#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../video_monitor.h"
@ -352,7 +353,7 @@ static void gfx_ctx_wgl_update_window_title(void *data)
buf_fps, sizeof(buf_fps)))
SetWindowText(g_hwnd, buf);
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_wgl_get_video_size(void *data, unsigned *width, unsigned *height)

View File

@ -19,6 +19,7 @@
*/
#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
#include "x11_common.h"
@ -227,7 +228,7 @@ static void gfx_ctx_xegl_update_window_title(void *data)
buf_fps, sizeof(buf_fps)))
XStoreName(g_dpy, g_win, buf);
if (g_settings.fps_show)
msg_queue_push(g_runloop.msg_queue, buf_fps, 1, 1);
rarch_main_msg_queue_push(buf_fps, 1, 1, false);
}
static void gfx_ctx_xegl_get_video_size(void *data,

View File

@ -22,6 +22,7 @@
#include "video_monitor.h"
#include "../general.h"
#include "../retroarch.h"
#include "../runloop.h"
static const video_driver_t *video_drivers[] = {
#ifdef HAVE_OPENGL

View File

@ -17,6 +17,7 @@
#include "video_monitor.h"
#include "../general.h"
#include "../retroarch.h"
#include "../runloop.h"
#include "../performance.h"
void video_monitor_adjust_system_rates(void)
@ -59,7 +60,7 @@ void video_monitor_set_refresh_rate(float hz)
{
char msg[PATH_MAX_LENGTH];
snprintf(msg, sizeof(msg), "Setting refresh rate to: %.3f Hz.", hz);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
RARCH_LOG("%s\n", msg);
g_settings.video.refresh_rate = hz;

View File

@ -17,12 +17,12 @@
#include "video_thread_wrapper.h"
#include "video_viewport.h"
#include "../performance.h"
#include "../runloop.h"
#include <file/dir_list.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
static void *thread_init_never_call(const video_info_t *video,
const input_driver_t **input, void **input_data)
{

View File

@ -20,6 +20,7 @@
#include "../input_autodetect.h"
#include "../input_common.h"
#include "../../general.h"
#include "../../runloop.h"
struct pad_connection
{
@ -127,7 +128,7 @@ static void remove_device(void* context, IOReturn result, void* sender)
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.",
connection->slot, "N/A");
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
RARCH_LOG("[apple_input]: %s\n", msg);
apple->buttons[connection->slot] = 0;

View File

@ -17,6 +17,7 @@
#include "../input_autodetect.h"
#include "../input_common.h"
#include "../../general.h"
#include "../../runloop.h"
#include <unistd.h>
#include <stdint.h>
#include <string.h>
@ -97,7 +98,7 @@ static bool linuxraw_joypad_init_pad(const char *path, struct linuxraw_joypad *p
{
char msg[512];
snprintf(msg, sizeof(msg), "Joypad #%u (%s) connected.", (unsigned)(pad - linuxraw_pads), pad->ident);
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
}
#endif
}
@ -153,7 +154,7 @@ static void handle_plugged_pad(void)
{
char msg[512];
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", idx, linuxraw_pads[idx].ident);
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
}
#endif

View File

@ -16,6 +16,7 @@
#include "../input_autodetect.h"
#include "../input_common.h"
#include "../../general.h"
#include "../../runloop.h"
#include <unistd.h>
#include <stdint.h>
#include <string.h>
@ -457,7 +458,7 @@ static void check_device(struct udev_device *dev, const char *path, bool hotplug
{
char msg[512];
snprintf(msg, sizeof(msg), "Joypad #%u (%s) connected.", pad, path);
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
RARCH_LOG("[udev]: %s\n", msg);
}
#else
@ -482,7 +483,7 @@ static void udev_joypad_remove_device(const char *path)
#ifndef IS_JOYCONFIG
char msg[512];
snprintf(msg, sizeof(msg), "Joypad #%u (%s) disconnected.", i, udev_pads[i].ident);
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
RARCH_LOG("[udev]: %s\n", msg);
#endif
free_pad(i, true);

View File

@ -22,6 +22,7 @@
#include <ctype.h>
#include "../general.h"
#include "../runloop.h"
static void input_autoconfigure_joypad_conf(config_file_t *conf,
struct retro_keybind *binds)
@ -91,7 +92,7 @@ found:
idx, name);
if (!block_osd_spam)
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
rarch_main_msg_queue_push(msg, 0, 60, false);
RARCH_LOG("%s\n", msg);
return true;

View File

@ -25,6 +25,7 @@
#include <ctype.h>
#include <errno.h>
#include "general.h"
#include "runloop.h"
#include "retroarch.h"
#include "performance.h"
#include "input/keyboard_line.h"
@ -136,7 +137,7 @@ static void video_frame(const void *data, unsigned width,
)
recording_dump_frame(data, width, height, pitch);
msg = msg_queue_pull(g_runloop.msg_queue);
msg = rarch_main_msg_queue_pull();
driver.current_msg = msg;
if (video_frame_filter(data, width, height, pitch,

View File

@ -19,6 +19,7 @@
#include "location_driver.h"
#include "../driver.h"
#include "../general.h"
#include "../runloop.h"
static const location_driver_t *location_drivers[] = {
#ifdef ANDROID
@ -147,8 +148,7 @@ bool driver_location_start(void)
if (g_settings.location.allow)
return driver.location->start(driver.location_data);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, "Location is explicitly disabled.\n", 1, 180);
rarch_main_msg_queue_push("Location is explicitly disabled.\n", 1, 180, true);
}
return false;
}

View File

@ -21,6 +21,7 @@
#include "../dynamic.h"
#include "../frontend/frontend.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include "../../performance.h"
#include <file/file_path.h>
@ -111,7 +112,7 @@ static void push_to_history_playlist(void)
fill_pathname_base(tmp, g_extern.fullpath, sizeof(tmp));
snprintf(str, sizeof(str), "INFO - Loading %s ...", tmp);
msg_queue_push(g_runloop.msg_queue, str, 1, 1);
rarch_main_msg_queue_push(str, 1, 1, false);
}
content_playlist_push(g_defaults.history,

View File

@ -24,6 +24,7 @@
#include <ctype.h>
#include <boolean.h>
#include "../../general.h"
#include "../../runloop.h"
#include "menu_input.h"
#if defined(HAVE_CG) || defined(HAVE_HLSL) || defined(HAVE_GLSL)

View File

@ -19,6 +19,7 @@
#include <string.h>
#include <compat/strl.h>
#include "../general.h"
#include "../runloop.h"
/* from https://github.com/kikito/tween.lua/blob/master/tween.lua */

View File

@ -25,6 +25,7 @@
#include "../file_ops.h"
#include "../config.def.h"
#include "../retroarch.h"
#include "../runloop.h"
#ifdef HAVE_NETWORKING
#include "../net_http.h"
@ -115,8 +116,7 @@ int cb_core_updater_download(void *data_, size_t len)
snprintf(msg, sizeof(msg), "Download complete: %s.",
core_updater_path);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg, 1, 90);
rarch_main_msg_queue_push(msg, 1, 90, true);
#ifdef HAVE_ZLIB
file_ext = path_get_extension(output_path);

View File

@ -23,6 +23,7 @@
#include "menu_navigation.h"
#include "../retroarch.h"
#include "../runloop.h"
#include "../input/input_autodetect.h"

View File

@ -20,6 +20,7 @@
#include "menu_shader.h"
#include "../performance.h"
#include "../runloop.h"
static void menu_action_setting_disp_set_label_cheat_num_passes(
file_list_t* list,

View File

@ -21,6 +21,7 @@
#include "net_compat.h"
#include "netplay.h"
#include "general.h"
#include "runloop.h"
#include "autosave.h"
#include "dynamic.h"
#include <queues/message_queue.h>
@ -122,8 +123,7 @@ struct netplay
static void warn_hangup(void)
{
RARCH_WARN("Netplay has disconnected. Will continue without connection ...\n");
if (g_runloop.msg_queue)
msg_queue_push(g_runloop.msg_queue, "Netplay has disconnected. Will continue without connection.", 0, 480);
rarch_main_msg_queue_push("Netplay has disconnected. Will continue without connection.", 0, 480, false);
}
/**
@ -279,7 +279,7 @@ static bool netplay_get_cmd(netplay_t *netplay)
netplay->flip_frame = flip_frame;
RARCH_LOG("Netplay users are flipped.\n");
msg_queue_push(g_runloop.msg_queue, "Netplay users are flipped.", 1, 180);
rarch_main_msg_queue_push("Netplay users are flipped.", 1, 180, false);
return netplay_cmd_ack(netplay);
@ -606,7 +606,7 @@ static void log_connection(const struct sockaddr_storage *their_addr,
char msg[512];
snprintf(msg, sizeof(msg), "Got connection from: \"%s (%s)\" (#%u)",
nick, str, slot);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
RARCH_LOG("%s\n", msg);
}
}
@ -912,7 +912,7 @@ static bool send_info(netplay_t *netplay)
snprintf(msg, sizeof(msg), "Connected to: \"%s\"", netplay->other_nick);
RARCH_LOG("%s\n", msg);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
return true;
}
@ -1062,7 +1062,7 @@ static bool get_info_spectate(netplay_t *netplay)
}
snprintf(msg, sizeof(msg), "Connected to \"%s\"", netplay->other_nick);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
RARCH_LOG("%s\n", msg);
@ -1265,7 +1265,7 @@ void netplay_flip_users(netplay_t *netplay)
&& netplay_get_response(netplay))
{
RARCH_LOG("Netplay users are flipped.\n");
msg_queue_push(g_runloop.msg_queue, "Netplay users are flipped.", 1, 180);
rarch_main_msg_queue_push("Netplay users are flipped.", 1, 180, false);
/* Queue up a flip well enough in the future. */
netplay->flip ^= true;
@ -1281,7 +1281,7 @@ void netplay_flip_users(netplay_t *netplay)
error:
RARCH_WARN("%s\n", msg);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
}
/**
@ -1367,9 +1367,7 @@ static int16_t netplay_get_spectate_input(netplay_t *netplay, bool port,
return swap_if_big16(inp);
RARCH_ERR("Connection with host was cut.\n");
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue,
"Connection with host was cut.", 1, 180);
rarch_main_msg_queue_push("Connection with host was cut.", 1, 180, true);
pretro_set_input_state(netplay->cbs.state_cb);
return netplay->cbs.state_cb(port, device, idx, id);
@ -1586,7 +1584,7 @@ static void netplay_post_frame_spectate(netplay_t *netplay)
RARCH_LOG("Client (#%u) disconnected ...\n", i);
snprintf(msg, sizeof(msg), "Client (#%u) disconnected.", i);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, false);
socket_close(netplay->spectate_fds[i]);
netplay->spectate_fds[i] = -1;

View File

@ -21,6 +21,7 @@
#include "../dynamic.h"
#include "../general.h"
#include "../retroarch.h"
#include "../runloop.h"
#include "../intl/intl.h"
#include "../gfx/video_viewport.h"
@ -122,9 +123,8 @@ void recording_dump_frame(const void *data, unsigned width,
{
static const char msg[] = "Recording terminated due to resize.";
RARCH_WARN("%s\n", msg);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, true);
rarch_main_command(RARCH_CMD_RECORD_DEINIT);
return;
}

View File

@ -59,8 +59,7 @@ static void set_volume(float gain)
g_settings.audio.volume = min(g_settings.audio.volume, 12.0f);
snprintf(msg, sizeof(msg), "Volume: %.1f dB", g_settings.audio.volume);
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
g_extern.audio_data.volume_gain = db_to_gain(g_settings.audio.volume);
@ -174,13 +173,10 @@ static void check_stateslots(bool pressed_increase, bool pressed_decrease)
else
return;
msg_queue_clear(g_runloop.msg_queue);
snprintf(msg, sizeof(msg), "State slot: %d",
g_settings.state_slot);
if (g_runloop.msg_queue)
msg_queue_push(g_runloop.msg_queue, msg, 1, 180);
rarch_main_msg_queue_push(msg, 1, 180, true);
RARCH_LOG("%s\n", msg);
}
@ -243,16 +239,16 @@ static void check_rewind(bool pressed)
g_extern.rewind.frame_is_reverse = true;
setup_rewind_audio();
msg_queue_push(g_runloop.msg_queue, RETRO_MSG_REWINDING, 0,
g_runloop.is_paused ? 1 : 30);
rarch_main_msg_queue_push(RETRO_MSG_REWINDING, 0,
g_runloop.is_paused ? 1 : 30, false);
pretro_unserialize(buf, g_extern.rewind.size);
if (g_extern.bsv.movie)
bsv_movie_frame_rewind(g_extern.bsv.movie);
}
else
msg_queue_push(g_runloop.msg_queue,
RETRO_MSG_REWIND_REACHED_END, 0, 30);
rarch_main_msg_queue_push(RETRO_MSG_REWIND_REACHED_END,
0, 30, false);
}
else
{
@ -294,9 +290,8 @@ static void check_slowmotion(bool pressed)
if (g_settings.video.black_frame_insertion)
rarch_render_cached_frame();
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, g_extern.rewind.frame_is_reverse ?
"Slow motion rewind." : "Slow motion.", 0, 30);
rarch_main_msg_queue_push(g_extern.rewind.frame_is_reverse ?
"Slow motion rewind." : "Slow motion.", 0, 30, true);
}
static bool check_movie_init(void)
@ -327,9 +322,8 @@ static bool check_movie_init(void)
if (!g_extern.bsv.movie)
ret = false;
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, g_extern.bsv.movie ?
msg : "Failed to start movie record.", 1, 180);
rarch_main_msg_queue_push(g_extern.bsv.movie ?
msg : "Failed to start movie record.", 1, 180, true);
if (g_extern.bsv.movie)
RARCH_LOG("Starting movie record to \"%s\".\n", path);
@ -351,9 +345,8 @@ static bool check_movie_record(void)
if (!g_extern.bsv.movie)
return false;
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue,
RETRO_MSG_MOVIE_RECORD_STOPPING, 2, 180);
rarch_main_msg_queue_push(
RETRO_MSG_MOVIE_RECORD_STOPPING, 2, 180, true);
RARCH_LOG(RETRO_LOG_MOVIE_RECORD_STOPPING);
rarch_main_command(RARCH_CMD_BSV_MOVIE_DEINIT);
@ -373,8 +366,8 @@ static bool check_movie_playback(void)
if (!g_extern.bsv.movie_end)
return false;
msg_queue_push(g_runloop.msg_queue,
RETRO_MSG_MOVIE_PLAYBACK_ENDED, 1, 180);
rarch_main_msg_queue_push(
RETRO_MSG_MOVIE_PLAYBACK_ENDED, 1, 180, false);
RARCH_LOG(RETRO_LOG_MOVIE_PLAYBACK_ENDED);
rarch_main_command(RARCH_CMD_BSV_MOVIE_DEINIT);
@ -439,11 +432,9 @@ static void check_shader_dir(bool pressed_next, bool pressed_prev)
else
return;
msg_queue_clear(g_runloop.msg_queue);
snprintf(msg, sizeof(msg), "Shader #%u: \"%s\".",
(unsigned)g_extern.shader_dir.ptr, shader);
msg_queue_push(g_runloop.msg_queue, msg, 1, 120);
rarch_main_msg_queue_push(msg, 1, 120, true);
RARCH_LOG("Applying shader \"%s\".\n", shader);
if (!video_driver_set_shader(type, shader))
@ -902,6 +893,22 @@ static void rarch_main_iterate_linefeed_overlay(void)
}
#endif
const char *rarch_main_msg_queue_pull(void)
{
return msg_queue_pull(g_runloop.msg_queue);
}
void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
bool flush)
{
if (!g_runloop.msg_queue)
return;
if (flush)
msg_queue_clear(g_runloop.msg_queue);
msg_queue_push(g_runloop.msg_queue, msg, 0, 60);
}
/**
* rarch_main_iterate:
*

View File

@ -21,6 +21,15 @@
#include <formats/image.h>
#include <formats/rpng.h>
#include <queues/message_queue.h>
#include "libretro.h"
#ifndef AUDIO_BUFFER_FREE_SAMPLES_COUNT
#define AUDIO_BUFFER_FREE_SAMPLES_COUNT (8 * 1024)
#endif
#ifndef MEASURE_FRAME_TIME_SAMPLES_COUNT
#define MEASURE_FRAME_TIME_SAMPLES_COUNT (2 * 1024)
#endif
#ifdef __cplusplus
extern "C" {
@ -91,7 +100,71 @@ struct data_runloop
nbio_handle_t nbio;
};
/* All libretro runloop-related globals go here. */
struct runloop
{
/* Lifecycle state checks. */
bool is_paused;
bool is_idle;
bool is_menu;
bool is_slowmotion;
struct
{
struct
{
unsigned count;
unsigned max;
struct
{
struct
{
struct
{
bool is_updated;
} label;
struct
{
bool is_active;
} animation;
struct
{
bool dirty;
} framebuf;
struct
{
bool active;
} action;
} menu;
} current;
} video;
struct
{
retro_time_t minimum_time;
retro_time_t last_time;
} limit;
} frames;
struct
{
unsigned buffer_free_samples[AUDIO_BUFFER_FREE_SAMPLES_COUNT];
uint64_t buffer_free_samples_count;
retro_time_t frame_time_samples[MEASURE_FRAME_TIME_SAMPLES_COUNT];
uint64_t frame_time_samples_count;
} measure_data;
msg_queue_t *msg_queue;
};
/* Public data structures. */
extern struct data_runloop g_data_runloop;
extern struct runloop g_runloop;
/**
* rarch_main_iterate:
@ -103,6 +176,11 @@ extern struct data_runloop g_data_runloop;
**/
int rarch_main_iterate(void);
void rarch_main_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush);
const char *rarch_main_msg_queue_pull(void);
void rarch_main_data_iterate(void);
void rarch_main_data_init_queues(void);

View File

@ -26,6 +26,7 @@
#include <file/file_path.h>
#include "gfx/scaler/scaler.h"
#include "retroarch.h"
#include "runloop.h"
#include "retroarch_logger.h"
#include "screenshot.h"
#include "gfx/video_viewport.h"
@ -257,9 +258,6 @@ bool take_screenshot(void)
!= RETRO_HW_CONTEXT_NONE) && driver.video->read_viewport &&
driver.video->viewport_info;
/* Clear out message queue to avoid OSD fonts to appear on screenshot. */
msg_queue_clear(g_runloop.msg_queue);
if (viewport_read)
{
#ifdef HAVE_MENU
@ -292,7 +290,7 @@ bool take_screenshot(void)
msg = RETRO_MSG_TAKE_SCREENSHOT_FAILED;
}
msg_queue_push(g_runloop.msg_queue, msg, 1, g_runloop.is_paused ? 1 : 180);
rarch_main_msg_queue_push(msg, 1, g_runloop.is_paused ? 1 : 180, true);
if (g_runloop.is_paused)
rarch_render_cached_frame();

View File

@ -25,6 +25,7 @@
#include "file_ext.h"
#include "settings.h"
#include "retroarch.h"
#include "runloop.h"
#include "performance.h"
#if defined(__CELLOS_LV2__)

View File

@ -491,3 +491,8 @@ int main(int argc, char *argv[])
free(g_auto_path);
return 0;
}
void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
bool flush)
{
}