all repos — mgba @ 6291a62860376b1e4a5e0d3ee681b6c93eb10f68

mGBA Game Boy Advance Emulator

Fix stream recording resumption
Jeffrey Pfau jeffrey@endrift.com
Thu, 07 Aug 2014 02:01:17 -0700
commit

6291a62860376b1e4a5e0d3ee681b6c93eb10f68

parent

484a7f299a966cb8fbd90c9e06b332235073bae8

1 files changed, 17 insertions(+), 8 deletions(-)

jump to
M src/gba/gba-rr.csrc/gba/gba-rr.c

@@ -22,6 +22,7 @@

static bool _parseMetadata(struct GBARRContext* rr, struct VFile* vf); static bool _markStreamNext(struct GBARRContext* rr, uint32_t newStreamId, bool recursive); +static void _streamEndReached(struct GBARRContext* rr); static struct VFile* _openSavedata(struct GBARRContext* rr, int flags); static struct VFile* _openSavestate(struct GBARRContext* rr, int flags);

@@ -303,13 +304,7 @@ _emitTag(rr, rr->movieStream, TAG_FRAME);

rr->inputThisFrame = false; } else { if (!_seekTag(rr, rr->movieStream, TAG_FRAME)) { - uint32_t endStreamId = rr->streamId; - GBARRStopPlaying(rr); - if (rr->autorecord) { - rr->isRecording = true; - GBARRLoadStream(rr, endStreamId); - GBARRIncrementStream(rr, false); - } + _streamEndReached(rr); } } }

@@ -357,6 +352,7 @@ bool GBARRSkipSegment(struct GBARRContext* rr) {

rr->nextTime = 0; while (_readTag(rr, rr->movieStream) != TAG_EOF); if (!rr->nextTime || !GBARRLoadStream(rr, rr->nextTime)) { + _streamEndReached(rr); return false; } return true;

@@ -492,7 +488,6 @@ default:

break; } } - rr->maxStreamIdOffset = vf->seek(vf, 0, SEEK_SET); return true; }

@@ -546,6 +541,20 @@ }

return _markStreamNext(rr, currentStreamId, rr->previously); } return true; +} + +void _streamEndReached(struct GBARRContext* rr) { + if (!GBARRIsPlaying(rr)) { + return; + } + + uint32_t endStreamId = rr->streamId; + GBARRStopPlaying(rr); + if (rr->autorecord) { + rr->isRecording = true; + GBARRLoadStream(rr, endStreamId); + GBARRIncrementStream(rr, false); + } } struct VFile* _openSavedata(struct GBARRContext* rr, int flags) {