Skip to content

Commit

Permalink
Create wrapper functions for passing a message to the runloop's
Browse files Browse the repository at this point in the history
message queue
  • Loading branch information
inactive123 committed Mar 15, 2015
1 parent 96ae2e9 commit 00239a3
Show file tree
Hide file tree
Showing 47 changed files with 200 additions and 152 deletions.
1 change: 1 addition & 0 deletions audio/audio_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions camera/camera_driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -232,15 +233,14 @@ 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",
handle_idx, handle->cheats[handle_idx].state ? "ON" : "OFF",
(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);
}

Expand Down
5 changes: 2 additions & 3 deletions command.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 3 additions & 4 deletions database_info.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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);

Expand Down
3 changes: 2 additions & 1 deletion driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down
7 changes: 2 additions & 5 deletions dynamic.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "libretro_private.h"
#include "dynamic_dummy.h"
#include "retroarch.h"
#include "runloop.h"

#include "input/input_sensor.h"

Expand Down Expand Up @@ -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;
}

Expand Down
66 changes: 0 additions & 66 deletions general.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;

Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers/exynos_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 *
Expand Down
1 change: 1 addition & 0 deletions gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <string.h>
#include "../../general.h"
#include "../../retroarch.h"
#include "../../runloop.h"
#include <math.h>

#ifdef HAVE_CONFIG_H
Expand Down
1 change: 1 addition & 0 deletions gfx/drivers/sdl2_gfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/androidegl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/bbqnx_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/d3d_ctx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "../d3d/d3d.h"
#include "win32_common.h"

#include "../../runloop.h"
#include "../video_monitor.h"

#ifdef _MSC_VER
Expand Down Expand Up @@ -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);
}
}

Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/drm_egl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
#include <file/dir_list.h>
Expand Down Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/emscriptenegl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "../../driver.h"
#include "../../runloop.h"
#include "../video_context_driver.h"
#include "../gl_common.h"
#include "../video_monitor.h"
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/glx_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"
#include "x11_common.h"
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/mali_fbdev_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include "../../driver.h"
#include "../../general.h"
#include "../../runloop.h"
#include "../video_monitor.h"
#include "../gl_common.h"

Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/ps3_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "../../driver.h"
#include "../../runloop.h"
#include "../../ps3/sdk_defines.h"

#ifdef HAVE_LIBDBGFONT
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion gfx/drivers_context/sdl_gl_ctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/

#include "../../driver.h"
#include "../../runloop.h"
#include "../gl_common.h"
#include "../video_monitor.h"

Expand Down Expand Up @@ -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,
Expand Down
Loading

0 comments on commit 00239a3

Please sign in to comment.