forge
Explore
Log in

Don't you dare go Hollow

pw_utils: Clarify the screencast cadence time base

Browse files at this commit

8be4c6df68ddef2afd4ccdde7f27dbc782c30603zParent: 4fa7fdf
src/screencasting/pw_utils.rsmodified+9 -8
@@ -106,7 +106,6 @@ pub struct Cast {
106 formats: FormatSet,106 formats: FormatSet,
107 offer_alpha: bool,107 offer_alpha: bool,
108 cursor_mode: CursorMode,108 cursor_mode: CursorMode,
109- // The last slot in the capture cadence, rather than the time a late frame was rendered.
110 last_frame_time: Duration,109 last_frame_time: Duration,
111 last_frame_interval: Duration,110 last_frame_interval: Duration,
112 scheduled_redraw: Option<RegistrationToken>,111 scheduled_redraw: Option<RegistrationToken>,
@@ -1022,19 +1021,21 @@ impl Cast {
1022 Ok(())1021 Ok(())
1023 }1022 }
1024 1023
1025- pub fn record_frame_time(&mut self, time: Duration) {1024+ pub fn record_frame_time(&mut self, recorded: Duration) {
1026 let interval = self.inner.borrow().min_time_between_frames;1025 let interval = self.inner.borrow().min_time_between_frames;
1027- let next = self.last_frame_time + interval;1026+ let ideal = self.last_frame_time + interval;
1028 1027
1029- // Absorb small scheduling delays without moving every subsequent frame back.1028+ // Absorb small (< 1 frame) differences in output refresh interval vs. screencast framerate
1029+ // to keep the screencast time base consistent instead of shifting forward every frame.
1030+ //
1030 // After a missed interval or a rate change, restart instead of catching up in a burst.1031 // After a missed interval or a rate change, restart instead of catching up in a burst.
1031 self.last_frame_time = if self.last_frame_interval == interval1032 self.last_frame_time = if self.last_frame_interval == interval
1032- && time >= self.last_frame_time1033+ && recorded >= self.last_frame_time
1033- && time < next + interval1034+ && recorded < ideal + interval
1034 {1035 {
1035- next1036+ ideal
1036 } else {1037 } else {
1037- time1038+ recorded
1038 };1039 };
1039 self.last_frame_interval = interval;1040 self.last_frame_interval = interval;
1040 }1041 }