Feature: Allow configuring waiting on frame flushing in proxy

This commit is contained in:
Vicki Pfau 2020-11-27 18:24:02 -08:00
parent bb74b60cd9
commit fc3e47a4ba
5 changed files with 11 additions and 2 deletions

View File

@ -57,6 +57,7 @@ struct mVideoLogger {
void* dataContext;
bool block;
bool waitOnFlush;
void (*init)(struct mVideoLogger*);
void (*deinit)(struct mVideoLogger*);
void (*reset)(struct mVideoLogger*);

View File

@ -119,7 +119,6 @@ static inline size_t _roundUp(size_t value, int shift) {
void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly) {
if (readonly) {
logger->writeData = _writeNull;
logger->block = true;
} else {
logger->writeData = _writeData;
}
@ -134,6 +133,9 @@ void mVideoLoggerRendererCreate(struct mVideoLogger* logger, bool readonly) {
logger->unlock = NULL;
logger->wait = NULL;
logger->wake = NULL;
logger->block = readonly;
logger->waitOnFlush = !readonly;
}
void mVideoLoggerRendererInit(struct mVideoLogger* logger) {
@ -263,7 +265,7 @@ void mVideoLoggerRendererFlush(struct mVideoLogger* logger) {
0xDEADBEEF,
};
logger->writeData(logger, &dirty, sizeof(dirty));
if (logger->wait) {
if (logger->waitOnFlush && logger->wait) {
logger->wait(logger);
}
}

View File

@ -435,6 +435,10 @@ void PainterGL::draw() {
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) {

View File

@ -14,6 +14,7 @@ using namespace QGBA;
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>;

View File

@ -24,6 +24,7 @@ public:
void attach(CoreController*);
void detach(CoreController*);
void setBlocking(bool block) { m_logger.d.waitOnFlush = block; }
signals:
void dataAvailable();