Core: Fix flushing a read video log

This commit is contained in:
Vicki Pfau 2017-04-23 23:24:48 -07:00
parent deffdc79a0
commit c4aa669cf1
1 changed files with 9 additions and 4 deletions

View File

@ -80,6 +80,7 @@ struct mVideoLogContext {
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 @@ static void _flushBuffer(struct mVideoLogContext* context) {
}
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);