mVL: Add parameter for closing the video log backing

This commit is contained in:
Vicki Pfau 2020-06-25 01:24:30 -07:00
parent 5ceec84560
commit 7973d70b04
5 changed files with 12 additions and 9 deletions

View File

@ -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);

View File

@ -723,7 +723,7 @@ static void _flushBuffer(struct mVideoLogContext* context) {
}
}
void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* context) {
void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* context, bool closeVF) {
if (context->write) {
_flushBuffer(context);
@ -751,6 +751,10 @@ void mVideoLogContextDestroy(struct mCore* core, struct mVideoLogContext* contex
#endif
}
if (closeVF && context->backing) {
context->backing->close(context->backing);
}
free(context);
}

View File

@ -1066,7 +1066,7 @@ static bool _GBVLPInit(struct mCore* core) {
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;
}

View File

@ -1224,7 +1224,7 @@ static bool _GBAVLPInit(struct mCore* core) {
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;
}

View File

@ -871,9 +871,8 @@ void CoreController::endVideoLog(bool closeVf) {
}
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;