Create runloop_msg_queue_pull

This commit is contained in:
twinaphex 2017-01-23 13:56:05 +01:00
parent 83b1bbe247
commit 9b1c0abf5e
3 changed files with 19 additions and 17 deletions

View File

@ -2184,8 +2184,9 @@ void video_driver_frame(const void *data, unsigned width,
video_driver_msg[0] = '\0';
if (runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PULL, &msg)
&& video_info.font_enable && msg)
if ( video_info.font_enable
&& runloop_msg_queue_pull((const char**)&msg)
&& msg)
strlcpy(video_driver_msg, msg, sizeof(video_driver_msg));
if (!current_video || !current_video->frame(

View File

@ -212,6 +212,20 @@ void runloop_get_status(bool *is_paused, bool *is_idle,
*is_slowmotion = runloop_slowmotion;
}
bool runloop_msg_queue_pull(const char **ret)
{
if (!ret)
return false;
#ifdef HAVE_THREADS
slock_lock(_runloop_msg_queue_lock);
#endif
*ret = msg_queue_pull(runloop_msg_queue);
#ifdef HAVE_THREADS
slock_unlock(_runloop_msg_queue_lock);
#endif
return true;
}
bool runloop_ctl(enum runloop_ctl_state state, void *data)
{
@ -455,20 +469,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
break;
case RUNLOOP_CTL_IS_PAUSED:
return runloop_paused;
case RUNLOOP_CTL_MSG_QUEUE_PULL:
{
const char **ret = (const char**)data;
if (!ret)
return false;
#ifdef HAVE_THREADS
slock_lock(_runloop_msg_queue_lock);
#endif
*ret = msg_queue_pull(runloop_msg_queue);
#ifdef HAVE_THREADS
slock_unlock(_runloop_msg_queue_lock);
#endif
}
break;
case RUNLOOP_CTL_MSG_QUEUE_DEINIT:
if (!runloop_msg_queue)
return true;

View File

@ -93,7 +93,6 @@ enum runloop_ctl_state
/* Message queue */
RUNLOOP_CTL_MSG_QUEUE_INIT,
RUNLOOP_CTL_MSG_QUEUE_DEINIT,
RUNLOOP_CTL_MSG_QUEUE_PULL,
/* Core options */
RUNLOOP_CTL_HAS_CORE_OPTIONS,
@ -203,6 +202,8 @@ int runloop_iterate(unsigned *sleep_ms);
void runloop_msg_queue_push(const char *msg, unsigned prio,
unsigned duration, bool flush);
bool runloop_msg_queue_pull(const char **ret);
void runloop_get_status(bool *is_paused, bool *is_idle, bool *is_slowmotion);
bool runloop_ctl(enum runloop_ctl_state state, void *data);