forked from libretro/RetroArch
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathrunloop_data.h
174 lines (147 loc) · 3.74 KB
/
runloop_data.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/* 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>
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
#endif
#include "tasks/tasks.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef int (*transfer_cb_t)(void *data, size_t len);
enum runloop_data_type
{
DATA_TYPE_NONE = 0,
DATA_TYPE_FILE,
DATA_TYPE_IMAGE,
DATA_TYPE_HTTP,
#ifdef HAVE_OVERLAY
DATA_TYPE_OVERLAY,
#endif
};
#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;
typedef struct db_handle
{
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;
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);
#ifdef __cplusplus
}
#endif
#endif