Feature: Allow configuring waiting on frame flushing in proxy
Vicki Pfau vi@endrift.com
Fri, 27 Nov 2020 18:24:02 -0800
5 files changed,
11 insertions(+),
2 deletions(-)
M
include/mgba/feature/video-logger.h
→
include/mgba/feature/video-logger.h
@@ -57,6 +57,7 @@ void (*postEvent)(struct mVideoLogger* logger, enum mVideoLoggerEvent event);
void* dataContext; bool block; + bool waitOnFlush; void (*init)(struct mVideoLogger*); void (*deinit)(struct mVideoLogger*); void (*reset)(struct mVideoLogger*);
M
src/feature/video-logger.c
→
src/feature/video-logger.c
@@ -119,7 +119,6 @@
void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly) { if (readonly) { logger->writeData = _writeNull; - logger->block = true; } else { logger->writeData = _writeData; }@@ -134,6 +133,9 @@ logger->lock = NULL;
logger->unlock = NULL; logger->wait = NULL; logger->wake = NULL; + + logger->block = readonly; + logger->waitOnFlush = !readonly; } void mVideoLoggerRendererInit(struct mVideoLogger* logger) {@@ -263,7 +265,7 @@ 0,
0xDEADBEEF, }; logger->writeData(logger, &dirty, sizeof(dirty)); - if (logger->wait) { + if (logger->waitOnFlush && logger->wait) { logger->wait(logger); } }
M
src/platform/qt/DisplayGL.cpp
→
src/platform/qt/DisplayGL.cpp
@@ -435,6 +435,10 @@ }
mCoreSync* sync = &m_context->thread()->impl->sync; mCoreSyncWaitFrameStart(sync); dequeue(); + if (m_videoProxy) { + // Only block on the next frame if we're trying to run at roughly 60fps via audio + m_videoProxy->setBlocking(sync->audioWait && std::abs(60.f - sync->fpsTarget) < 0.1f); + } if (!m_delayTimer.isValid()) { m_delayTimer.start(); } else if (sync->audioWait || sync->videoFrameWait) {
M
src/platform/qt/VideoProxy.cpp
→
src/platform/qt/VideoProxy.cpp
@@ -14,6 +14,7 @@
VideoProxy::VideoProxy() { mVideoLoggerRendererCreate(&m_logger.d, false); m_logger.d.block = true; + m_logger.d.waitOnFlush = false; m_logger.d.init = &cbind<&VideoProxy::init>; m_logger.d.reset = &cbind<&VideoProxy::reset>;
M
src/platform/qt/VideoProxy.h
→
src/platform/qt/VideoProxy.h
@@ -24,6 +24,7 @@ VideoProxy();
void attach(CoreController*); void detach(CoreController*); + void setBlocking(bool block) { m_logger.d.waitOnFlush = block; } signals: void dataAvailable();