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

View File

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

View File

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