mirror of
https://github.com/CTCaer/RetroArch.git
synced 2024-12-18 00:07:23 +00:00
Start adding HTTP transfer mechanism to runloop
This commit is contained in:
parent
16cd8d1321
commit
77eb7b262e
@ -59,6 +59,10 @@
|
||||
#include "command.h"
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
#include "net_http.h"
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -568,6 +572,10 @@ struct global
|
||||
#endif
|
||||
|
||||
msg_queue_t *msg_queue;
|
||||
#ifdef HAVE_NETPLAY
|
||||
msg_queue_t *http_msg_queue;
|
||||
http_t *http_handle;
|
||||
#endif
|
||||
|
||||
bool exec;
|
||||
|
||||
|
@ -2910,6 +2910,10 @@ bool rarch_main_command(unsigned cmd)
|
||||
rarch_main_command(RARCH_CMD_MSG_QUEUE_DEINIT);
|
||||
if (!g_extern.msg_queue)
|
||||
rarch_assert(g_extern.msg_queue = msg_queue_new(8));
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (!g_extern.http_msg_queue)
|
||||
rarch_assert(g_extern.http_msg_queue = msg_queue_new(8));
|
||||
#endif
|
||||
break;
|
||||
case RARCH_CMD_BSV_MOVIE_DEINIT:
|
||||
if (g_extern.bsv.movie)
|
||||
|
43
runloop.c
43
runloop.c
@ -866,6 +866,36 @@ static int rarch_main_iterate_quit(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
static int rarch_main_iterate_http_transfer(void)
|
||||
{
|
||||
size_t pos = 0, tot = 0;
|
||||
|
||||
if (!net_http_update(g_extern.http_handle, &pos, &tot))
|
||||
{
|
||||
RARCH_LOG("%.9lu / %.9lu \r", pos, tot);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int rarch_main_iterate_http_poll(void)
|
||||
{
|
||||
const char *url = msg_queue_pull(g_extern.http_msg_queue);
|
||||
|
||||
if (!url)
|
||||
return -1;
|
||||
/* Can only deal with one HTTP transfer at a time for now */
|
||||
if (g_extern.http_handle)
|
||||
return -1;
|
||||
|
||||
g_extern.http_handle = net_http_new(url);
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* rarch_main_iterate:
|
||||
*
|
||||
@ -897,6 +927,19 @@ int rarch_main_iterate(void)
|
||||
|
||||
do_pre_state_checks(input, old_input, trigger_input);
|
||||
|
||||
#ifdef HAVE_NETPLAY
|
||||
if (g_extern.http_handle)
|
||||
{
|
||||
if (!rarch_main_iterate_http_transfer())
|
||||
{
|
||||
/* TODO - we should have some function pointer
|
||||
* we can call here. */
|
||||
}
|
||||
}
|
||||
else
|
||||
rarch_main_iterate_http_poll();
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_MENU
|
||||
if (g_extern.is_menu)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user