mirror of https://github.com/mgba-emu/mgba.git
GBA: Make sure interrupting the thread actually pauses it
This commit is contained in:
parent
22e7eff33c
commit
64ba9d2d8e
|
@ -180,20 +180,22 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
|
||||||
|
|
||||||
int resetScheduled = 0;
|
int resetScheduled = 0;
|
||||||
MutexLock(&threadContext->stateMutex);
|
MutexLock(&threadContext->stateMutex);
|
||||||
if (threadContext->state == THREAD_PAUSING) {
|
while (threadContext->state > THREAD_RUNNING && threadContext->state < THREAD_EXITING) {
|
||||||
threadContext->state = THREAD_PAUSED;
|
if (threadContext->state == THREAD_PAUSING) {
|
||||||
ConditionWake(&threadContext->stateCond);
|
threadContext->state = THREAD_PAUSED;
|
||||||
}
|
ConditionWake(&threadContext->stateCond);
|
||||||
if (threadContext->state == THREAD_INTERRUPTING) {
|
}
|
||||||
threadContext->state = THREAD_INTERRUPTED;
|
if (threadContext->state == THREAD_INTERRUPTING) {
|
||||||
ConditionWake(&threadContext->stateCond);
|
threadContext->state = THREAD_INTERRUPTED;
|
||||||
}
|
ConditionWake(&threadContext->stateCond);
|
||||||
if (threadContext->state == THREAD_RESETING) {
|
}
|
||||||
threadContext->state = THREAD_RUNNING;
|
if (threadContext->state == THREAD_RESETING) {
|
||||||
resetScheduled = 1;
|
threadContext->state = THREAD_RUNNING;
|
||||||
}
|
resetScheduled = 1;
|
||||||
while (threadContext->state == THREAD_PAUSED) {
|
}
|
||||||
ConditionWait(&threadContext->stateCond, &threadContext->stateMutex);
|
while (threadContext->state == THREAD_PAUSED || threadContext->state == THREAD_INTERRUPTED) {
|
||||||
|
ConditionWait(&threadContext->stateCond, &threadContext->stateMutex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
MutexUnlock(&threadContext->stateMutex);
|
MutexUnlock(&threadContext->stateMutex);
|
||||||
if (resetScheduled) {
|
if (resetScheduled) {
|
||||||
|
|
Loading…
Reference in New Issue