Core: Fix race condition initializing thread proxy

This commit is contained in:
Vicki Pfau 2020-01-31 18:06:18 -08:00
parent 313c8a1d7f
commit d98e30f984
2 changed files with 6 additions and 2 deletions

View File

@ -7,6 +7,7 @@ Emulation fixes:
- GBA Video: Fix backdrop blending on lines without sprites (fixes mgba.io/i/1647)
- GBA Video: Fix OpenGL sprite flag priority
Other fixes:
- Core: Fix race condition initializing thread proxy
- Qt: Only dynamically reset video scale if a game is running
- Qt: Fix race condition with proxied video events
- Qt: Fix color selection in asset view (fixes mgba.io/i/1648)

View File

@ -137,8 +137,10 @@ static void _postEvent(struct mVideoLogger* logger, enum mVideoLoggerEvent event
struct mVideoThreadProxy* proxyRenderer = (struct mVideoThreadProxy*) logger;
MutexLock(&proxyRenderer->mutex);
proxyRenderer->event = event;
ConditionWake(&proxyRenderer->toThreadCond);
ConditionWait(&proxyRenderer->fromThreadCond, &proxyRenderer->mutex);
while (proxyRenderer->event) {
ConditionWake(&proxyRenderer->toThreadCond);
ConditionWait(&proxyRenderer->fromThreadCond, &proxyRenderer->mutex);
}
MutexUnlock(&proxyRenderer->mutex);
}
@ -179,6 +181,7 @@ static THREAD_ENTRY _proxyThread(void* logger) {
ThreadSetName("Proxy Renderer Thread");
MutexLock(&proxyRenderer->mutex);
ConditionWake(&proxyRenderer->fromThreadCond);
while (proxyRenderer->threadState != PROXY_THREAD_STOPPED) {
ConditionWait(&proxyRenderer->toThreadCond, &proxyRenderer->mutex);
if (proxyRenderer->threadState == PROXY_THREAD_STOPPED) {