all repos — mgba @ 45501658b5b9492996141149ade4ad29aa14ffd4

mGBA Game Boy Advance Emulator

src/gba/gba-thread.h (view raw)

 1#ifndef GBA_THREAD_H
 2#define GBA_THREAD_H
 3
 4#include <pthread.h>
 5
 6struct GBAThread {
 7	// Output
 8	int started;
 9	int useDebugger;
10	struct GBA* gba;
11	struct ARMDebugger* debugger;
12
13	// Input
14	struct GBAVideoRenderer* renderer;
15	int fd;
16	const char* fname;
17	int activeKeys;
18	int frameskip;
19
20	// Threading state
21	pthread_t thread;
22
23	pthread_mutex_t startMutex;
24	pthread_cond_t startCond;
25
26	struct GBASync {
27		int videoFramePending;
28		int videoFrameWait;
29		int videoFrameSkip;
30		pthread_mutex_t videoFrameMutex;
31		pthread_cond_t videoFrameAvailableCond;
32		pthread_cond_t videoFrameRequiredCond;
33
34		int audioWait;
35		pthread_cond_t audioAvailableCond;
36		pthread_cond_t audioRequiredCond;
37	} sync;
38};
39
40int GBAThreadStart(struct GBAThread* threadContext);
41void GBAThreadJoin(struct GBAThread* threadContext);
42struct GBAThread* GBAThreadGetContext(void);
43
44void GBASyncPostFrame(struct GBASync* sync);
45void GBASyncWaitFrameStart(struct GBASync* sync, int frameskip);
46void GBASyncWaitFrameEnd(struct GBASync* sync);
47int GBASyncDrawingFrame(struct GBASync* sync);
48
49void GBASyncProduceAudio(struct GBASync* sync, pthread_mutex_t* mutex);
50void GBASyncConsumeAudio(struct GBASync* sync);
51
52#endif