mirror of
https://github.com/libretro/RetroArch.git
synced 2025-01-30 21:42:18 +00:00
nbio handle should be initialized on the thread, not the
main thread
This commit is contained in:
parent
f962723943
commit
583511c045
@ -23,7 +23,10 @@
|
||||
#include <lists/string_list.h>
|
||||
#include <rhash.h>
|
||||
|
||||
#include <string/stdstring.h>
|
||||
|
||||
#include "tasks_internal.h"
|
||||
#include "../file_path_special.h"
|
||||
#include "../verbosity.h"
|
||||
|
||||
static int task_file_transfer_iterate_transfer(nbio_handle_t *nbio)
|
||||
@ -68,6 +71,33 @@ void task_file_load_handler(retro_task_t *task)
|
||||
|
||||
switch (nbio->status)
|
||||
{
|
||||
case NBIO_STATUS_INIT:
|
||||
if (nbio && !string_is_empty(nbio->path))
|
||||
{
|
||||
const char *fullpath = nbio->path;
|
||||
struct nbio_t *handle = nbio_open(fullpath, NBIO_READ);
|
||||
if (handle)
|
||||
{
|
||||
nbio->handle = handle;
|
||||
nbio->status = NBIO_STATUS_TRANSFER;
|
||||
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_PNG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION))
|
||||
|| strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_JPEG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_BMP;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_TGA;
|
||||
|
||||
nbio_begin_read(handle);
|
||||
return;
|
||||
}
|
||||
else
|
||||
task_set_cancelled(task, true);
|
||||
}
|
||||
break;
|
||||
case NBIO_STATUS_TRANSFER_PARSE:
|
||||
if (task_file_transfer_iterate_parse(nbio) == -1)
|
||||
task_set_cancelled(task, true);
|
||||
|
@ -330,7 +330,6 @@ bool task_push_image_load(const char *fullpath,
|
||||
{
|
||||
nbio_handle_t *nbio = NULL;
|
||||
retro_task_t *t = NULL;
|
||||
struct nbio_t *handle = NULL;
|
||||
struct nbio_image_handle *image = NULL;
|
||||
bool supports_rgba = video_driver_supports_rgba();
|
||||
|
||||
@ -345,11 +344,7 @@ bool task_push_image_load(const char *fullpath,
|
||||
if (!nbio)
|
||||
goto error;
|
||||
|
||||
handle = nbio_open(fullpath, NBIO_READ);
|
||||
if (!handle)
|
||||
goto error;
|
||||
|
||||
nbio->handle = handle;
|
||||
strlcpy(nbio->path, fullpath, sizeof(nbio->path));
|
||||
|
||||
if (supports_rgba)
|
||||
BIT32_SET(nbio->status_flags, NBIO_FLAG_IMAGE_SUPPORTS_RGBA);
|
||||
@ -363,19 +358,8 @@ bool task_push_image_load(const char *fullpath,
|
||||
nbio->data = (struct nbio_image_handle*)image;
|
||||
nbio->is_finished = false;
|
||||
nbio->cb = &cb_nbio_image_menu_thumbnail;
|
||||
nbio->status = NBIO_STATUS_TRANSFER;
|
||||
nbio->status = NBIO_STATUS_INIT;
|
||||
|
||||
if (strstr(fullpath, file_path_str(FILE_PATH_PNG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_PNG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_JPEG_EXTENSION))
|
||||
|| strstr(fullpath, file_path_str(FILE_PATH_JPG_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_JPEG;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_BMP_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_BMP;
|
||||
else if (strstr(fullpath, file_path_str(FILE_PATH_TGA_EXTENSION)))
|
||||
nbio->image_type = IMAGE_TYPE_TGA;
|
||||
|
||||
nbio_begin_read(handle);
|
||||
|
||||
t->state = nbio;
|
||||
t->handler = task_file_load_handler;
|
||||
@ -388,7 +372,6 @@ bool task_push_image_load(const char *fullpath,
|
||||
return true;
|
||||
|
||||
error:
|
||||
nbio_free(handle);
|
||||
task_image_load_free(t);
|
||||
free(t);
|
||||
if (nbio)
|
||||
|
@ -55,7 +55,8 @@ enum content_mode_load
|
||||
|
||||
enum nbio_status_enum
|
||||
{
|
||||
NBIO_STATUS_POLL = 0,
|
||||
NBIO_STATUS_INIT = 0,
|
||||
NBIO_STATUS_POLL,
|
||||
NBIO_STATUS_TRANSFER,
|
||||
NBIO_STATUS_TRANSFER_PARSE,
|
||||
NBIO_STATUS_TRANSFER_PARSE_FREE
|
||||
@ -78,6 +79,7 @@ typedef struct nbio_handle
|
||||
msg_queue_t *msg_queue;
|
||||
unsigned status;
|
||||
uint32_t status_flags;
|
||||
char path[4096];
|
||||
} nbio_handle_t;
|
||||
|
||||
typedef struct autoconfig_params
|
||||
|
Loading…
x
Reference in New Issue
Block a user