mVL: Add parameter for closing the video log backing
Vicki Pfau vi@endrift.com
Thu, 25 Jun 2020 01:24:30 -0700
5 files changed,
12 insertions(+),
9 deletions(-)
M
include/mgba/feature/video-logger.h
→
include/mgba/feature/video-logger.h
@@ -117,7 +117,7 @@ void mVideoLogContextSetOutput(struct mVideoLogContext*, struct VFile*);
void mVideoLogContextWriteHeader(struct mVideoLogContext*, struct mCore* core); bool mVideoLogContextLoad(struct mVideoLogContext*, struct VFile*); -void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext*); +void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext*, bool closeVF); void mVideoLogContextRewind(struct mVideoLogContext*, struct mCore*); void* mVideoLogContextInitialState(struct mVideoLogContext*, size_t* size);
M
src/feature/video-logger.c
→
src/feature/video-logger.c
@@ -723,7 +723,7 @@ context->backing->write(context->backing, writeBuffer, read);
} } -void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* context) { +void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* context, bool closeVF) { if (context->write) { _flushBuffer(context);@@ -749,6 +749,10 @@ inflateEnd(&context->channels[i].inflateStream);
context->channels[i].inflating = false; } #endif + } + + if (closeVF && context->backing) { + context->backing->close(context->backing); } free(context);
M
src/gb/core.c
→
src/gb/core.c
@@ -1066,7 +1066,7 @@
static void _GBVLPDeinit(struct mCore* core) { struct GBCore* gbcore = (struct GBCore*) core; if (gbcore->logContext) { - mVideoLogContextDestroy(core, gbcore->logContext); + mVideoLogContextDestroy(core, gbcore->logContext, true); } _GBCoreDeinit(core); }@@ -1095,7 +1095,7 @@ static bool _GBVLPLoadROM(struct mCore* core, struct VFile* vf) {
struct GBCore* gbcore = (struct GBCore*) core; gbcore->logContext = mVideoLogContextCreate(NULL); if (!mVideoLogContextLoad(gbcore->logContext, vf)) { - mVideoLogContextDestroy(core, gbcore->logContext); + mVideoLogContextDestroy(core, gbcore->logContext, false); gbcore->logContext = NULL; return false; }
M
src/gba/core.c
→
src/gba/core.c
@@ -1224,7 +1224,7 @@
static void _GBAVLPDeinit(struct mCore* core) { struct GBACore* gbacore = (struct GBACore*) core; if (gbacore->logContext) { - mVideoLogContextDestroy(core, gbacore->logContext); + mVideoLogContextDestroy(core, gbacore->logContext, true); } _GBACoreDeinit(core); }@@ -1253,7 +1253,7 @@ static bool _GBAVLPLoadROM(struct mCore* core, struct VFile* vf) {
struct GBACore* gbacore = (struct GBACore*) core; gbacore->logContext = mVideoLogContextCreate(NULL); if (!mVideoLogContextLoad(gbacore->logContext, vf)) { - mVideoLogContextDestroy(core, gbacore->logContext); + mVideoLogContextDestroy(core, gbacore->logContext, false); gbacore->logContext = NULL; return false; }
M
src/platform/qt/CoreController.cpp
→
src/platform/qt/CoreController.cpp
@@ -871,9 +871,8 @@ return;
} Interrupter interrupter(this); - mVideoLogContextDestroy(m_threadContext.core, m_vl); - if (m_vlVf && closeVf) { - m_vlVf->close(m_vlVf); + mVideoLogContextDestroy(m_threadContext.core, m_vl, closeVf); + if (closeVf) { m_vlVf = nullptr; } m_vl = nullptr;