Qt: Fix running proxied video if it gets pushed to the main thread

This commit is contained in:
Vicki Pfau 2020-11-08 23:14:29 -08:00
parent a2dc6557e3
commit e7028e4b29
2 changed files with 19 additions and 8 deletions

View File

@ -54,6 +54,7 @@ Other fixes:
- Qt: Fix static compilation in MinGW (fixes mgba.io/i/1769)
- Qt: Fix a race condition in the frame inspector
- Qt: Load/save bytes from memory viewer in the order visible (fixes mgba.io/i/1900)
- Qt: Fix running proxied video if it gets pushed to the main thread
- SM83: Simplify register pair access on big endian
- SM83: Disassemble STOP as one byte
Misc:

View File

@ -58,11 +58,16 @@ void VideoProxy::deinit() {
bool VideoProxy::writeData(const void* data, size_t length) {
while (!RingFIFOWrite(&m_dirtyQueue, data, length)) {
emit dataAvailable();
m_mutex.lock();
m_toThreadCond.wakeAll();
m_fromThreadCond.wait(&m_mutex);
m_mutex.unlock();
if (QThread::currentThread() == thread()) {
// We're on the main thread
mVideoLoggerRendererRun(&m_logger.d, false);
} else {
emit dataAvailable();
m_mutex.lock();
m_toThreadCond.wakeAll();
m_fromThreadCond.wait(&m_mutex);
m_mutex.unlock();
}
}
return true;
}
@ -112,9 +117,14 @@ void VideoProxy::unlock() {
void VideoProxy::wait() {
m_mutex.lock();
while (RingFIFOSize(&m_dirtyQueue)) {
emit dataAvailable();
m_toThreadCond.wakeAll();
m_fromThreadCond.wait(&m_mutex, 1);
if (QThread::currentThread() == thread()) {
// We're on the main thread
mVideoLoggerRendererRun(&m_logger.d, false);
} else {
emit dataAvailable();
m_toThreadCond.wakeAll();
m_fromThreadCond.wait(&m_mutex, 1);
}
}
m_mutex.unlock();
}