Keep max stream ID separate from current stream ID
Jeffrey Pfau jeffrey@endrift.com
Tue, 29 Jul 2014 22:50:19 -0700
2 files changed,
14 insertions(+),
5 deletions(-)
M
src/gba/gba-rr.c
→
src/gba/gba-rr.c
@@ -38,6 +38,7 @@ }
rr->streamDir = stream; rr->movieStream = 0; rr->streamId = 1; + rr->maxStreamId = 1; return true; }@@ -58,24 +59,31 @@ if (!rr->movieStream || !_seekTag(rr, rr->movieStream, TAG_BEGIN)) {
GBARRStopPlaying(rr); } } + rr->frames = 0; + rr->lagFrames = 0; return true; } -uint32_t GBARRIncrementStream(struct GBARRContext* rr) { - uint32_t newStreamId = rr->streamId + 1; +bool GBARRIncrementStream(struct GBARRContext* rr) { + uint32_t newStreamId = rr->maxStreamId + 1; uint32_t oldStreamId = rr->streamId; if (GBARRIsRecording(rr) && rr->movieStream) { _emitTag(rr, rr->movieStream, TAG_END); + _emitTag(rr, rr->movieStream, TAG_FRAME_COUNT); + rr->movieStream->write(rr->movieStream, &rr->frames, sizeof(rr->frames)); + _emitTag(rr, rr->movieStream, TAG_LAG_COUNT); + rr->movieStream->write(rr->movieStream, &rr->lagFrames, sizeof(rr->lagFrames)); _emitTag(rr, rr->movieStream, TAG_NEXT_TIME); rr->movieStream->write(rr->movieStream, &newStreamId, sizeof(newStreamId)); } if (!GBARRLoadStream(rr, newStreamId)) { - return 0; + return false; } + rr->maxStreamId = newStreamId; _emitTag(rr, rr->movieStream, TAG_PREVIOUSLY); rr->movieStream->write(rr->movieStream, &oldStreamId, sizeof(oldStreamId)); _emitTag(rr, rr->movieStream, TAG_BEGIN); - return rr->streamId; + return true; } bool GBARRStartPlaying(struct GBARRContext* rr, bool autorecord) {
M
src/gba/gba-rr.h
→
src/gba/gba-rr.h
@@ -31,6 +31,7 @@ // Metadata
uint32_t frames; uint32_t lagFrames; uint32_t streamId; + uint32_t maxStreamId; // Streaming state struct VDir* streamDir;@@ -45,7 +46,7 @@ void GBARRContextDestroy(struct GBA*);
bool GBARRSetStream(struct GBARRContext*, struct VDir*); bool GBARRLoadStream(struct GBARRContext*, uint32_t streamId); -uint32_t GBARRIncrementStream(struct GBARRContext*); +bool GBARRIncrementStream(struct GBARRContext*); bool GBARRStartPlaying(struct GBARRContext*, bool autorecord); void GBARRStopPlaying(struct GBARRContext*);