all repos — mgba @ 484618ca4c5f59f62a73018051ca6397472ea35e

mGBA Game Boy Advance Emulator

Core: Restore sleep callback
Vicki Pfau vi@endrift.com
Sun, 09 Apr 2017 19:13:13 -0700
commit

484618ca4c5f59f62a73018051ca6397472ea35e

parent

f0ea421feada3a4960ed37e32cb7096103e275ab

M CHANGESCHANGES

@@ -85,6 +85,7 @@ - Qt: Re-enable QtMultimedia on Windows

- FFmpeg: Return false if a file fails to open - FFmpeg: Force MP4 files to YUV420P - Qt: Make "Mute" able to be bound to a key + - Core: Restore sleep callback 0.5.2: (2016-12-31) Bugfixes:
M include/mgba/core/interface.hinclude/mgba/core/interface.h

@@ -38,6 +38,7 @@ void* context;

void (*videoFrameStarted)(void* context); void (*videoFrameEnded)(void* context); void (*coreCrashed)(void* context); + void (*sleep)(void* context); }; DECLARE_VECTOR(mCoreCallbacksList, struct mCoreCallbacks);

@@ -51,10 +52,6 @@ };

struct mKeyCallback { uint16_t (*readKeys)(struct mKeyCallback*); -}; - -struct mStopCallback { - void (*stop)(struct mStopCallback*); }; struct mRotationSource {
M include/mgba/core/thread.hinclude/mgba/core/thread.h

@@ -62,6 +62,7 @@ ThreadCallback startCallback;

ThreadCallback resetCallback; ThreadCallback cleanCallback; ThreadCallback frameCallback; + ThreadCallback sleepCallback; void* userData; void (*run)(struct mCoreThread*);
M include/mgba/internal/gba/gba.hinclude/mgba/internal/gba/gba.h

@@ -99,7 +99,6 @@ struct VFile* biosVf;

struct mAVStream* stream; struct mKeyCallback* keyCallback; - struct mStopCallback* stopCallback; struct mCoreCallbacksList coreCallbacks; enum GBAIdleLoopOptimization idleOptimization;
M src/core/thread.csrc/core/thread.c

@@ -120,6 +120,16 @@ }

_changeState(thread, THREAD_CRASHED, true); } +void _sleep(void* context) { + struct mCoreThread* thread = context; + if (!thread) { + return; + } + if (thread->sleepCallback) { + thread->sleepCallback(thread); + } +} + static THREAD_ENTRY _mCoreThreadRun(void* context) { struct mCoreThread* threadContext = context; #ifdef USE_PTHREADS

@@ -143,6 +153,7 @@ struct mCoreCallbacks callbacks = {

.videoFrameStarted = _frameStarted, .videoFrameEnded = _frameEnded, .coreCrashed = _crashed, + .sleep = _sleep, .context = threadContext }; core->addCoreCallbacks(core, &callbacks);
M src/gba/gba.csrc/gba/gba.c

@@ -89,8 +89,6 @@ gba->biosVf = 0;

gba->stream = NULL; gba->keyCallback = NULL; - gba->stopCallback = NULL; - gba->stopCallback = NULL; mCoreCallbacksListInit(&gba->coreCallbacks, 0); gba->biosChecksum = GBAChecksum(gba->memory.bios, SIZE_BIOS);

@@ -450,11 +448,14 @@ gba->cpu->halted = 1;

} void GBAStop(struct GBA* gba) { - if (!gba->stopCallback) { - return; + size_t c; + for (c = 0; c < mCoreCallbacksListSize(&gba->coreCallbacks); ++c) { + struct mCoreCallbacks* callbacks = mCoreCallbacksListGetPointer(&gba->coreCallbacks, c); + if (callbacks->sleep) { + callbacks->sleep(callbacks->context); + } } gba->cpu->nextEvent = gba->cpu->cycles; - gba->stopCallback->stop(gba->stopCallback); } void GBADebug(struct GBA* gba, uint16_t flags) {
M src/platform/qt/GameController.cppsrc/platform/qt/GameController.cpp

@@ -217,18 +217,16 @@ QMetaObject::invokeMethod(controller, "gamePaused", Q_ARG(mCoreThread*, context));

} }; - // TODO: Put back - /*m_threadContext.stopCallback = [](mCoreThread* context) { + m_threadContext.sleepCallback = [](mCoreThread* context) { if (!context) { - return false; + return; } GameController* controller = static_cast<GameController*>(context->userData); if (!mCoreSaveState(context->core, 0, controller->m_saveStateFlags)) { - return false; + return; } QMetaObject::invokeMethod(controller, "closeGame"); - return true; - };*/ + }; m_threadContext.logger.d.log = [](mLogger* logger, int category, enum mLogLevel level, const char* format, va_list args) { mThreadLogger* logContext = reinterpret_cast<mThreadLogger*>(logger);