RetroArch/runloop_data.h

190 lines
4.1 KiB
C
Raw Normal View History

2015-03-24 12:45:53 +00:00
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RETROARCH_DATA_RUNLOOP_H
#define __RETROARCH_DATA_RUNLOOP_H
#include <file/nbio.h>
#include <formats/image.h>
#include <formats/rpng.h>
#include <queues/message_queue.h>
2015-05-05 15:36:58 +00:00
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
2015-05-05 07:50:00 +00:00
#endif
2015-05-23 16:13:23 +00:00
#ifdef HAVE_LIBRETRODB
#include "database_info.h"
#endif
2015-05-05 15:36:58 +00:00
#include "tasks/tasks.h"
2015-03-24 12:45:53 +00:00
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*transfer_cb_t)(void *data, size_t len);
2015-05-05 07:50:00 +00:00
2015-03-24 12:45:53 +00:00
enum runloop_data_type
{
DATA_TYPE_NONE = 0,
DATA_TYPE_FILE,
DATA_TYPE_IMAGE,
DATA_TYPE_HTTP,
DATA_TYPE_OVERLAY,
2015-05-23 15:59:48 +00:00
DATA_TYPE_DB,
2015-03-24 12:45:53 +00:00
};
2015-05-05 07:50:00 +00:00
#ifdef HAVE_NETWORKING
enum
{
HTTP_STATUS_POLL = 0,
HTTP_STATUS_CONNECTION_TRANSFER,
HTTP_STATUS_CONNECTION_TRANSFER_PARSE,
HTTP_STATUS_TRANSFER,
HTTP_STATUS_TRANSFER_PARSE,
HTTP_STATUS_TRANSFER_PARSE_FREE,
} http_status_enum;
typedef struct http_handle
{
struct
{
struct http_connection_t *handle;
transfer_cb_t cb;
char elem1[PATH_MAX_LENGTH];
} connection;
msg_queue_t *msg_queue;
struct http_t *handle;
transfer_cb_t cb;
unsigned status;
} http_handle_t;
#endif
typedef struct nbio_image_handle
{
struct texture_image ti;
bool is_blocking;
bool is_blocking_on_processing;
bool is_finished;
transfer_cb_t cb;
#ifdef HAVE_RPNG
struct rpng_t *handle;
#endif
unsigned processing_pos_increment;
unsigned pos_increment;
uint64_t frame_count;
uint64_t processing_frame_count;
int processing_final_state;
msg_queue_t *msg_queue;
unsigned status;
} nbio_image_handle_t;
enum
{
NBIO_IMAGE_STATUS_POLL = 0,
NBIO_IMAGE_STATUS_TRANSFER,
NBIO_IMAGE_STATUS_TRANSFER_PARSE,
NBIO_IMAGE_STATUS_PROCESS_TRANSFER,
NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE,
NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE,
} nbio_image_status_enum;
enum
{
NBIO_STATUS_POLL = 0,
NBIO_STATUS_TRANSFER,
NBIO_STATUS_TRANSFER_PARSE,
NBIO_STATUS_TRANSFER_PARSE_FREE,
} nbio_status_enum;
typedef struct nbio_handle
{
nbio_image_handle_t image;
bool is_finished;
transfer_cb_t cb;
struct nbio_t *handle;
unsigned pos_increment;
uint64_t frame_count;
msg_queue_t *msg_queue;
unsigned status;
} nbio_handle_t;
2015-05-23 19:56:17 +00:00
typedef struct database_state_handle
{
database_info_list_t *info;
2015-05-24 06:04:13 +00:00
struct string_list *list;
size_t list_index;
size_t entry_index;
uint32_t crc;
2015-05-23 19:56:17 +00:00
uint8_t *buf;
char zip_name[PATH_MAX_LENGTH];
2015-05-23 19:56:17 +00:00
} database_state_handle_t;
2015-05-05 07:50:00 +00:00
typedef struct db_handle
{
2015-05-23 19:56:17 +00:00
database_state_handle_t state;
2015-05-23 16:13:23 +00:00
database_info_handle_t *handle;
2015-05-05 07:50:00 +00:00
msg_queue_t *msg_queue;
unsigned status;
} db_handle_t;
typedef struct data_runloop
{
#ifdef HAVE_NETWORKING
http_handle_t http;
#endif
#ifdef HAVE_LIBRETRODB
db_handle_t db;
#endif
nbio_handle_t nbio;
bool inited;
#ifdef HAVE_THREADS
bool thread_inited;
unsigned thread_code;
bool alive;
slock_t *lock;
slock_t *cond_lock;
slock_t *overlay_lock;
scond_t *cond;
sthread_t *thread;
#endif
} data_runloop_t;
2015-03-24 12:45:53 +00:00
void rarch_main_data_msg_queue_push(unsigned type,
const char *msg, const char *msg2,
unsigned prio, unsigned duration, bool flush);
void rarch_main_data_clear_state(void);
void rarch_main_data_iterate(void);
void rarch_main_data_deinit(void);
void rarch_main_data_free(void);
void rarch_main_data_init_queues(void);
bool rarch_main_data_active(data_runloop_t *runloop);
data_runloop_t *rarch_main_data_get_ptr(void);
2015-03-24 12:45:53 +00:00
#ifdef __cplusplus
}
#endif
#endif