Skip to content

Commit 61d0ad6

Browse files
committed
try to do things in the right order
1 parent be5ffdb commit 61d0ad6

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

display/layer_controller.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,7 @@ class SCRReader : public BufferedFileReader {
402402
bool Play(Effect* f) {
403403
if (!*f) return false; // no files, do nothing
404404
PVLOG_VERBOSE << "SCR Playing " << f->GetName() << "\n";
405+
wait_for_previous_open_to_complete();
405406
sound_time_ms_ = SaberBase::sound_length * 1000;
406407
file_.PlayInternal(f);
407408
delayed_open_ = true;
@@ -410,6 +411,7 @@ class SCRReader : public BufferedFileReader {
410411
}
411412

412413
void Play(const char* filename) {
414+
wait_for_previous_open_to_complete();
413415
sound_time_ms_ = SaberBase::sound_length * 1000;
414416
file_.PlayInternal(filename);
415417
delayed_open_ = true;
@@ -424,6 +426,12 @@ class SCRReader : public BufferedFileReader {
424426

425427
bool IsActive() override { return active_ || delayed_open_; }
426428
protected:
429+
void wait_for_previous_open_to_complete() {
430+
while (delayed_open_ && !state_machine_.done()) {
431+
loop();
432+
check_open();
433+
}
434+
}
427435
void check_open() {
428436
if (delayed_open_ && state_machine_.done()) {
429437
active_ = true;

display/rgb565frame.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -649,7 +649,8 @@ class RGB565Frame : public SizedLayeredScreenControl<WIDTH, HEIGHT> {
649649
SLEEP_MICROS(next_frame_time_ - frame_end);
650650
}
651651
}
652-
lc_->LC_onStop();
652+
while (!lc_->LC_done()) YIELD();
653+
if (!layers[0].is_playing()) lc_->LC_onStop();
653654
while (!lc_->LC_done()) YIELD();
654655
}
655656

0 commit comments

Comments
 (0)