mirror of
https://github.com/libretro/RetroArch
synced 2025-02-21 18:40:09 +00:00
(data runloop) Start creating separate message queue for data runloop
This commit is contained in:
parent
77dd981d21
commit
11d75d088c
@ -108,27 +108,29 @@ void msg_queue_push(msg_queue_t *queue, const char *msg,
|
|||||||
if (!queue || queue->ptr >= queue->size)
|
if (!queue || queue->ptr >= queue->size)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_elem = (struct queue_elem*)calloc(1, sizeof(struct queue_elem));
|
new_elem = (struct queue_elem*)
|
||||||
|
calloc(1, sizeof(struct queue_elem));
|
||||||
if (!new_elem)
|
if (!new_elem)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
new_elem->prio = prio;
|
new_elem->prio = prio;
|
||||||
new_elem->duration = duration;
|
new_elem->duration = duration;
|
||||||
new_elem->msg = msg ? strdup(msg) : NULL;
|
new_elem->msg = msg ? strdup(msg) : NULL;
|
||||||
|
|
||||||
queue->elems[queue->ptr] = new_elem;
|
queue->elems[queue->ptr] = new_elem;
|
||||||
tmp_ptr = queue->ptr++;
|
|
||||||
|
tmp_ptr = queue->ptr++;
|
||||||
|
|
||||||
while (tmp_ptr > 1)
|
while (tmp_ptr > 1)
|
||||||
{
|
{
|
||||||
struct queue_elem *parent = queue->elems[tmp_ptr >> 1];
|
struct queue_elem *parent = queue->elems[tmp_ptr >> 1];
|
||||||
struct queue_elem *child = queue->elems[tmp_ptr];
|
struct queue_elem *child = queue->elems[tmp_ptr];
|
||||||
|
|
||||||
if (child->prio <= parent->prio)
|
if (child->prio <= parent->prio)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
queue->elems[tmp_ptr >> 1] = child;
|
queue->elems[tmp_ptr >> 1] = child;
|
||||||
queue->elems[tmp_ptr] = parent;
|
queue->elems[tmp_ptr] = parent;
|
||||||
|
|
||||||
tmp_ptr >>= 1;
|
tmp_ptr >>= 1;
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include "general.h"
|
#include "general.h"
|
||||||
#include "runloop.h"
|
#include "runloop.h"
|
||||||
|
#include "runloop_data.h"
|
||||||
#include "retroarch.h"
|
#include "retroarch.h"
|
||||||
#include "performance.h"
|
#include "performance.h"
|
||||||
#include "input/keyboard_line.h"
|
#include "input/keyboard_line.h"
|
||||||
@ -149,6 +150,7 @@ static void video_frame(const void *data, unsigned width,
|
|||||||
recording_dump_frame(data, width, height, pitch);
|
recording_dump_frame(data, width, height, pitch);
|
||||||
|
|
||||||
msg = rarch_main_msg_queue_pull();
|
msg = rarch_main_msg_queue_pull();
|
||||||
|
|
||||||
driver->current_msg = msg;
|
driver->current_msg = msg;
|
||||||
|
|
||||||
if (video_frame_filter(data, width, height, pitch,
|
if (video_frame_filter(data, width, height, pitch,
|
||||||
|
@ -889,7 +889,12 @@ static void rarch_main_iterate_linefeed_overlay(void)
|
|||||||
const char *rarch_main_msg_queue_pull(void)
|
const char *rarch_main_msg_queue_pull(void)
|
||||||
{
|
{
|
||||||
runloop_t *runloop = rarch_main_get_ptr();
|
runloop_t *runloop = rarch_main_get_ptr();
|
||||||
return msg_queue_pull(runloop->msg_queue);
|
const char *msg = rarch_main_data_msg_queue_pull();
|
||||||
|
|
||||||
|
if (!msg && runloop)
|
||||||
|
msg = msg_queue_pull(runloop->msg_queue);
|
||||||
|
|
||||||
|
return msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
|
void rarch_main_msg_queue_push(const char *msg, unsigned prio, unsigned duration,
|
||||||
|
@ -110,6 +110,7 @@ enum
|
|||||||
|
|
||||||
typedef struct data_runloop
|
typedef struct data_runloop
|
||||||
{
|
{
|
||||||
|
msg_queue_t *msg_queue;
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
http_handle_t http;
|
http_handle_t http;
|
||||||
#endif
|
#endif
|
||||||
@ -163,7 +164,6 @@ static int rarch_main_data_http_iterate_transfer(http_handle_t *http)
|
|||||||
int percent = 0;
|
int percent = 0;
|
||||||
if (!net_http_update(http->handle, &pos, &tot))
|
if (!net_http_update(http->handle, &pos, &tot))
|
||||||
{
|
{
|
||||||
#if 0
|
|
||||||
char msg[PATH_MAX_LENGTH];
|
char msg[PATH_MAX_LENGTH];
|
||||||
|
|
||||||
if(tot != 0)
|
if(tot != 0)
|
||||||
@ -171,14 +171,11 @@ static int rarch_main_data_http_iterate_transfer(http_handle_t *http)
|
|||||||
else
|
else
|
||||||
percent=0;
|
percent=0;
|
||||||
|
|
||||||
RARCH_LOG("Download progress: %.d%% \r", percent);
|
if (percent > 0)
|
||||||
|
|
||||||
if(percent > 0)
|
|
||||||
{
|
{
|
||||||
snprintf(msg, sizeof(msg), "Download progress: %d%%", percent);
|
snprintf(msg, sizeof(msg), "Download progress: %d%%", percent);
|
||||||
rarch_main_msg_queue_push(msg, 1, 10, true);
|
rarch_main_data_msg_queue_push(DATA_TYPE_MSG, msg, NULL, 1, 10, true);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -872,6 +869,9 @@ void rarch_main_data_deinit(void)
|
|||||||
if (!data_runloop)
|
if (!data_runloop)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (data_runloop->msg_queue)
|
||||||
|
msg_queue_free(data_runloop->msg_queue);
|
||||||
|
|
||||||
#ifdef HAVE_THREADS
|
#ifdef HAVE_THREADS
|
||||||
if (data_runloop->thread_inited)
|
if (data_runloop->thread_inited)
|
||||||
{
|
{
|
||||||
@ -1036,6 +1036,14 @@ void rarch_main_data_init_queues(void)
|
|||||||
rarch_assert(data_runloop->nbio.msg_queue = msg_queue_new(8));
|
rarch_assert(data_runloop->nbio.msg_queue = msg_queue_new(8));
|
||||||
if (!data_runloop->nbio.image.msg_queue)
|
if (!data_runloop->nbio.image.msg_queue)
|
||||||
rarch_assert(data_runloop->nbio.image.msg_queue = msg_queue_new(8));
|
rarch_assert(data_runloop->nbio.image.msg_queue = msg_queue_new(8));
|
||||||
|
if (!data_runloop->msg_queue)
|
||||||
|
rarch_assert(data_runloop->msg_queue = msg_queue_new(8));
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *rarch_main_data_msg_queue_pull(void)
|
||||||
|
{
|
||||||
|
data_runloop_t *runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
return msg_queue_pull(runloop->msg_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void rarch_main_data_msg_queue_push(unsigned type,
|
void rarch_main_data_msg_queue_push(unsigned type,
|
||||||
@ -1046,27 +1054,35 @@ void rarch_main_data_msg_queue_push(unsigned type,
|
|||||||
msg_queue_t *queue = NULL;
|
msg_queue_t *queue = NULL;
|
||||||
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
data_runloop_t *data_runloop = (data_runloop_t*)rarch_main_data_get_ptr();
|
||||||
|
|
||||||
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
|
||||||
|
|
||||||
switch(type)
|
switch(type)
|
||||||
{
|
{
|
||||||
case DATA_TYPE_NONE:
|
case DATA_TYPE_NONE:
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_FILE:
|
case DATA_TYPE_FILE:
|
||||||
queue = data_runloop->nbio.msg_queue;
|
queue = data_runloop->nbio.msg_queue;
|
||||||
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
case DATA_TYPE_IMAGE:
|
case DATA_TYPE_IMAGE:
|
||||||
queue = data_runloop->nbio.image.msg_queue;
|
queue = data_runloop->nbio.image.msg_queue;
|
||||||
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
#ifdef HAVE_NETWORKING
|
#ifdef HAVE_NETWORKING
|
||||||
case DATA_TYPE_HTTP:
|
case DATA_TYPE_HTTP:
|
||||||
queue = data_runloop->http.msg_queue;
|
queue = data_runloop->http.msg_queue;
|
||||||
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_OVERLAY
|
#ifdef HAVE_OVERLAY
|
||||||
case DATA_TYPE_OVERLAY:
|
case DATA_TYPE_OVERLAY:
|
||||||
|
snprintf(new_msg, sizeof(new_msg), "%s|%s", msg, msg2);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
case DATA_TYPE_MSG:
|
||||||
|
if (data_runloop->thread_inited)
|
||||||
|
return;
|
||||||
|
queue = data_runloop->msg_queue;
|
||||||
|
snprintf(new_msg, sizeof(new_msg), "%s", msg);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!queue)
|
if (!queue)
|
||||||
|
@ -28,6 +28,7 @@ extern "C" {
|
|||||||
enum runloop_data_type
|
enum runloop_data_type
|
||||||
{
|
{
|
||||||
DATA_TYPE_NONE = 0,
|
DATA_TYPE_NONE = 0,
|
||||||
|
DATA_TYPE_MSG,
|
||||||
DATA_TYPE_FILE,
|
DATA_TYPE_FILE,
|
||||||
DATA_TYPE_IMAGE,
|
DATA_TYPE_IMAGE,
|
||||||
DATA_TYPE_HTTP,
|
DATA_TYPE_HTTP,
|
||||||
@ -40,6 +41,8 @@ void rarch_main_data_msg_queue_push(unsigned type,
|
|||||||
const char *msg, const char *msg2,
|
const char *msg, const char *msg2,
|
||||||
unsigned prio, unsigned duration, bool flush);
|
unsigned prio, unsigned duration, bool flush);
|
||||||
|
|
||||||
|
const char *rarch_main_data_msg_queue_pull(void);
|
||||||
|
|
||||||
void rarch_main_data_clear_state(void);
|
void rarch_main_data_clear_state(void);
|
||||||
|
|
||||||
void rarch_main_data_iterate(void);
|
void rarch_main_data_iterate(void);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user