Core: Allow video playback to be non-blocking
Vicki Pfau vi@endrift.com
Mon, 17 Apr 2017 02:55:26 -0700
4 files changed,
6 insertions(+),
6 deletions(-)
M
src/feature/video-logger.c
→
src/feature/video-logger.c
@@ -168,9 +168,9 @@ };
logger->writeData(logger, &dirty, sizeof(dirty)); } -bool mVideoLoggerRendererRun(struct mVideoLogger* logger) { +bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block) { struct mVideoLoggerDirtyInfo item = {0}; - while (logger->readData(logger, &item, sizeof(item), false)) { + while (logger->readData(logger, &item, sizeof(item), block)) { switch (item.type) { case DIRTY_REGISTER: case DIRTY_PALETTE:@@ -186,7 +186,7 @@ default:
return false; } } - return false; + return !block; } static bool _writeData(struct mVideoLogger* logger, const void* data, size_t length) {
M
src/feature/video-logger.h
→
src/feature/video-logger.h
@@ -107,7 +107,7 @@
void mVideoLoggerRendererDrawScanline(struct mVideoLogger* logger, int y); void mVideoLoggerRendererFlush(struct mVideoLogger* logger); -bool mVideoLoggerRendererRun(struct mVideoLogger* logger); +bool mVideoLoggerRendererRun(struct mVideoLogger* logger, bool block); struct mCore; struct mVideoLogContext* mVideoLoggerCreate(struct mCore* core);
M
src/gba/core.c
→
src/gba/core.c
@@ -769,7 +769,7 @@ struct mCore* core = context;
struct GBACore* gbacore = (struct GBACore*) core; struct GBA* gba = core->board; - if (!mVideoLoggerRendererRun(&gbacore->logProxy.logger)) { + if (!mVideoLoggerRendererRun(&gbacore->logProxy.logger, true)) { GBAVideoProxyRendererUnshim(&gba->video, &gbacore->logProxy); gbacore->logProxy.logger.vf->seek(gbacore->logProxy.logger.vf, 0, SEEK_SET); core->loadState(core, gbacore->logContext->initialState);
M
src/gba/renderers/thread-proxy.c
→
src/gba/renderers/thread-proxy.c
@@ -174,7 +174,7 @@ break;
} proxyRenderer->threadState = PROXY_THREAD_BUSY; MutexUnlock(&proxyRenderer->mutex); - if (!mVideoLoggerRendererRun(&proxyRenderer->d.logger)) { + if (!mVideoLoggerRendererRun(&proxyRenderer->d.logger, false)) { // FIFO was corrupted proxyRenderer->threadState = PROXY_THREAD_STOPPED; mLOG(GBA_VIDEO, ERROR, "Proxy thread queue got corrupted!");