mirror of https://github.com/mgba-emu/mgba.git
Change log handler API
This commit is contained in:
parent
2ce9806de5
commit
f55d085162
|
@ -110,7 +110,6 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
||||||
pthread_sigmask(SIG_SETMASK, &signals, 0);
|
pthread_sigmask(SIG_SETMASK, &signals, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
gba.logHandler = threadContext->logHandler;
|
|
||||||
GBACreate(&gba);
|
GBACreate(&gba);
|
||||||
ARMSetComponents(&cpu, &gba.d, numComponents, components);
|
ARMSetComponents(&cpu, &gba.d, numComponents, components);
|
||||||
ARMInit(&cpu);
|
ARMInit(&cpu);
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
|
|
||||||
struct GBAThread;
|
struct GBAThread;
|
||||||
typedef void (*ThreadCallback)(struct GBAThread* threadContext);
|
typedef void (*ThreadCallback)(struct GBAThread* threadContext);
|
||||||
|
typedef void (*LogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args);
|
||||||
|
|
||||||
enum ThreadState {
|
enum ThreadState {
|
||||||
THREAD_INITIALIZED = -1,
|
THREAD_INITIALIZED = -1,
|
||||||
|
@ -55,6 +56,8 @@ struct GBAThread {
|
||||||
struct VFile* patch;
|
struct VFile* patch;
|
||||||
const char* fname;
|
const char* fname;
|
||||||
int activeKeys;
|
int activeKeys;
|
||||||
|
|
||||||
|
// Run-time options
|
||||||
int frameskip;
|
int frameskip;
|
||||||
float fpsTarget;
|
float fpsTarget;
|
||||||
size_t audioBuffers;
|
size_t audioBuffers;
|
||||||
|
@ -66,7 +69,7 @@ struct GBAThread {
|
||||||
Condition stateCond;
|
Condition stateCond;
|
||||||
enum ThreadState savedState;
|
enum ThreadState savedState;
|
||||||
|
|
||||||
GBALogHandler logHandler;
|
LogHandler logHandler;
|
||||||
int logLevel;
|
int logLevel;
|
||||||
ThreadCallback startCallback;
|
ThreadCallback startCallback;
|
||||||
ThreadCallback cleanCallback;
|
ThreadCallback cleanCallback;
|
||||||
|
|
|
@ -537,16 +537,15 @@ void GBAHalt(struct GBA* gba) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) {
|
static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format, va_list args) {
|
||||||
if (!gba) {
|
struct GBAThread* threadContext = GBAThreadGetContext();
|
||||||
struct GBAThread* threadContext = GBAThreadGetContext();
|
if (threadContext) {
|
||||||
if (threadContext) {
|
if (!gba) {
|
||||||
gba = threadContext->gba;
|
gba = threadContext->gba;
|
||||||
}
|
}
|
||||||
}
|
if (threadContext->logHandler) {
|
||||||
|
threadContext->logHandler(threadContext, level, format, args);
|
||||||
if (gba && gba->logHandler) {
|
return;
|
||||||
gba->logHandler(gba, level, format, args);
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) {
|
if (gba && !(level & gba->logLevel) && level != GBA_LOG_FATAL) {
|
||||||
|
|
|
@ -65,8 +65,6 @@ struct GBARotationSource;
|
||||||
struct Patch;
|
struct Patch;
|
||||||
struct VFile;
|
struct VFile;
|
||||||
|
|
||||||
typedef void (*GBALogHandler)(struct GBA*, enum GBALogLevel, const char* format, va_list args);
|
|
||||||
|
|
||||||
struct GBA {
|
struct GBA {
|
||||||
struct ARMComponent d;
|
struct ARMComponent d;
|
||||||
|
|
||||||
|
@ -108,7 +106,6 @@ struct GBA {
|
||||||
const char* activeFile;
|
const char* activeFile;
|
||||||
|
|
||||||
int logLevel;
|
int logLevel;
|
||||||
GBALogHandler logHandler;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct GBACartridge {
|
struct GBACartridge {
|
||||||
|
|
Loading…
Reference in New Issue