Fix locking in waitForEvent() and sample playing

This commit is contained in:
Michal Moskal
2017-10-30 19:18:01 +00:00
parent e8e31e6aa7
commit a082807455
3 changed files with 6 additions and 0 deletions

View File

@ -269,11 +269,13 @@ void waitForEvent(int source, int value) {
pthread_mutex_lock(&eventMutex);
t->waitSource = source;
t->waitValue = value;
stopUser();
// spourious wake ups may occur they say
while (t->waitSource) {
pthread_cond_wait(&t->waitCond, &eventMutex);
}
pthread_mutex_unlock(&eventMutex);
startUser();
return;
}
}