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 } sync;
34};
35
36int GBAThreadStart(struct GBAThread* threadContext);
37void GBAThreadJoin(struct GBAThread* threadContext);
38struct GBAThread* GBAThreadGetContext(void);
39
40void GBASyncPostFrame(struct GBASync* sync);
41void GBASyncWaitFrameStart(struct GBASync* sync, int frameskip);
42void GBASyncWaitFrameEnd(struct GBASync* sync);
43int GBASyncDrawingFrame(struct GBASync* sync);
44
45#endif