Qt: Fix running proxied video if it gets pushed to the main thread
Vicki Pfau vi@endrift.com
Sun, 08 Nov 2020 23:14:29 -0800
2 files changed,
19 insertions(+),
8 deletions(-)
M
CHANGES
→
CHANGES
@@ -54,6 +54,7 @@ - Qt: Force OpenGL paint engine creation thread (fixes mgba.io/i/1642)
- 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:
M
src/platform/qt/VideoProxy.cpp
→
src/platform/qt/VideoProxy.cpp
@@ -58,11 +58,16 @@ }
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::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(); }