mirror of
https://github.com/CTCaer/RetroArch.git
synced 2025-02-04 02:26:13 +00:00
(rpng) Add stub code for nonblocking
This commit is contained in:
parent
4d631cba30
commit
deb282af4d
@ -61,6 +61,9 @@ struct nbio_t* nbio_open(const char * filename, enum nbio_mode_t mode)
|
||||
|
||||
void nbio_begin_read(struct nbio_t* handle)
|
||||
{
|
||||
if (!handle)
|
||||
return;
|
||||
|
||||
if (handle->op >= 0)
|
||||
{
|
||||
puts("ERROR - attempted file read operation while busy");
|
||||
@ -90,6 +93,9 @@ bool nbio_iterate(struct nbio_t* handle)
|
||||
{
|
||||
size_t amount = 65536;
|
||||
|
||||
if (!handle)
|
||||
return false;
|
||||
|
||||
if (amount > handle->len - handle->progress)
|
||||
amount = handle->len - handle->progress;
|
||||
|
||||
@ -126,6 +132,8 @@ void nbio_resize(struct nbio_t* handle, size_t len)
|
||||
|
||||
void* nbio_get_ptr(struct nbio_t* handle, size_t* len)
|
||||
{
|
||||
if (!handle)
|
||||
return NULL;
|
||||
if (len)
|
||||
*len = handle->len;
|
||||
if (handle->op == -1)
|
||||
|
@ -28,6 +28,8 @@
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <file/nbio.h>
|
||||
|
||||
#ifdef GEKKO
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
@ -43,6 +45,8 @@
|
||||
#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
|
||||
#endif
|
||||
|
||||
//#define NONBLOCKING_TEST
|
||||
|
||||
static const uint8_t png_magic[8] = {
|
||||
0x89, 'P', 'N', 'G', 0x0d, 0x0a, 0x1a, 0x0a,
|
||||
};
|
||||
@ -805,7 +809,20 @@ bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||
bool has_iend = false;
|
||||
bool has_plte = false;
|
||||
bool ret = true;
|
||||
FILE *file = fopen(path, "rb");
|
||||
FILE *file;
|
||||
#ifdef NONBLOCKING_TEST
|
||||
size_t size = 0;
|
||||
bool looped = false;
|
||||
struct nbio_t* read = nbio_open(path, NBIO_READ);
|
||||
void* ptr = nbio_get_ptr(read, &size);
|
||||
nbio_begin_read(read);
|
||||
|
||||
while (!nbio_iterate(read)) looped=true;
|
||||
ptr = nbio_get_ptr(read, &size);
|
||||
(void)ptr;
|
||||
(void)looped;
|
||||
#endif
|
||||
file = fopen(path, "rb");
|
||||
|
||||
if (!file)
|
||||
{
|
||||
@ -848,6 +865,9 @@ bool rpng_load_image_argb(const char *path, uint32_t **data,
|
||||
width, height);
|
||||
|
||||
end:
|
||||
#ifdef NONBLOCKING_TEST
|
||||
nbio_free(read);
|
||||
#endif
|
||||
if (file)
|
||||
fclose(file);
|
||||
if (!ret)
|
||||
|
Loading…
x
Reference in New Issue
Block a user