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:
- CMake: Fix build with downstream minizip that exports incompatible symbols
- 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)
Emulation fixes:

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();
}