Add ability to resume recording as soon as a movie ends

This commit is contained in:
Jeffrey Pfau 2014-07-20 03:14:55 -07:00
parent 74dae5033b
commit b4d6d11d19
3 changed files with 19 additions and 9 deletions

View File

@ -31,18 +31,24 @@ bool GBARRSetStream(struct GBARRContext* rr, struct VDir* stream) {
return !!rr->inputsStream;
}
bool GBARRStartPlaying(struct GBARRContext* rr) {
bool GBARRStartPlaying(struct GBARRContext* rr, bool autorecord) {
if (GBARRIsRecording(rr) || GBARRIsPlaying(rr)) {
return false;
}
rr->autorecord = autorecord;
if (rr->inputsStream->seek(rr->inputsStream, 0, SEEK_SET) < 0) {
return false;
}
if (rr->inputsStream->read(rr->inputsStream, &rr->nextInput, sizeof(rr->nextInput)) != sizeof(rr->nextInput)) {
return false;
}
rr->isPlaying = true;
rr->inputId = 0;
return rr->inputsStream->seek(rr->inputsStream, 0, SEEK_SET) == 0;
return true;
}
void GBARRStopPlaying(struct GBARRContext* rr) {
rr->isPlaying = 0;
rr->isPlaying = false;
}
bool GBARRStartRecording(struct GBARRContext* rr) {
@ -93,7 +99,10 @@ uint16_t GBARRQueryInput(struct GBARRContext* rr) {
return 0;
}
uint16_t keys;
rr->inputsStream->read(rr->inputsStream, &keys, sizeof(keys));
uint16_t keys = rr->nextInput;
rr->isPlaying = rr->inputsStream->read(rr->inputsStream, &rr->nextInput, sizeof(rr->nextInput)) == sizeof(rr->nextInput);
if (!rr->isPlaying && rr->autorecord) {
rr->isRecording = true;
}
return keys;
}

View File

@ -10,7 +10,8 @@ struct VFile;
struct GBARRContext {
// Playback state
bool isPlaying;
size_t inputId;
bool autorecord;
uint16_t nextInput;
// Recording state
bool isRecording;
@ -30,7 +31,7 @@ void GBARRContextDestroy(struct GBA*);
bool GBARRSetStream(struct GBARRContext*, struct VDir*);
bool GBARRStartPlaying(struct GBARRContext*);
bool GBARRStartPlaying(struct GBARRContext*, bool autorecord);
void GBARRStopPlaying(struct GBARRContext*);
bool GBARRStartRecording(struct GBARRContext*);
void GBARRStopRecording(struct GBARRContext*);

View File

@ -143,7 +143,7 @@ static void _GBASDLHandleKeypress(struct GBAThread* context, struct GBASDLEvents
GBARRContextCreate(context->gba);
GBARRSetStream(context->gba->rr, context->stateDir);
GBARRStopRecording(context->gba->rr);
GBARRStartPlaying(context->gba->rr);
GBARRStartPlaying(context->gba->rr, event->keysym.mod & KMOD_SHIFT);
GBAThreadContinue(context);
break;
default: