mirror of https://github.com/mgba-emu/mgba.git
Core: Restore sleep callback
This commit is contained in:
parent
f0ea421fea
commit
484618ca4c
1
CHANGES
1
CHANGES
|
@ -85,6 +85,7 @@ Misc:
|
|||
- 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:
|
||||
|
|
|
@ -38,6 +38,7 @@ struct mCoreCallbacks {
|
|||
void (*videoFrameStarted)(void* context);
|
||||
void (*videoFrameEnded)(void* context);
|
||||
void (*coreCrashed)(void* context);
|
||||
void (*sleep)(void* context);
|
||||
};
|
||||
|
||||
DECLARE_VECTOR(mCoreCallbacksList, struct mCoreCallbacks);
|
||||
|
@ -53,10 +54,6 @@ struct mKeyCallback {
|
|||
uint16_t (*readKeys)(struct mKeyCallback*);
|
||||
};
|
||||
|
||||
struct mStopCallback {
|
||||
void (*stop)(struct mStopCallback*);
|
||||
};
|
||||
|
||||
struct mRotationSource {
|
||||
void (*sample)(struct mRotationSource*);
|
||||
|
||||
|
|
|
@ -62,6 +62,7 @@ struct mCoreThread {
|
|||
ThreadCallback resetCallback;
|
||||
ThreadCallback cleanCallback;
|
||||
ThreadCallback frameCallback;
|
||||
ThreadCallback sleepCallback;
|
||||
void* userData;
|
||||
void (*run)(struct mCoreThread*);
|
||||
|
||||
|
|
|
@ -99,7 +99,6 @@ struct GBA {
|
|||
|
||||
struct mAVStream* stream;
|
||||
struct mKeyCallback* keyCallback;
|
||||
struct mStopCallback* stopCallback;
|
||||
struct mCoreCallbacksList coreCallbacks;
|
||||
|
||||
enum GBAIdleLoopOptimization idleOptimization;
|
||||
|
|
|
@ -120,6 +120,16 @@ void _crashed(void* context) {
|
|||
_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 @@ static THREAD_ENTRY _mCoreThreadRun(void* context) {
|
|||
.videoFrameStarted = _frameStarted,
|
||||
.videoFrameEnded = _frameEnded,
|
||||
.coreCrashed = _crashed,
|
||||
.sleep = _sleep,
|
||||
.context = threadContext
|
||||
};
|
||||
core->addCoreCallbacks(core, &callbacks);
|
||||
|
|
|
@ -89,8 +89,6 @@ static void GBAInit(void* cpu, struct mCPUComponent* component) {
|
|||
|
||||
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 @@ void GBAHalt(struct GBA* gba) {
|
|||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -217,18 +217,16 @@ GameController::GameController(QObject* parent)
|
|||
}
|
||||
};
|
||||
|
||||
// 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);
|
||||
|
|
Loading…
Reference in New Issue