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 f70185da5f
commit 32fc0dac31
2 changed files with 19 additions and 8 deletions

View File

@ -4,6 +4,7 @@ Emulation fixes:
Other fixes: Other fixes:
- CMake: Fix build with downstream minizip that exports incompatible symbols - CMake: Fix build with downstream minizip that exports incompatible symbols
- Debugger: Close trace log when done tracing - Debugger: Close trace log when done tracing
- Qt: Fix running proxied video if it gets pushed to the main thread
0.8.4: (2020-10-29) 0.8.4: (2020-10-29)
Emulation fixes: Emulation fixes:

View File

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