GBA: Move logging construct into GBA struct

This commit is contained in:
Jeffrey Pfau 2015-03-05 20:42:37 -08:00
parent 3f9abf2b05
commit eb21dd722f
4 changed files with 11 additions and 7 deletions

View File

@ -547,10 +547,10 @@ static void _GBAVLog(struct GBA* gba, enum GBALogLevel level, const char* format
threadContext->state = THREAD_CRASHED; threadContext->state = THREAD_CRASHED;
MutexUnlock(&threadContext->stateMutex); MutexUnlock(&threadContext->stateMutex);
} }
if (threadContext->logHandler) { }
threadContext->logHandler(threadContext, level, format, args); if (gba->logHandler) {
return; gba->logHandler(threadContext, level, format, args);
} return;
} }
vprintf(format, args); vprintf(format, args);

View File

@ -90,9 +90,12 @@ enum {
struct GBA; struct GBA;
struct GBARotationSource; struct GBARotationSource;
struct GBAThread;
struct Patch; struct Patch;
struct VFile; struct VFile;
typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args);
struct GBATimer { struct GBATimer {
uint16_t reload; uint16_t reload;
uint16_t oldReload; uint16_t oldReload;
@ -141,7 +144,8 @@ struct GBA {
const char* activeFile; const char* activeFile;
int logLevel; GBALogHandler logHandler;
enum GBALogLevel logLevel;
enum GBAIdleLoopOptimization idleOptimization; enum GBAIdleLoopOptimization idleOptimization;
uint32_t idleLoop; uint32_t idleLoop;

View File

@ -134,6 +134,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
gba.sync = &threadContext->sync; gba.sync = &threadContext->sync;
threadContext->gba = &gba; threadContext->gba = &gba;
gba.logLevel = threadContext->logLevel; gba.logLevel = threadContext->logLevel;
gba.logHandler = threadContext->logHandler;
gba.idleOptimization = threadContext->idleOptimization; gba.idleOptimization = threadContext->idleOptimization;
#ifdef USE_PTHREADS #ifdef USE_PTHREADS
pthread_setspecific(_contextKey, threadContext); pthread_setspecific(_contextKey, threadContext);

View File

@ -20,7 +20,6 @@ struct GBACheatSet;
struct GBAOptions; struct GBAOptions;
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,
@ -95,7 +94,7 @@ struct GBAThread {
enum ThreadState savedState; enum ThreadState savedState;
int interruptDepth; int interruptDepth;
LogHandler logHandler; GBALogHandler logHandler;
int logLevel; int logLevel;
ThreadCallback startCallback; ThreadCallback startCallback;
ThreadCallback cleanCallback; ThreadCallback cleanCallback;