Record your screen, ship a demo. Free and open-source, GPU-accelerated, no watermarks, no subscriptions. Windows, macOS, Linux. Actively maintained.
TypeScript cross-platformelectronffmpegopen-sourceproduct-demorustscreen-capturescreen-recorderscreen-recordingscreen-studioscreencastspeech-to-texttypescriptvideo-editingvideo-editorwaylandwgpuwhisper
fix(preview): recompose a paused frame at the time it was shown at
EtienneLescot13631421cb52
diff --git a/crates/compositor/src/live.rs b/crates/compositor/src/live.rsindex f7becd6bd..2165d1d35 100644--- a/crates/compositor/src/live.rs+++ b/crates/compositor/src/live.rs@@ -397,6 +397,8 @@ impl Player {self.idx = (source_time_sec * self.sdec.fps()).round().max(0.0) as u32;self.has_current_frame = true;self.use_current_on_next_step = true;+ // Not composed yet: a `recompose` before the next frame must not reuse the old time.+ self.composed_time_sec.set(self.sdec.cur_time_sec());Ok(true)}@@ -430,6 +432,8 @@ impl Player {self.idx = incoming.idx;self.has_current_frame = true;self.use_current_on_next_step = true;+ // Not composed yet: a `recompose` before the next frame must not reuse the old clip's time.+ self.composed_time_sec.set(self.sdec.cur_time_sec());outgoing}@@ -682,8 +686,20 @@ impl Player {}/// Recompose la frame courante (déjà décodée) — rafraîchit après un changement de param.+ /// At the time it was last composed at, not at its pts: a held frame placed by a seek on+ /// Linux, or held when playback paused, is shown at the playhead, and a settle pass or a+ /// param change sent the cursor and the published position back to the pts.pub unsafe fn recompose(&self, comp: &Compositor, cfg: &Cfg) -> Result<bool> {- self.recompose_at(comp, cfg, self.sdec.cur_time_sec())+ self.recompose_at(comp, cfg, self.composed_time_sec.get())+ }++ /// Anchors the playhead at `t` on a frame positioned but not composed yet (a re-anchor or+ /// a clip change from the app): a `recompose` composes it there, and the returned+ /// accumulator puts the playback clock there (`anchor_acc`).+ pub unsafe fn anchor_at(&self, t: f64) -> f64 {+ let pts = self.sdec.cur_time_sec();+ self.composed_time_sec.set(t.max(pts));+ anchor_acc(t, pts)}/// Recomposes the current frame with the cursor, zooms and programme time at `clock_sec`@@ -1687,8 +1703,9 @@ unsafe fn render_thread(};match switch_result {Ok(()) => {- // The app's re-anchor names the playhead: the clock restarts there.- acc = anchor_acc(request.source_time_sec, player.screen_time_sec());+ // The app's re-anchor names the playhead: the clock restarts there, and a+ // paused recompose (the `clip_changed` branch below) composes there.+ acc = player.anchor_at(request.source_time_sec);// Condition sur `repositioned`, pas sur `same_media` : un repositionnement// qui a échoué est retombé sur l'ouverture complète, donc des décodeurs// ONT été fermés et le cache doit être vidé malgré des médias identiques.diff --git a/crates/compositor/tests/held_frame_clock.rs b/crates/compositor/tests/held_frame_clock.rsindex 4e6b45989..c5dad9c9e 100644--- a/crates/compositor/tests/held_frame_clock.rs+++ b/crates/compositor/tests/held_frame_clock.rs@@ -67,10 +67,19 @@ fn a_held_frame_follows_the_playback_clock() {"programme time {advanced} instead of {at_pts} + 0.25 s");+ // Paused there, a param change or a settle pass recomposes: the frame keeps the time it+ // was shown at. At the pts, the cursor and the published position went back.comp.set_programme_time(None);assert!(player.recompose(&comp, &cfg).expect("recompose"));- assert_eq!(comp.programme_time(), Some(at_pts), "recompose stays at the pts");- assert_eq!(player.composed_time_sec(), held);+ assert_eq!(comp.programme_time(), Some(advanced), "recompose keeps the time it was composed at");+ assert_eq!(player.composed_time_sec(), held + 0.25);++ // A re-anchor positions the decoders without composing: the next recompose is at the+ // anchored playhead, never at the time the frame before it was composed at.+ assert!(player.seek_active(0.5).expect("seek_active"), "re-anchor");+ player.anchor_at(0.5);+ assert!(player.recompose(&comp, &cfg).expect("recompose"));+ assert_eq!(player.composed_time_sec(), 0.5f64.max(player.screen_time_sec()));}}