all repos — mgba @ fc3e47a4bab1465b91e7368c6396b222f65f51cb

mGBA Game Boy Advance Emulator

Feature: Allow configuring waiting on frame flushing in proxy
Vicki Pfau vi@endrift.com
Fri, 27 Nov 2020 18:24:02 -0800
commit

fc3e47a4bab1465b91e7368c6396b222f65f51cb

parent

bb74b60cd9033fe1dd4cf0607b379033902dfc4d

M include/mgba/feature/video-logger.hinclude/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.csrc/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.cppsrc/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.cppsrc/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.hsrc/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();