mirror of https://github.com/mgba-emu/mgba.git
GBA Thread: Fix uses of videoFrameOn being overridden
This commit is contained in:
parent
982408281e
commit
870417d46e
|
@ -619,11 +619,12 @@ void GBARunOnThread(struct GBAThread* threadContext, void (*run)(struct GBAThrea
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAThreadPause(struct GBAThread* threadContext) {
|
void GBAThreadPause(struct GBAThread* threadContext) {
|
||||||
bool frameOn = true;
|
bool frameOn = threadContext->sync.videoFrameOn;
|
||||||
MutexLock(&threadContext->stateMutex);
|
MutexLock(&threadContext->stateMutex);
|
||||||
_waitOnInterrupt(threadContext);
|
_waitOnInterrupt(threadContext);
|
||||||
if (threadContext->state == THREAD_RUNNING) {
|
if (threadContext->state == THREAD_RUNNING) {
|
||||||
_pauseThread(threadContext, false);
|
_pauseThread(threadContext, false);
|
||||||
|
threadContext->frameWasOn = frameOn;
|
||||||
frameOn = false;
|
frameOn = false;
|
||||||
}
|
}
|
||||||
MutexUnlock(&threadContext->stateMutex);
|
MutexUnlock(&threadContext->stateMutex);
|
||||||
|
@ -632,15 +633,17 @@ void GBAThreadPause(struct GBAThread* threadContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAThreadUnpause(struct GBAThread* threadContext) {
|
void GBAThreadUnpause(struct GBAThread* threadContext) {
|
||||||
|
bool frameOn = threadContext->sync.videoFrameOn;
|
||||||
MutexLock(&threadContext->stateMutex);
|
MutexLock(&threadContext->stateMutex);
|
||||||
_waitOnInterrupt(threadContext);
|
_waitOnInterrupt(threadContext);
|
||||||
if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) {
|
if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) {
|
||||||
threadContext->state = THREAD_RUNNING;
|
threadContext->state = THREAD_RUNNING;
|
||||||
ConditionWake(&threadContext->stateCond);
|
ConditionWake(&threadContext->stateCond);
|
||||||
|
frameOn = threadContext->frameWasOn;
|
||||||
}
|
}
|
||||||
MutexUnlock(&threadContext->stateMutex);
|
MutexUnlock(&threadContext->stateMutex);
|
||||||
|
|
||||||
_changeVideoSync(&threadContext->sync, true);
|
_changeVideoSync(&threadContext->sync, frameOn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool GBAThreadIsPaused(struct GBAThread* threadContext) {
|
bool GBAThreadIsPaused(struct GBAThread* threadContext) {
|
||||||
|
@ -653,14 +656,16 @@ bool GBAThreadIsPaused(struct GBAThread* threadContext) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBAThreadTogglePause(struct GBAThread* threadContext) {
|
void GBAThreadTogglePause(struct GBAThread* threadContext) {
|
||||||
bool frameOn = true;
|
bool frameOn = threadContext->sync.videoFrameOn;
|
||||||
MutexLock(&threadContext->stateMutex);
|
MutexLock(&threadContext->stateMutex);
|
||||||
_waitOnInterrupt(threadContext);
|
_waitOnInterrupt(threadContext);
|
||||||
if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) {
|
if (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_PAUSING) {
|
||||||
threadContext->state = THREAD_RUNNING;
|
threadContext->state = THREAD_RUNNING;
|
||||||
ConditionWake(&threadContext->stateCond);
|
ConditionWake(&threadContext->stateCond);
|
||||||
|
frameOn = threadContext->frameWasOn;
|
||||||
} else if (threadContext->state == THREAD_RUNNING) {
|
} else if (threadContext->state == THREAD_RUNNING) {
|
||||||
_pauseThread(threadContext, false);
|
_pauseThread(threadContext, false);
|
||||||
|
threadContext->frameWasOn = frameOn;
|
||||||
frameOn = false;
|
frameOn = false;
|
||||||
}
|
}
|
||||||
MutexUnlock(&threadContext->stateMutex);
|
MutexUnlock(&threadContext->stateMutex);
|
||||||
|
|
|
@ -91,6 +91,7 @@ struct GBAThread {
|
||||||
Condition stateCond;
|
Condition stateCond;
|
||||||
enum ThreadState savedState;
|
enum ThreadState savedState;
|
||||||
int interruptDepth;
|
int interruptDepth;
|
||||||
|
bool frameWasOn;
|
||||||
|
|
||||||
GBALogHandler logHandler;
|
GBALogHandler logHandler;
|
||||||
int logLevel;
|
int logLevel;
|
||||||
|
|
Loading…
Reference in New Issue