forge
Explore
Log in

Don't you dare go Hollow

A refused file names the refusal on its library row

Browse files at this commit

c2e01467bda6775e0405e9858c75849c68b064d9Ahmet Kaan GümüşParent: 0c9d76c
  • fix
    • a refused file names the refusal on its library row
Show full message
fix(app): a refused file names the refusal on its library row

`engine::decode::probe` answers a stream this machine has no seat for
with an `Err` carrying the plugin's own words. `Player::refill` took
`engine::decode::probe(&path).ok()`, so the refusal and "a file with no
decoder to name" both became a missing map entry -- and a missing entry
drew an empty second line, the same line a song draws. A file that cannot
be decoded therefore looked exactly like a file that needs no word, and
the freeze that followed looked like the end of the film.

The map now holds a `Decoder` that can say all three things: asked and
not answered, the seat it will open on, or the refusal in the words the
decoder used. The row's existing detail line carries it; no second label
mechanism, and no change to what import or open does with the file.

Witness: `a_refused_file_names_the_refusal_on_its_row` drives the real
`engine::decode::probe` -- a `.mkv` that is not a container, refused by
the demuxer with no plugin and no hardware -- and asserts the row detail
equals the refusal. Red before (the row drew ""), green after, and red
again with `Decoder::detail`'s refusal arm reverted, and with
`From<engine::Result<..>>` mapping `Err` back to `Pending`.
crates/app/src/library_meta.rsmodified+45 -4
@@ -64,7 +64,7 @@ pub(crate) struct Row {
64 pub(crate) fn library_rows(64 pub(crate) fn library_rows(
65 sources: &[Source],65 sources: &[Source],
66 streams: &HashMap<PathBuf, Vec<StreamInfo>>,66 streams: &HashMap<PathBuf, Vec<StreamInfo>>,
67- decoders: &HashMap<PathBuf, Option<(Option<Codec>, Backend)>>,67+ decoders: &HashMap<PathBuf, Decoder>,
68 timeline_audio: Option<(u32, u16)>,68 timeline_audio: Option<(u32, u16)>,
69 frames: impl Fn(&Path) -> u32,69 frames: impl Fn(&Path) -> u32,
70 ) -> Vec<Row> {70 ) -> Vec<Row> {
@@ -89,9 +89,7 @@ pub(crate) fn library_rows(
89 detail: join_detail(89 detail: join_detail(
90 &decoders90 &decoders
91 .get(&source.path)91 .get(&source.path)
92- .copied()92+ .map_or_else(|| Decoder::Pending.detail(), Decoder::detail),
93- .flatten()
94- .map_or_else(String::new, |(codec, backend)| decode_label(codec, backend)),
95 &info93 &info
96 .filter(|_| of_file.len() > 1)94 .filter(|_| of_file.len() > 1)
97 .map_or_else(String::new, stream_detail),95 .map_or_else(String::new, stream_detail),
@@ -196,6 +194,49 @@ pub(crate) fn decode_label(codec: Option<Codec>, backend: Backend) -> String {
196 }194 }
197 }195 }
198 196
197+/// What the one-shot probe said about a file: the seat it will open on, or --
198+/// when the decoder itself refused -- the refusal, in the decoder's own words.
199+///
200+/// Three answers, not two, because "asked" and "refused" are not the same
201+/// answer. Both used to be a missing entry, and a missing entry drew an empty
202+/// second line -- the same line a song draws -- so a file this machine cannot
203+/// decode was indistinguishable from one that needs no word at all.
204+#[derive(Debug, Clone, PartialEq)]
205+pub(crate) enum Decoder {
206+ /// Asked and not yet answered: the probe is still walking the file. A
207+ /// real wait, and one that claims nothing while it lasts.
208+ Pending,
209+ /// The codec (`None` for a still, which has no coded stream) and the seat
210+ /// the engine picked for it.
211+ Seat(Option<Codec>, Backend),
212+ /// The decoder refused this file, and these are its words. Not a message
213+ /// of this program's own making: the probe is `engine::decode::probe`,
214+ /// and the refusal is the one opening the file would give.
215+ Refused(String),
216+}
217+
218+impl From<engine::Result<(Option<Codec>, Backend)>> for Decoder {
219+ fn from(probed: engine::Result<(Option<Codec>, Backend)>) -> Self {
220+ match probed {
221+ Ok((codec, backend)) => Self::Seat(codec, backend),
222+ Err(why) => Self::Refused(why.to_string()),
223+ }
224+ }
225+}
226+
227+impl Decoder {
228+ /// What the row's second line says about the file's decoder: the seat for
229+ /// a file that opens, the refusal for one that does not, and nothing for a
230+ /// probe still running.
231+ pub(crate) fn detail(&self) -> String {
232+ match self {
233+ Self::Pending => String::new(),
234+ Self::Seat(codec, backend) => decode_label(*codec, *backend),
235+ Self::Refused(why) => why.clone(),
236+ }
237+ }
238+}
239+
199 /// How a row names its file: the file alone when it has one audio stream or240 /// How a row names its file: the file alone when it has one audio stream or
200 /// none, and the file plus which stream this row is when it has several --241 /// none, and the file plus which stream this row is when it has several --
201 /// counted from 1, the way a player numbers tracks.242 /// counted from 1, the way a player numbers tracks.
crates/app/src/main.rsmodified+10 -9
@@ -68,11 +68,11 @@ use engine::transform::TransformParams;
68 use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession};68 use engine::{Clip, Codec, ExportHandle, Frame, MediaBitrate, PlaybackSession};
69 use gpui::{69 use gpui::{
70 AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div,70 AnyElement, App, Application, Bounds, ClickEvent, Context, Corners, CursorStyle, Div,
71- DragMoveEvent, FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent,71+ DragMoveEvent, FocusHandle, KeyDownEvent, MouseButton, MouseDownEvent, MouseExitEvent,
72- MouseExitEvent, MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage,72+ MouseMoveEvent, MouseUpEvent, PathBuilder, Pixels, Point, RenderImage, ScrollDelta,
73- ScrollDelta, ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign,73+ ScrollHandle, ScrollWheelEvent, SharedString, Size, Stateful, TextAlign, TitlebarOptions,
74- TitlebarOptions, Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px,74+ Window, WindowBounds, WindowOptions, canvas, div, point, prelude::*, px, relative, rgb, rgba,
75- relative, rgb, rgba, size,75+ size,
76 };76 };
77 77
78 struct Player {78 struct Player {
@@ -278,13 +278,14 @@ struct Player {
278 /// must stay in the map or every repaint would ask again.278 /// must stay in the map or every repaint would ask again.
279 syncs: HashMap<PathBuf, Vec<u32>>,279 syncs: HashMap<PathBuf, Vec<u32>>,
280 /// Which decoder each source will run on, probed once at import and kept:280 /// Which decoder each source will run on, probed once at import and kept:
281- /// the codec (`None` for a still) and the seat the engine picked for it.281+ /// the codec (`None` for a still) and the seat the engine picked for it --
282+ /// or, where the decoder refused the file, the refusal in its own words.
282 /// What a library row says *before* anything plays; the running answer is283 /// What a library row says *before* anything plays; the running answer is
283 /// the session's own (`PlaybackSession::decode_backend`), which follows a284 /// the session's own (`PlaybackSession::decode_backend`), which follows a
284 /// fallback this cannot. Filled like `sizes`: presence means "asked", and285 /// fallback this cannot. Filled like `sizes`: presence means "asked", and
285- /// `None` is a source with no decoder to name -- a song, or one the probe286+ /// `Decoder::Pending` is that asked-but-unanswered window -- which must
286- /// refused -- which must stay in the map or every repaint would ask again.287+ /// stay in the map or every repaint would ask again.
287- decoders: HashMap<PathBuf, Option<(Option<Codec>, Backend)>>,288+ decoders: HashMap<PathBuf, Decoder>,
288 /// What an export of the picked settings would open -- the picture's seat289 /// What an export of the picked settings would open -- the picture's seat
289 /// or the copy that means it opens none, and the sound's -- and what it was290 /// or the copy that means it opens none, and the sound's -- and what it was
290 /// asked about: the settings, the canvas and the *cuts*, since where they291 /// asked about: the settings, the canvas and the *cuts*, since where they
crates/app/src/player/export.rsmodified+13 -6
@@ -180,13 +180,15 @@ impl Player {
180 // a frame of it plays. Off the render thread like the streams above: a180 // a frame of it plays. Off the render thread like the streams above: a
181 // stream the plugin takes costs one VA-API init (~90 ms) to answer.181 // stream the plugin takes costs one VA-API init (~90 ms) to answer.
182 for path in unseen_paths(session.sources(), &self.decoders) {182 for path in unseen_paths(session.sources(), &self.decoders) {
183- self.decoders.insert(path.clone(), None);183+ self.decoders.insert(path.clone(), Decoder::Pending);
184 let probed = cx.background_executor().spawn({184 let probed = cx.background_executor().spawn({
185 let path = path.clone();185 let path = path.clone();
186- // A song and a source no decoder here takes are both `None`:186+ // A refusal is kept in the decoder's own words, and the row
187- // the row says nothing about them rather than guessing, and187+ // shows them: a file this machine cannot decode is the one
188- // import refused the second at the door anyway.188+ // whose second line has to say so. A song is a different
189- async move { engine::decode::probe(&path).ok() }189+ // answer entirely -- it has no coded stream, and the probe
190+ // says so by naming the still seat.
191+ async move { Decoder::from(engine::decode::probe(&path)) }
190 });192 });
191 cx.spawn(async move |this, cx| {193 cx.spawn(async move |this, cx| {
192 let probed = probed.await;194 let probed = probed.await;
@@ -644,7 +646,12 @@ impl Player {
644 ///646 ///
645 /// Escape retreats one step at a time (DESIGN.md:146): the field first,647 /// Escape retreats one step at a time (DESIGN.md:146): the field first,
646 /// the moment second.648 /// the moment second.
647- pub(crate) fn export_moment_key(&mut self, key: &str, shift: bool, cx: &mut Context<Self>) -> bool {649+ pub(crate) fn export_moment_key(
650+ &mut self,
651+ key: &str,
652+ shift: bool,
653+ cx: &mut Context<Self>,
654+ ) -> bool {
648 if !self.export_open {655 if !self.export_open {
649 return false;656 return false;
650 }657 }
crates/app/src/tests/editing.rsmodified+166 -71
@@ -109,9 +109,11 @@ fn a_song_opens_the_window_by_itself() {
109 // ...and it places, on the audio lane, through the door `insert_source`109 // ...and it places, on the audio lane, through the door `insert_source`
110 // uses: a second copy of the song at the playhead.110 // uses: a second copy of the song at the playhead.
111 session.seek(1.0);111 session.seek(1.0);
112- assert!(session112+ assert!(
113- .place_stream_at(1.0, &path, 0, Some(Lane::A1))113+ session
114- .expect("its own file is on this timeline"));114+ .place_stream_at(1.0, &path, 0, Some(Lane::A1))
115+ .expect("its own file is on this timeline")
116+ );
115 assert_eq!(session.lane_clips(Lane::A1).len(), 2);117 assert_eq!(session.lane_clips(Lane::A1).len(), 2);
116 assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture");118 assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture");
117 119
@@ -256,6 +258,63 @@ fn every_audio_stream_of_a_file_is_a_row_usable_or_not() {
256 assert_eq!(rows[1].tint, 1, "the other file is the other tint");258 assert_eq!(rows[1].tint, 1, "the other file is the other tint");
257 }259 }
258 260
261+/// A file the decoder refuses says so on its own row, in the decoder's own
262+/// words. The refusal is the only thing a person can act on for a file that
263+/// will not play, and before this the row drew an empty second line -- the
264+/// same line a song draws, which claims nothing and means nothing.
265+///
266+/// Dumped through the real [`engine::decode::probe`], not a hand-written
267+/// `Err`: a `.mkv` that is not a container is refused by the demuxer, with no
268+/// plugin and no hardware involved, so the words under test are the ones the
269+/// engine really produces.
270+#[test]
271+fn a_refused_file_names_the_refusal_on_its_row() {
272+ let junk = std::env::temp_dir().join("edith-lane-j-refused.mkv");
273+ std::fs::write(&junk, b"not a container, and never will be").expect("write the junk file");
274+ let words = engine::decode::probe(&junk)
275+ .expect_err("a file that is not a stream is refused")
276+ .to_string();
277+ assert!(
278+ !words.is_empty(),
279+ "a refusal that says nothing says nothing"
280+ );
281+
282+ let mut decoders = HashMap::new();
283+ decoders.insert(junk.clone(), Decoder::from(engine::decode::probe(&junk)));
284+ let rows = library_rows(
285+ &[Source {
286+ path: junk.clone(),
287+ audio_stream: 0,
288+ }],
289+ &HashMap::new(),
290+ &decoders,
291+ None,
292+ |_| 0,
293+ );
294+ assert_eq!(
295+ rows[0].detail, words,
296+ "the row carries the refusal verbatim"
297+ );
298+
299+ // A probe still running says nothing, and must keep saying nothing: an
300+ // empty second line is a real answer here, not a missing one.
301+ let mut pending = HashMap::new();
302+ pending.insert(junk.clone(), Decoder::Pending);
303+ let rows = library_rows(
304+ &[Source {
305+ path: junk.clone(),
306+ audio_stream: 0,
307+ }],
308+ &HashMap::new(),
309+ &pending,
310+ None,
311+ |_| 0,
312+ );
313+ assert_eq!(rows[0].detail, "", "an unasked decoder claims nothing");
314+
315+ std::fs::remove_file(&junk).ok();
316+}
317+
259 /// What the clip menu offers, and where it hangs. The two items that act on318 /// What the clip menu offers, and where it hangs. The two items that act on
260 /// the playhead rather than on the clicked clip are the ones that can be319 /// the playhead rather than on the clicked clip are the ones that can be
261 /// inapplicable, and a menu at the edge of the window has to come back inside320 /// inapplicable, and a menu at the edge of the window has to come back inside
@@ -343,11 +402,13 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() {
343 );402 );
344 // ...and the same reading with a clip under it is the clip menu, untouched:403 // ...and the same reading with a clip under it is the clip menu, untouched:
345 // the flag is off wherever a `Clip` was clicked.404 // the flag is off wherever a `Clip` was clicked.
346- assert!(menu_items(Ctx {405+ assert!(
347- timeline: true,406+ menu_items(Ctx {
348- ..Ctx::default()407+ timeline: true,
349- })408+ ..Ctx::default()
350- .contains(&ActionId::Cut));409+ })
410+ .contains(&ActionId::Cut)
411+ );
351 }412 }
352 413
353 /// A timeline with a subtitle palette and an empty subtitle lane: what a414 /// A timeline with a subtitle palette and an empty subtitle lane: what a
@@ -949,14 +1010,16 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() {
949 }1010 }
950 assert!(!whole(ActionId::Delete, live).yes());1011 assert!(!whole(ActionId::Delete, live).yes());
951 assert!(!whole(ActionId::Paste, live).yes());1012 assert!(!whole(ActionId::Paste, live).yes());
952- assert!(whole(1013+ assert!(
953- ActionId::Paste,1014+ whole(
954- Ctx {1015+ ActionId::Paste,
955- clipboard: true,1016+ Ctx {
956- ..live1017+ clipboard: true,
957- }1018+ ..live
958- )1019+ }
959- .yes());1020+ )
1021+ .yes()
1022+ );
960 assert!(!whole(ActionId::CancelExport, live).yes());1023 assert!(!whole(ActionId::CancelExport, live).yes());
961 let busy = Ctx {1024 let busy = Ctx {
962 exporting: true,1025 exporting: true,
@@ -1176,14 +1239,16 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() {
1176 assert!(row_enable(RowItem::RemoveWithClips, placed).yes());1239 assert!(row_enable(RowItem::RemoveWithClips, placed).yes());
1177 let unplaced = row_items(live);1240 let unplaced = row_items(live);
1178 assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips));1241 assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips));
1179- assert!(!row_enable(1242+ assert!(
1180- RowItem::RemoveWithClips,1243+ !row_enable(
1181- RowCtx {1244+ RowItem::RemoveWithClips,
1182- exporting: true,1245+ RowCtx {
1183- ..placed1246+ exporting: true,
1184- }1247+ ..placed
1185- )1248+ }
1186- .yes());1249+ )
1250+ .yes()
1251+ );
1187 assert!(!row_enable(RowItem::Add, RowCtx::default()).yes());1252 assert!(!row_enable(RowItem::Add, RowCtx::default()).yes());
1188 // Every refusal is short enough to sit in the hint column beside its1253 // Every refusal is short enough to sit in the hint column beside its
1189 // label, the clip menu's rule.1254 // label, the clip menu's rule.
@@ -1617,9 +1682,11 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() {
1617 let frames = session.file_frames(&second);1682 let frames = session.file_frames(&second);
1618 // Through the engine door `insert_source` uses, with the row's own1683 // Through the engine door `insert_source` uses, with the row's own
1619 // stream: the button, the drop and this are one call.1684 // stream: the button, the drop and this are one call.
1620- assert!(session1685+ assert!(
1621- .place_stream_at(2.0, &second, 0, None)1686+ session
1622- .expect("av2 is already on the timeline"));1687+ .place_stream_at(2.0, &second, 0, None)
1688+ .expect("av2 is already on the timeline")
1689+ );
1623 // The whole of source 1 went in and nothing was painted over: the1690 // The whole of source 1 went in and nothing was painted over: the
1624 // timeline is longer by exactly that file.1691 // timeline is longer by exactly that file.
1625 assert_eq!(session.timeline_duration(), 9.0);1692 assert_eq!(session.timeline_duration(), 9.0);
@@ -1646,9 +1713,11 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() {
1646 let path = session.sources()[0].path.clone();1713 let path = session.sources()[0].path.clone();
1647 let frames = session.file_frames(&path);1714 let frames = session.file_frames(&path);
1648 let end = session.timeline_duration();1715 let end = session.timeline_duration();
1649- assert!(session1716+ assert!(
1650- .place_stream_at(end, &path, 1, None)1717+ session
1651- .expect("the French track shares the timeline's parameters"));1718+ .place_stream_at(end, &path, 1, None)
1719+ .expect("the French track shares the timeline's parameters")
1720+ );
1652 assert_eq!(session.sources()[1].audio_stream, 1);1721 assert_eq!(session.sources()[1].audio_stream, 1);
1653 assert_eq!(session.timeline_duration(), end * 2.0);1722 assert_eq!(session.timeline_duration(), end * 2.0);
1654 // Both rows are the same file, so both rows are that file's length --1723 // Both rows are the same file, so both rows are that file's length --
@@ -1698,9 +1767,11 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() {
1698 1767
1699 // ...and what the release does with it: the frame back through the same1768 // ...and what the release does with it: the frame back through the same
1700 // rate every box is drawn at, into the door the Add button uses too.1769 // rate every box is drawn at, into the door the Add button uses too.
1701- assert!(session1770+ assert!(
1702- .place_stream_at(f64::from(at) / fps, &second, 0, None)1771+ session
1703- .expect("av2 is already on this timeline"));1772+ .place_stream_at(f64::from(at) / fps, &second, 0, None)
1773+ .expect("av2 is already on this timeline")
1774+ );
1704 let head = |lane| {1775 let head = |lane| {
1705 session1776 session
1706 .lane_clips(lane)1777 .lane_clips(lane)
@@ -1734,9 +1805,11 @@ fn removing_a_row_is_refused_while_it_plays_and_takes_the_row_away() {
1734 session.import(&asset("test_av2.mp4")).expect("av2 matches");1805 session.import(&asset("test_av2.mp4")).expect("av2 matches");
1735 let second = session.sources()[1].path.clone();1806 let second = session.sources()[1].path.clone();
1736 let end = session.timeline_duration();1807 let end = session.timeline_duration();
1737- assert!(session1808+ assert!(
1738- .place_stream_at(end, &second, 0, None)1809+ session
1739- .expect("a file just imported is on this timeline"));1810+ .place_stream_at(end, &second, 0, None)
1811+ .expect("a file just imported is on this timeline")
1812+ );
1740 let streams = HashMap::new();1813 let streams = HashMap::new();
1741 let rows = |session: &PlaybackSession| {1814 let rows = |session: &PlaybackSession| {
1742 library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len()1815 library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len()
@@ -1957,7 +2030,7 @@ fn trim_to_playhead_moves_the_selected_clips_edge_and_undoes_in_one_step() {
1957 /// it makes.2030 /// it makes.
1958 #[test]2031 #[test]
1959 fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() {2032 fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() {
1960- use crate::player::actions::{history_step, HistoryBefore, SessionCaches};2033+ use crate::player::actions::{HistoryBefore, SessionCaches, history_step};
1961 2034
1962 let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");2035 let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
1963 session.set_gain(0.0);2036 session.set_gain(0.0);
@@ -2037,7 +2110,7 @@ fn the_windows_settings_caches_follow_the_session_across_undo_and_redo() {
2037 /// keyed by where a cue sits -- but because the step moves the cues under it.2110 /// keyed by where a cue sits -- but because the step moves the cues under it.
2038 #[test]2111 #[test]
2039 fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() {2112 fn the_subtitle_pick_follows_its_track_across_an_undo_of_a_removal() {
2040- use crate::player::actions::{history_step, HistoryBefore, SessionCaches};2113+ use crate::player::actions::{HistoryBefore, SessionCaches, history_step};
2041 2114
2042 let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");2115 let mut session = PlaybackSession::open(asset("test_av.mp4")).expect("open the fixture");
2043 session.set_gain(0.0);2116 session.set_gain(0.0);
@@ -2268,9 +2341,11 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() {
2268 // A library row let go over that row: the same door the Add button2341 // A library row let go over that row: the same door the Add button
2269 // uses, told which lane it was let go over.2342 // uses, told which lane it was let go over.
2270 let path = session.sources()[0].path.clone();2343 let path = session.sources()[0].path.clone();
2271- assert!(session2344+ assert!(
2272- .place_stream_at(1.0, &path, 0, Some(v2))2345+ session
2273- .expect("its own file is on this timeline"));2346+ .place_stream_at(1.0, &path, 0, Some(v2))
2347+ .expect("its own file is on this timeline")
2348+ );
2274 assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2");2349 assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2");
2275 assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead");2350 assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead");
2276 // ...with the sound it came with, on the row of its own the drop added:2351 // ...with the sound it came with, on the row of its own the drop added:
@@ -2357,18 +2432,22 @@ fn a_selection_drag_moves_every_pick_by_the_same_delta() {
2357 2432
2358 // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in,2433 // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in,
2359 // appended to the open bed and rippling nothing.2434 // appended to the open bed and rippling nothing.
2360- assert!(session2435+ assert!(
2361- .place_stream_at(10.0, &second, 0, None)2436+ session
2362- .expect("av2 is on this timeline"));2437+ .place_stream_at(10.0, &second, 0, None)
2438+ .expect("av2 is on this timeline")
2439+ );
2363 let clip0 = session.lane_clips(Lane::V1)[0];2440 let clip0 = session.lane_clips(Lane::V1)[0];
2364 let clip1 = session.lane_clips(Lane::V1)[1];2441 let clip1 = session.lane_clips(Lane::V1)[1];
2365 assert_eq!((clip0.start, clip1.start), (0, 300));2442 assert_eq!((clip0.start, clip1.start), (0, 300));
2366 2443
2367 // clipC on a second video row, well past both of the above.2444 // clipC on a second video row, well past both of the above.
2368 let v2 = session.add_lane(LaneKind::Video);2445 let v2 = session.add_lane(LaneKind::Video);
2369- assert!(session2446+ assert!(
2370- .place_stream_at(20.0, &path, 0, Some(v2))2447+ session
2371- .expect("test_av.mp4 is on this timeline"));2448+ .place_stream_at(20.0, &path, 0, Some(v2))
2449+ .expect("test_av.mp4 is on this timeline")
2450+ );
2372 let clip_c = session.lane_clips(v2)[0];2451 let clip_c = session.lane_clips(v2)[0];
2373 assert_eq!(clip_c.start, 600);2452 assert_eq!(clip_c.start, 600);
2374 2453
@@ -2421,22 +2500,28 @@ fn a_selection_drag_refuses_as_one_set_when_any_pick_cannot_land() {
2421 session.import(&asset("test_av2.mp4")).expect("av2 matches");2500 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2422 let second = session.sources()[1].path.clone();2501 let second = session.sources()[1].path.clone();
2423 2502
2424- assert!(session2503+ assert!(
2425- .place_stream_at(10.0, &second, 0, None)2504+ session
2426- .expect("av2 is on this timeline"));2505+ .place_stream_at(10.0, &second, 0, None)
2506+ .expect("av2 is on this timeline")
2507+ );
2427 let clip0 = session.lane_clips(Lane::V1)[0];2508 let clip0 = session.lane_clips(Lane::V1)[0];
2428 let clip1 = session.lane_clips(Lane::V1)[1];2509 let clip1 = session.lane_clips(Lane::V1)[1];
2429 2510
2430 let v2 = session.add_lane(LaneKind::Video);2511 let v2 = session.add_lane(LaneKind::Video);
2431- assert!(session2512+ assert!(
2432- .place_stream_at(0.0, &path, 0, Some(v2))2513+ session
2433- .expect("test_av.mp4 is on this timeline"));2514+ .place_stream_at(0.0, &path, 0, Some(v2))
2515+ .expect("test_av.mp4 is on this timeline")
2516+ );
2434 let clip_c = session.lane_clips(v2)[0];2517 let clip_c = session.lane_clips(v2)[0];
2435 // A clip clip1 is not picked, blocking the road on V2 the drag is about2518 // A clip clip1 is not picked, blocking the road on V2 the drag is about
2436 // to try: clip1 dragged onto V2 lands its head inside this one.2519 // to try: clip1 dragged onto V2 lands its head inside this one.
2437- assert!(session2520+ assert!(
2438- .place_stream_at(10.0, &second, 0, Some(v2))2521+ session
2439- .expect("av2 is on this timeline"));2522+ .place_stream_at(10.0, &second, 0, Some(v2))
2523+ .expect("av2 is on this timeline")
2524+ );
2440 let blocker = session.lane_clips(v2)[1];2525 let blocker = session.lane_clips(v2)[1];
2441 assert_eq!(blocker.start, 300);2526 assert_eq!(blocker.start, 300);
2442 2527
@@ -2491,16 +2576,20 @@ fn a_three_pick_copy_paste_preserves_gaps_and_lane_assignment() {
2491 session.import(&asset("test_av2.mp4")).expect("av2 matches");2576 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2492 let second = session.sources()[1].path.clone();2577 let second = session.sources()[1].path.clone();
2493 2578
2494- assert!(session2579+ assert!(
2495- .place_stream_at(10.0, &second, 0, None)2580+ session
2496- .expect("av2 is on this timeline"));2581+ .place_stream_at(10.0, &second, 0, None)
2582+ .expect("av2 is on this timeline")
2583+ );
2497 let clip0 = session.lane_clips(Lane::V1)[0];2584 let clip0 = session.lane_clips(Lane::V1)[0];
2498 let clip1 = session.lane_clips(Lane::V1)[1];2585 let clip1 = session.lane_clips(Lane::V1)[1];
2499 2586
2500 let v2 = session.add_lane(LaneKind::Video);2587 let v2 = session.add_lane(LaneKind::Video);
2501- assert!(session2588+ assert!(
2502- .place_stream_at(20.0, &path, 0, Some(v2))2589+ session
2503- .expect("test_av.mp4 is on this timeline"));2590+ .place_stream_at(20.0, &path, 0, Some(v2))
2591+ .expect("test_av.mp4 is on this timeline")
2592+ );
2504 let clip_c = session.lane_clips(v2)[0];2593 let clip_c = session.lane_clips(v2)[0];
2505 2594
2506 // Copied in click order, out of the lanes each was clicked in -- exactly2595 // Copied in click order, out of the lanes each was clicked in -- exactly
@@ -2548,16 +2637,20 @@ fn a_colliding_set_paste_refuses_whole() {
2548 session.import(&asset("test_av2.mp4")).expect("av2 matches");2637 session.import(&asset("test_av2.mp4")).expect("av2 matches");
2549 let second = session.sources()[1].path.clone();2638 let second = session.sources()[1].path.clone();
2550 2639
2551- assert!(session2640+ assert!(
2552- .place_stream_at(10.0, &second, 0, None)2641+ session
2553- .expect("av2 is on this timeline"));2642+ .place_stream_at(10.0, &second, 0, None)
2643+ .expect("av2 is on this timeline")
2644+ );
2554 let clip0 = session.lane_clips(Lane::V1)[0];2645 let clip0 = session.lane_clips(Lane::V1)[0];
2555 let clip1 = session.lane_clips(Lane::V1)[1];2646 let clip1 = session.lane_clips(Lane::V1)[1];
2556 2647
2557 let v2 = session.add_lane(LaneKind::Video);2648 let v2 = session.add_lane(LaneKind::Video);
2558- assert!(session2649+ assert!(
2559- .place_stream_at(20.0, &path, 0, Some(v2))2650+ session
2560- .expect("test_av.mp4 is on this timeline"));2651+ .place_stream_at(20.0, &path, 0, Some(v2))
2652+ .expect("test_av.mp4 is on this timeline")
2653+ );
2561 let clip_c = session.lane_clips(v2)[0];2654 let clip_c = session.lane_clips(v2)[0];
2562 2655
2563 let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];2656 let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)];
@@ -2612,9 +2705,11 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() {
2612 let (mut session, sub_lane) = with_subtitle_lane();2705 let (mut session, sub_lane) = with_subtitle_lane();
2613 let v2 = session.add_lane(LaneKind::Video);2706 let v2 = session.add_lane(LaneKind::Video);
2614 let path = session.sources()[0].path.clone();2707 let path = session.sources()[0].path.clone();
2615- assert!(session2708+ assert!(
2616- .place_stream_at(0.0, &path, 0, Some(v2))2709+ session
2617- .expect("its own file is on this timeline"));2710+ .place_stream_at(0.0, &path, 0, Some(v2))
2711+ .expect("its own file is on this timeline")
2712+ );
2618 session2713 session
2619 .place_sub(sub_lane, 0, one_second(0))2714 .place_sub(sub_lane, 0, one_second(0))
2620 .expect("the caption goes down");2715 .expect("the caption goes down");
crates/app/src/tests/mod.rsmodified+30 -29
@@ -10,55 +10,56 @@ mod media;
10 mod view;10 mod view;
11 11
12 use super::{12 use super::{
13- active_lane, auto_bps, band_label, bitrate_detail, clipboard_after_remove, color_snap,13+ ACCENT_PRIMARY, AUDIO_KBPS, BENCH_ITEMS, BG_RAISED, BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN,
14- containers, destructive, enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label,14+ COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, Clip, ColorEdit, Ctx,
15- eq_graph_h, eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, export_settings,15+ DEFAULT_AUDIO_KBPS, Decoder, EQ_BANDS_MAX, EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW,
16- format_refusal, fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder,16+ EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H, EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP,
17- histogram, inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lane_items,17+ EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE, EXPORT_DONE, EXPORT_MOMENT_H, Enable, EncoderSeat,
18- lanes_h, marked, menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play,18+ FORMATS, Format, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN, KEYS_ROW_H, KEYS_W,
19- notice_tone, panel_h, parse_budget, project_path, proxies_to_start, push_notice, px_below,19+ KeyRow, LABEL_H, LANE_H, LANES_MAX, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W, Lane, MB_FLOOR,
20- range_word, rate_label, retarget, row_enable, row_items, scrub_due, secs_label, should_resync,20+ MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, NO_FILE, NOTICES_MAX, NumberEdit, OVERLAID, PANEL_H,
21+ RESYNC_GAP, ROW_ITEMS, RULER_HIT_H, RowCtx, RowItem, SCROLL_NOTCH_SHARE, SILENCE_ROWS,
22+ SOURCE_TINTS, SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING,
23+ SUB_PLAN_CHARS, Source, Speed, StreamInfo, SubPickKey, TIMELINE_SHARE, Transport, VOLUME_W,
24+ VizSlot, Volume, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, Wave, ZOOM_MIN_FRAMES, active_lane,
25+ auto_bps, band_label, bitrate_detail, clipboard_after_remove, color_snap, containers,
26+ destructive, enable, enable_lane, envelope, eq_card_w, eq_freq, eq_freq_label, eq_graph_h,
27+ eq_spectrum, eq_x, eq_y, estimated_bytes, export_path, export_settings, format_refusal,
28+ fps_choices, fps_label, frac_along, frac_down, frame_at, frame_rate_ladder, histogram,
29+ inserted_band, is_project, keymap, keys_rows, keys_rows_matching, lane_items, lanes_h, marked,
30+ menu_at, menu_items, menu_rows_h, next_container, normalise, nothing_to_play, notice_tone,
31+ panel_h, parse_budget, project_path, proxies_to_start, push_notice, px_below, range_word,
32+ rate_label, retarget, row_enable, row_items, scrub_due, secs_label, should_resync,
21 silence_rate, size_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at,33 silence_rate, size_label, snap_cue, snap_marks, snapped, source_tint, span_partner, speed_at,
22 sub_pick_after_removal, sub_pick_after_restore, subtitle_plan, timecode, timeline_fixed_h,34 sub_pick_after_removal, sub_pick_after_restore, subtitle_plan, timecode, timeline_fixed_h,
23 tip_may_paint, transport, typed, unseen_paths, unseen_sources, viz_held_paint, whole_take,35 tip_may_paint, transport, typed, unseen_paths, unseen_sources, viz_held_paint, whole_take,
24- window_title, Clip, ColorEdit, Ctx, Enable, EncoderSeat, Format, KeyRow, Lane, NumberEdit,36+ window_title,
25- RowCtx, RowItem, Source, Speed, StreamInfo, SubPickKey, Transport, VizSlot, Volume, Wave,
26- ACCENT_PRIMARY, AUDIO_KBPS, BENCH_ITEMS, BG_RAISED, BPS_COARSE, BPS_FINE, BPS_MAX, BPS_MIN,
27- COLOR_BANDS, COLOR_BAR_W, COLOR_STEP, COLOR_W, CONTROL_H, DEFAULT_AUDIO_KBPS, EQ_BANDS_MAX,
28- EQ_CURVE_STEPS, EQ_FFT, EQ_FREQ_HIGH, EQ_FREQ_LOW, EQ_FREQ_STEP, EQ_GAIN_LIMIT, EQ_GRAPH_H,
29- EQ_HANDLE, EQ_Q_HIGH, EQ_Q_LOW, EQ_Q_STEP, EQ_SPECTRUM_DB, EQ_TICKS, EQ_W_MAX, ESCAPE,
30- EXPORT_DONE, EXPORT_MOMENT_H, FORMATS, HEADER_H, HIST_BINS, HIST_H, HIST_SAMPLES, HIT_MIN,
31- KEYS_ROW_H, KEYS_W, LABEL_H, LANES_MAX, LANE_H, LATE_RESYNC, LIBRARY_MAX_W, LIBRARY_MIN_W,
32- MB_FLOOR, MENU_ITEMS, MENU_PAD, MENU_ROW_H, MENU_W, NOTICES_MAX, NO_FILE, OVERLAID, PANEL_H,
33- RESYNC_GAP, ROW_ITEMS, RULER_HIT_H, SCROLL_NOTCH_SHARE, SILENCE_ROWS, SOURCE_TINTS,
34- SPEED_PRESETS, SPEED_STEP, STATUS_ERROR, STATUS_SUCCESS, STATUS_WARNING, SUB_PLAN_CHARS,
35- TIMELINE_SHARE, VOLUME_W, WAVE_BPS, WAVE_COL, WAVE_COLS_MAX, ZOOM_MIN_FRAMES,
36 };37 };
37 38
38 use super::{39 use super::{
39- arrival, audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label,40+ ActionId, Choice, EDGE_W, ETA_SPAN, Edge, FITS, FRAME_RATES, IMPORT_STALL, Import, ImportStage,
41+ Landing, LaneKind, PPS_DEFAULT, PPS_MIN, Preset, RESOLUTIONS, Repeat, SAMPLE_RATES, SEEK_STALL,
42+ Scale, ScanKey, ScanPlan, SilenceScan, SubClip, View, ZOOM_OUT_MARGIN, ZOOM_STEP, arrival,
43+ audio_rate_choices, av1_hw_warning, clip_width, clock, encoder_choices, encoder_label,
40 eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing,44 eta_secs, file_name, file_uri, fit_choices, frames_of_us, full_scan_key, import_line, landing,
41 lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress,45 lane_refuses, launch_queue, library_rows, live_idx, next_fit, next_resolution, note_progress,
42 pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats,46 pending_fps_choices, pending_resolution_choices, px_along, read_ahead, repeats,
43 resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line,47 resolution_choices, resolution_ladder, sample_rate_choices, scan_plan, seek_line,
44 silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices,48 silence_cached, silence_line, slice_whole_levels, source_secs, stash_or_write, tone_choices,
45- tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable, ActionId, Choice, Edge,49+ tone_label, trimmed_clip, trimmed_sub, trims, unscannable, unusable,
46- Import, ImportStage, Landing, LaneKind, Preset, Repeat, Scale, ScanKey, ScanPlan, SilenceScan,
47- SubClip, View, EDGE_W, ETA_SPAN, FITS, FRAME_RATES, IMPORT_STALL, PPS_DEFAULT, PPS_MIN,
48- RESOLUTIONS, SAMPLE_RATES, SEEK_STALL, ZOOM_OUT_MARGIN, ZOOM_STEP,
49 };50 };
50 51
51 use super::{52 use super::{
52- carries_subtitles, cue_box, cues_at, file_tint, is_subtitle, lang_human, sub_bottom,53+ SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT, Subs, carries_subtitles, cue_box, cues_at,
53- sub_pick_name, subtitle_detail, subtitle_notice, subtitle_rows, subtitle_tail,54+ file_tint, is_subtitle, lang_human, sub_bottom, sub_pick_name, subtitle_detail,
54- subtitle_toggle_notice, walk_subtitles, Subs, SUB_BOTTOM, SUB_CUE_MIN_W, SUB_LINE_H, SUB_TEXT,55+ subtitle_notice, subtitle_rows, subtitle_tail, subtitle_toggle_notice, walk_subtitles,
55 };56 };
56 57
57 use engine::PlaybackSession;58 use engine::PlaybackSession;
58 59
59 use engine::scale::FitPolicy;60 use engine::scale::FitPolicy;
60 61
61-use gpui::{point, px, size, Bounds, Pixels};62+use gpui::{Bounds, Pixels, point, px, size};
62 63
63 use std::collections::HashMap;64 use std::collections::HashMap;
64 65