all repos — mgba @ c4aa669cf19b64703d525753c0c736beee56d0e3

mGBA Game Boy Advance Emulator

Core: Fix flushing a read video log
Vicki Pfau vi@endrift.com
Sun, 23 Apr 2017 23:24:48 -0700
commit

c4aa669cf19b64703d525753c0c736beee56d0e3

parent

deffdc79a0e657365b223a168092a4814fd77b97

1 files changed, 9 insertions(+), 4 deletions(-)

jump to
M src/feature/video-logger.csrc/feature/video-logger.c

@@ -80,6 +80,7 @@ size_t initialStateSize;

uint32_t nChannels; struct mVideoLogChannel channels[mVL_MAX_CHANNELS]; + bool write; uint32_t activeChannel; struct VFile* backing; };

@@ -320,6 +321,8 @@ struct mVideoLogContext* mVideoLogContextCreate(struct mCore* core) {

struct mVideoLogContext* context = malloc(sizeof(*context)); memset(context, 0, sizeof(*context)); + context->write = !!core; + if (core) { context->initialStateSize = core->stateSize(core); context->initialState = anonymousMemoryMap(context->initialStateSize);

@@ -449,11 +452,13 @@ }

} void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* context) { - _flushBuffer(context); + if (context->write) { + _flushBuffer(context); - struct mVLBlockHeader header = { 0 }; - STORE_32LE(mVL_BLOCK_FOOTER, 0, &header.blockType); - context->backing->write(context->backing, &header, sizeof(header)); + struct mVLBlockHeader header = { 0 }; + STORE_32LE(mVL_BLOCK_FOOTER, 0, &header.blockType); + context->backing->write(context->backing, &header, sizeof(header)); + } if (core) { core->endVideoLog(core);