@@ -2389,17 +2389,6 @@
}
while (true) {
// Break out of the encoding loop if any of the following are true:
// a) The stream is ending
// b) Sunshine is quitting
// c) The capture side is waiting to reinit and we've encoded at least one frame
//
// If we have to reinit before we have received any captured frames, we will encode
// the blank dummy frame just to let Moonlight know that we're alive.
if (shutdown_event->peek() || !images->running() || (reinit_event.peek() && frame_nr > 1)) {
break;
}
bool requested_idr_frame = false;
while (invalidate_ref_frames_events->peek()) {
@@ -2430,6 +2419,20 @@
} else if (!images->running()) {
break;
}
}
// Break out of the encoding loop if any of the following are true:
// a) The stream is ending
// b) Sunshine is quitting
// c) The capture side is waiting to reinit and we've encoded at least one frame
//
// If we have to reinit before we have received any captured frames, we will encode
// the blank dummy frame just to let Moonlight know that we're alive.
//
// Ensure that this check occurs as close as possible to the encode call to prevent packets
// in flight after encoder teardown.
if (shutdown_event->peek() || !images->running() || (reinit_event.peek() && frame_nr > 1)) {
break;
}
if (encode(frame_nr++, *session, packets, channel_data, frame_timestamp)) {