mirror of
https://github.com/libretro/RetroArch
synced 2025-02-28 22:13:51 +00:00
(nbio interface) Don't immediately free data buffer of nbio handle -
in the case of images we need to retain this data buffer until it's time to free it. We set nbio_handle->is_blocking to true to indicate to the nbio interface that we want to 'block' on the nbio interface (i.e. don't free, iterate or create a new nbio transfer). If nbio_handle->is_finished is set to true, we cleanup and free the nbio transfer handle.
This commit is contained in:
parent
07c7a0df99
commit
b673321322
@ -594,6 +594,8 @@ struct global
|
|||||||
|
|
||||||
struct
|
struct
|
||||||
{
|
{
|
||||||
|
bool is_blocking;
|
||||||
|
bool is_finished;
|
||||||
transfer_cb_t cb;
|
transfer_cb_t cb;
|
||||||
struct nbio_t *handle;
|
struct nbio_t *handle;
|
||||||
msg_queue_t *msg_queue;
|
msg_queue_t *msg_queue;
|
||||||
|
32
runloop.c
32
runloop.c
@ -888,6 +888,21 @@ static int rarch_main_iterate_nbio_transfer(void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int rarch_main_iterate_nbio_parse_free(void)
|
||||||
|
{
|
||||||
|
if (!g_extern.nbio.is_finished)
|
||||||
|
return -1;
|
||||||
|
|
||||||
|
nbio_free(g_extern.nbio.handle);
|
||||||
|
g_extern.nbio.handle = NULL;
|
||||||
|
g_extern.nbio.is_blocking = false;
|
||||||
|
g_extern.nbio.is_finished = false;
|
||||||
|
|
||||||
|
msg_queue_clear(g_extern.nbio.msg_queue);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
static int rarch_main_iterate_nbio_parse(void)
|
static int rarch_main_iterate_nbio_parse(void)
|
||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
@ -896,11 +911,6 @@ static int rarch_main_iterate_nbio_parse(void)
|
|||||||
if (data && g_extern.nbio.cb)
|
if (data && g_extern.nbio.cb)
|
||||||
g_extern.nbio.cb(data, len);
|
g_extern.nbio.cb(data, len);
|
||||||
|
|
||||||
nbio_free(g_extern.nbio.handle);
|
|
||||||
g_extern.nbio.handle = NULL;
|
|
||||||
|
|
||||||
msg_queue_clear(g_extern.nbio.msg_queue);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1026,6 +1036,9 @@ static int cb_nbio_default(void *data, size_t len)
|
|||||||
(void)data;
|
(void)data;
|
||||||
(void)len;
|
(void)len;
|
||||||
|
|
||||||
|
g_extern.nbio.is_blocking = false;
|
||||||
|
g_extern.nbio.is_finished = true;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1211,8 +1224,13 @@ int rarch_main_iterate(void)
|
|||||||
|
|
||||||
if (g_extern.nbio.handle)
|
if (g_extern.nbio.handle)
|
||||||
{
|
{
|
||||||
if (!rarch_main_iterate_nbio_transfer())
|
if (!g_extern.nbio.is_blocking)
|
||||||
rarch_main_iterate_nbio_parse();
|
{
|
||||||
|
if (!rarch_main_iterate_nbio_transfer())
|
||||||
|
rarch_main_iterate_nbio_parse();
|
||||||
|
}
|
||||||
|
else if (g_extern.nbio.is_finished)
|
||||||
|
rarch_main_iterate_nbio_parse_free();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
rarch_main_iterate_nbio_poll();
|
rarch_main_iterate_nbio_poll();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user