A failed waveform decode is asked again
Browse files at this commit43e146d27ead5c6e4cd15ee6e19f1b2fb19ee6c6Parent: 9c53bb8- fix
- a failed waveform decode is asked again
4 changed files +146 -127
- crates/app/src/importing.rs +9 -4
- crates/app/src/player/export.rs +7 -2
- crates/app/src/subs.rs +21 -7
- crates/app/src/tests/editing.rs +109 -114
crates/app/src/importing.rsmodified+9 -4
| @@ -18,10 +18,15 @@ pub(crate) enum Wave { | ||
| 18 | 18 | Loading, |
| 19 | 19 | /// The file has no audio track. An answer, not a miss. |
| 20 | 20 | Silent, |
| 21 | - /// The decode failed. Drawn as its own mark rather than as [`Self::Silent`]: | |
| 22 | - /// "this file's sound could not be read" and "this file has no sound" look | |
| 23 | - /// the same on a lane, and the first is a bug report waiting to happen. | |
| 24 | - Failed, | |
| 21 | + /// The decode failed, at the moment it did. Drawn as its own mark rather | |
| 22 | + /// than as [`Self::Silent`]: "this file's sound could not be read" and | |
| 23 | + /// "this file has no sound" look the same on a lane, and the first is a | |
| 24 | + /// bug report waiting to happen. It is *not* an answer, though: a failure | |
| 25 | + /// may have had a reason that has since gone away (a file still being | |
| 26 | + /// copied when it arrived), so [`crate::subs::unseen_sources`] asks again | |
| 27 | + /// once the stamp is older than its cooldown -- which is what the stamp is | |
| 28 | + /// for. | |
| 29 | + Failed(std::time::Instant), | |
| 25 | 30 | Peaks(Arc<Vec<(f32, f32)>>), |
| 26 | 31 | } |
| 27 | 32 |
crates/app/src/player/export.rsmodified+7 -2
| @@ -2,6 +2,7 @@ | ||
| 2 | 2 | //! two of them decide. |
| 3 | 3 | |
| 4 | 4 | use crate::*; |
| 5 | +use std::time::Instant; | |
| 5 | 6 | |
| 6 | 7 | impl Player { |
| 7 | 8 | /// What [`timeline_math::lane_refuses`] asks to decide a video lane's |
| @@ -231,7 +232,7 @@ impl Player { | ||
| 231 | 232 | } |
| 232 | 233 | starting.push(path); |
| 233 | 234 | } |
| 234 | - for key in unseen_sources(session.sources(), &self.waves) { | |
| 235 | + for key in unseen_sources(session.sources(), &self.waves, Instant::now()) { | |
| 235 | 236 | self.waves.insert(key.clone(), Wave::Loading); |
| 236 | 237 | let decoded = cx.background_executor().spawn({ |
| 237 | 238 | let (path, stream) = key.clone(); |
| @@ -254,7 +255,11 @@ impl Player { | ||
| 254 | 255 | // A file whose sound we could not read is not a |
| 255 | 256 | // silent one, and a lane that drew it as silent is |
| 256 | 257 | // how a broken decode passes for a design choice. |
| 257 | - Err(_) => Wave::Failed, | |
| 258 | + // Stamped, and not an answer: a repaint past | |
| 259 | + // [`WAVE_RETRY`] asks again, so a failure whose | |
| 260 | + // cause went away (a file still being copied when | |
| 261 | + // it arrived) draws its envelope without a reopen. | |
| 262 | + Err(_) => Wave::Failed(Instant::now()), | |
| 258 | 263 | }, |
| 259 | 264 | ); |
| 260 | 265 | cx.notify(); |
crates/app/src/subs.rsmodified+21 -7
| @@ -333,9 +333,7 @@ pub(crate) fn subtitle_tail(session: &mut PlaybackSession, subs: Subs) -> Option | ||
| 333 | 333 | match subs { |
| 334 | 334 | Ok(tracks) => match session.add_subtitle_tracks(tracks) { |
| 335 | 335 | 0 => None, |
| 336 | - n => Some(format!( | |
| 337 | - " · {n} subtitle track(s)" | |
| 338 | - )), | |
| 336 | + n => Some(format!(" · {n} subtitle track(s)")), | |
| 339 | 337 | }, |
| 340 | 338 | Err(e) => Some(format!(" — SUBTITLES UNREAD: {e}")), |
| 341 | 339 | } |
| @@ -705,17 +703,33 @@ pub(crate) fn cues_at(cues: &[engine::subtitle::Cue], at: f64) -> Vec<&engine::s | ||
| 705 | 703 | .collect() |
| 706 | 704 | } |
| 707 | 705 | |
| 708 | -/// The sources a repaint has not asked about yet. A key that is already there | |
| 709 | -/// means "asked", whatever state it is in, which is what stops a decode already | |
| 710 | -/// running from being started again by the next of sixty repaints a second. | |
| 706 | +/// How long a failed waveform decode is left alone before the next repaint asks | |
| 707 | +/// again: long enough that sixty repaints a second do not become sixty decodes, | |
| 708 | +/// short enough that a file which arrived mid-copy has its envelope a moment | |
| 709 | +/// after it lands. The engine memoizes no failure for the same reason | |
| 710 | +/// ([`engine::waveform`]): the reason one failed may have gone away. | |
| 711 | +pub(crate) const WAVE_RETRY: std::time::Duration = std::time::Duration::from_secs(5); | |
| 712 | + | |
| 713 | +/// The sources a repaint has not asked about yet, as of `now`. A key that is | |
| 714 | +/// already there means "asked", whatever state it is in -- which is what stops | |
| 715 | +/// a decode already running from being started again by the next of sixty | |
| 716 | +/// repaints a second -- with one exception: a [`Wave::Failed`] older than | |
| 717 | +/// [`WAVE_RETRY`] is asked again, because a decode that failed once is not an | |
| 718 | +/// answer about the file, only about the moment it was tried. A file with no | |
| 719 | +/// audio (`Wave::Silent`) is an answer like any other and is never re-asked. | |
| 711 | 720 | pub(crate) fn unseen_sources( |
| 712 | 721 | sources: &[Source], |
| 713 | 722 | waves: &HashMap<(PathBuf, usize), Wave>, |
| 723 | + now: std::time::Instant, | |
| 714 | 724 | ) -> Vec<(PathBuf, usize)> { |
| 715 | 725 | sources |
| 716 | 726 | .iter() |
| 717 | 727 | .map(|s| (s.path.clone(), s.audio_stream)) |
| 718 | - .filter(|key| !waves.contains_key(key)) | |
| 728 | + .filter(|key| match waves.get(key) { | |
| 729 | + None => true, | |
| 730 | + Some(Wave::Failed(at)) => now.duration_since(*at) >= WAVE_RETRY, | |
| 731 | + Some(_) => false, | |
| 732 | + }) | |
| 719 | 733 | .collect() |
| 720 | 734 | } |
| 721 | 735 |
crates/app/src/tests/editing.rsmodified+109 -114
| @@ -109,11 +109,9 @@ fn a_song_opens_the_window_by_itself() { | ||
| 109 | 109 | // ...and it places, on the audio lane, through the door `insert_source` |
| 110 | 110 | // uses: a second copy of the song at the playhead. |
| 111 | 111 | session.seek(1.0); |
| 112 | - assert!( | |
| 113 | - session | |
| 114 | - .place_stream_at(1.0, &path, 0, Some(Lane::A1)) | |
| 115 | - .expect("its own file is on this timeline") | |
| 116 | - ); | |
| 112 | + assert!(session | |
| 113 | + .place_stream_at(1.0, &path, 0, Some(Lane::A1)) | |
| 114 | + .expect("its own file is on this timeline")); | |
| 117 | 115 | assert_eq!(session.lane_clips(Lane::A1).len(), 2); |
| 118 | 116 | assert!(session.lane_clips(Lane::V1).is_empty(), "still no picture"); |
| 119 | 117 | |
| @@ -345,13 +343,11 @@ fn a_caption_is_deleted_by_the_same_row_and_stroke_every_box_is() { | ||
| 345 | 343 | ); |
| 346 | 344 | // ...and the same reading with a clip under it is the clip menu, untouched: |
| 347 | 345 | // the flag is off wherever a `Clip` was clicked. |
| 348 | - assert!( | |
| 349 | - menu_items(Ctx { | |
| 350 | - timeline: true, | |
| 351 | - ..Ctx::default() | |
| 352 | - }) | |
| 353 | - .contains(&ActionId::Cut) | |
| 354 | - ); | |
| 346 | + assert!(menu_items(Ctx { | |
| 347 | + timeline: true, | |
| 348 | + ..Ctx::default() | |
| 349 | + }) | |
| 350 | + .contains(&ActionId::Cut)); | |
| 355 | 351 | } |
| 356 | 352 | |
| 357 | 353 | /// A timeline with a subtitle palette and an empty subtitle lane: what a |
| @@ -939,16 +935,14 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | ||
| 939 | 935 | } |
| 940 | 936 | assert!(!whole(ActionId::Delete, live).yes()); |
| 941 | 937 | assert!(!whole(ActionId::Paste, live).yes()); |
| 942 | - assert!( | |
| 943 | - whole( | |
| 944 | - ActionId::Paste, | |
| 945 | - Ctx { | |
| 946 | - clipboard: true, | |
| 947 | - ..live | |
| 948 | - } | |
| 949 | - ) | |
| 950 | - .yes() | |
| 951 | - ); | |
| 938 | + assert!(whole( | |
| 939 | + ActionId::Paste, | |
| 940 | + Ctx { | |
| 941 | + clipboard: true, | |
| 942 | + ..live | |
| 943 | + } | |
| 944 | + ) | |
| 945 | + .yes()); | |
| 952 | 946 | assert!(!whole(ActionId::CancelExport, live).yes()); |
| 953 | 947 | let busy = Ctx { |
| 954 | 948 | exporting: true, |
| @@ -988,7 +982,10 @@ fn the_clip_menu_dims_what_the_playhead_is_not_on_and_stays_in_the_window() { | ||
| 988 | 982 | assert_eq!(menu_at(point(px(10.), px(10.)), viewport, 150.), (10., 10.)); |
| 989 | 983 | assert_eq!( |
| 990 | 984 | menu_at(point(px(700.), px(380.)), viewport, 150.), |
| 991 | - (800. - crate::layout::MENU_EDGE - MENU_W, 400. - crate::layout::MENU_EDGE - 150.) | |
| 985 | + ( | |
| 986 | + 800. - crate::layout::MENU_EDGE - MENU_W, | |
| 987 | + 400. - crate::layout::MENU_EDGE - 150. | |
| 988 | + ) | |
| 992 | 989 | ); |
| 993 | 990 | // A window smaller than the menu loses its bottom, never its top: the |
| 994 | 991 | // top-left margin wins over the bottom-right one, because the items are |
| @@ -1165,16 +1162,14 @@ fn a_menu_offers_only_what_applies_and_is_drawn_inside_the_window() { | ||
| 1165 | 1162 | assert!(row_enable(RowItem::RemoveWithClips, placed).yes()); |
| 1166 | 1163 | let unplaced = row_items(live); |
| 1167 | 1164 | assert!(unplaced.contains(&RowItem::Remove) && !unplaced.contains(&RowItem::RemoveWithClips)); |
| 1168 | - assert!( | |
| 1169 | - !row_enable( | |
| 1170 | - RowItem::RemoveWithClips, | |
| 1171 | - RowCtx { | |
| 1172 | - exporting: true, | |
| 1173 | - ..placed | |
| 1174 | - } | |
| 1175 | - ) | |
| 1176 | - .yes() | |
| 1177 | - ); | |
| 1165 | + assert!(!row_enable( | |
| 1166 | + RowItem::RemoveWithClips, | |
| 1167 | + RowCtx { | |
| 1168 | + exporting: true, | |
| 1169 | + ..placed | |
| 1170 | + } | |
| 1171 | + ) | |
| 1172 | + .yes()); | |
| 1178 | 1173 | assert!(!row_enable(RowItem::Add, RowCtx::default()).yes()); |
| 1179 | 1174 | // Every refusal is short enough to sit in the hint column beside its |
| 1180 | 1175 | // label, the clip menu's rule. |
| @@ -1282,7 +1277,11 @@ fn the_hanging_menus_mount_at_the_room_root_and_their_rows_wear_chords_not_prose | ||
| 1282 | 1277 | } |
| 1283 | 1278 | // §9: no junk drawer. A label that fits the plate whole beside its |
| 1284 | 1279 | // chord, and never a sentence. |
| 1285 | - assert!(item.label().split_whitespace().count() <= 4, "{}", item.label()); | |
| 1280 | + assert!( | |
| 1281 | + item.label().split_whitespace().count() <= 4, | |
| 1282 | + "{}", | |
| 1283 | + item.label() | |
| 1284 | + ); | |
| 1286 | 1285 | } |
| 1287 | 1286 | // The two removes must not read as the same verb now that the column |
| 1288 | 1287 | // beside them is empty. |
| @@ -1604,11 +1603,9 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() { | ||
| 1604 | 1603 | let frames = session.file_frames(&second); |
| 1605 | 1604 | // Through the engine door `insert_source` uses, with the row's own |
| 1606 | 1605 | // stream: the button, the drop and this are one call. |
| 1607 | - assert!( | |
| 1608 | - session | |
| 1609 | - .place_stream_at(2.0, &second, 0, None) | |
| 1610 | - .expect("av2 is already on the timeline") | |
| 1611 | - ); | |
| 1606 | + assert!(session | |
| 1607 | + .place_stream_at(2.0, &second, 0, None) | |
| 1608 | + .expect("av2 is already on the timeline")); | |
| 1612 | 1609 | // The whole of source 1 went in and nothing was painted over: the |
| 1613 | 1610 | // timeline is longer by exactly that file. |
| 1614 | 1611 | assert_eq!(session.timeline_duration(), 9.0); |
| @@ -1635,11 +1632,9 @@ fn adding_a_row_drops_the_whole_source_in_at_the_playhead() { | ||
| 1635 | 1632 | let path = session.sources()[0].path.clone(); |
| 1636 | 1633 | let frames = session.file_frames(&path); |
| 1637 | 1634 | let end = session.timeline_duration(); |
| 1638 | - assert!( | |
| 1639 | - session | |
| 1640 | - .place_stream_at(end, &path, 1, None) | |
| 1641 | - .expect("the French track shares the timeline's parameters") | |
| 1642 | - ); | |
| 1635 | + assert!(session | |
| 1636 | + .place_stream_at(end, &path, 1, None) | |
| 1637 | + .expect("the French track shares the timeline's parameters")); | |
| 1643 | 1638 | assert_eq!(session.sources()[1].audio_stream, 1); |
| 1644 | 1639 | assert_eq!(session.timeline_duration(), end * 2.0); |
| 1645 | 1640 | // Both rows are the same file, so both rows are that file's length -- |
| @@ -1689,11 +1684,9 @@ fn a_row_dropped_on_the_open_bed_lands_under_the_pointer() { | ||
| 1689 | 1684 | |
| 1690 | 1685 | // ...and what the release does with it: the frame back through the same |
| 1691 | 1686 | // rate every box is drawn at, into the door the Add button uses too. |
| 1692 | - assert!( | |
| 1693 | - session | |
| 1694 | - .place_stream_at(f64::from(at) / fps, &second, 0, None) | |
| 1695 | - .expect("av2 is already on this timeline") | |
| 1696 | - ); | |
| 1687 | + assert!(session | |
| 1688 | + .place_stream_at(f64::from(at) / fps, &second, 0, None) | |
| 1689 | + .expect("av2 is already on this timeline")); | |
| 1697 | 1690 | let head = |lane| { |
| 1698 | 1691 | session |
| 1699 | 1692 | .lane_clips(lane) |
| @@ -1727,11 +1720,9 @@ fn removing_a_row_is_refused_while_it_plays_and_takes_the_row_away() { | ||
| 1727 | 1720 | session.import(&asset("test_av2.mp4")).expect("av2 matches"); |
| 1728 | 1721 | let second = session.sources()[1].path.clone(); |
| 1729 | 1722 | let end = session.timeline_duration(); |
| 1730 | - assert!( | |
| 1731 | - session | |
| 1732 | - .place_stream_at(end, &second, 0, None) | |
| 1733 | - .expect("a file just imported is on this timeline") | |
| 1734 | - ); | |
| 1723 | + assert!(session | |
| 1724 | + .place_stream_at(end, &second, 0, None) | |
| 1725 | + .expect("a file just imported is on this timeline")); | |
| 1735 | 1726 | let streams = HashMap::new(); |
| 1736 | 1727 | let rows = |session: &PlaybackSession| { |
| 1737 | 1728 | library_rows(session.sources(), &streams, &HashMap::new(), None, |_| 0).len() |
| @@ -2058,11 +2049,9 @@ fn a_track_can_be_added_dropped_on_edited_and_taken_back() { | ||
| 2058 | 2049 | // A library row let go over that row: the same door the Add button |
| 2059 | 2050 | // uses, told which lane it was let go over. |
| 2060 | 2051 | let path = session.sources()[0].path.clone(); |
| 2061 | - assert!( | |
| 2062 | - session | |
| 2063 | - .place_stream_at(1.0, &path, 0, Some(v2)) | |
| 2064 | - .expect("its own file is on this timeline") | |
| 2065 | - ); | |
| 2052 | + assert!(session | |
| 2053 | + .place_stream_at(1.0, &path, 0, Some(v2)) | |
| 2054 | + .expect("its own file is on this timeline")); | |
| 2066 | 2055 | assert_eq!(session.lane_clips(v2).len(), 1, "the drop landed on V2"); |
| 2067 | 2056 | assert_eq!(session.lane_clips(v2)[0].start, 30, "at the playhead"); |
| 2068 | 2057 | // ...with the sound it came with, on the row of its own the drop added: |
| @@ -2149,22 +2138,18 @@ fn a_selection_drag_moves_every_pick_by_the_same_delta() { | ||
| 2149 | 2138 | |
| 2150 | 2139 | // clip0 on V1 at the fixture's own start; clip1 on V1 ten seconds in, |
| 2151 | 2140 | // appended to the open bed and rippling nothing. |
| 2152 | - assert!( | |
| 2153 | - session | |
| 2154 | - .place_stream_at(10.0, &second, 0, None) | |
| 2155 | - .expect("av2 is on this timeline") | |
| 2156 | - ); | |
| 2141 | + assert!(session | |
| 2142 | + .place_stream_at(10.0, &second, 0, None) | |
| 2143 | + .expect("av2 is on this timeline")); | |
| 2157 | 2144 | let clip0 = session.lane_clips(Lane::V1)[0]; |
| 2158 | 2145 | let clip1 = session.lane_clips(Lane::V1)[1]; |
| 2159 | 2146 | assert_eq!((clip0.start, clip1.start), (0, 300)); |
| 2160 | 2147 | |
| 2161 | 2148 | // clipC on a second video row, well past both of the above. |
| 2162 | 2149 | let v2 = session.add_lane(LaneKind::Video); |
| 2163 | - assert!( | |
| 2164 | - session | |
| 2165 | - .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2166 | - .expect("test_av.mp4 is on this timeline") | |
| 2167 | - ); | |
| 2150 | + assert!(session | |
| 2151 | + .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2152 | + .expect("test_av.mp4 is on this timeline")); | |
| 2168 | 2153 | let clip_c = session.lane_clips(v2)[0]; |
| 2169 | 2154 | assert_eq!(clip_c.start, 600); |
| 2170 | 2155 | |
| @@ -2217,28 +2202,22 @@ fn a_selection_drag_refuses_as_one_set_when_any_pick_cannot_land() { | ||
| 2217 | 2202 | session.import(&asset("test_av2.mp4")).expect("av2 matches"); |
| 2218 | 2203 | let second = session.sources()[1].path.clone(); |
| 2219 | 2204 | |
| 2220 | - assert!( | |
| 2221 | - session | |
| 2222 | - .place_stream_at(10.0, &second, 0, None) | |
| 2223 | - .expect("av2 is on this timeline") | |
| 2224 | - ); | |
| 2205 | + assert!(session | |
| 2206 | + .place_stream_at(10.0, &second, 0, None) | |
| 2207 | + .expect("av2 is on this timeline")); | |
| 2225 | 2208 | let clip0 = session.lane_clips(Lane::V1)[0]; |
| 2226 | 2209 | let clip1 = session.lane_clips(Lane::V1)[1]; |
| 2227 | 2210 | |
| 2228 | 2211 | let v2 = session.add_lane(LaneKind::Video); |
| 2229 | - assert!( | |
| 2230 | - session | |
| 2231 | - .place_stream_at(0.0, &path, 0, Some(v2)) | |
| 2232 | - .expect("test_av.mp4 is on this timeline") | |
| 2233 | - ); | |
| 2212 | + assert!(session | |
| 2213 | + .place_stream_at(0.0, &path, 0, Some(v2)) | |
| 2214 | + .expect("test_av.mp4 is on this timeline")); | |
| 2234 | 2215 | let clip_c = session.lane_clips(v2)[0]; |
| 2235 | 2216 | // A clip clip1 is not picked, blocking the road on V2 the drag is about |
| 2236 | 2217 | // to try: clip1 dragged onto V2 lands its head inside this one. |
| 2237 | - assert!( | |
| 2238 | - session | |
| 2239 | - .place_stream_at(10.0, &second, 0, Some(v2)) | |
| 2240 | - .expect("av2 is on this timeline") | |
| 2241 | - ); | |
| 2218 | + assert!(session | |
| 2219 | + .place_stream_at(10.0, &second, 0, Some(v2)) | |
| 2220 | + .expect("av2 is on this timeline")); | |
| 2242 | 2221 | let blocker = session.lane_clips(v2)[1]; |
| 2243 | 2222 | assert_eq!(blocker.start, 300); |
| 2244 | 2223 | |
| @@ -2293,20 +2272,16 @@ fn a_three_pick_copy_paste_preserves_gaps_and_lane_assignment() { | ||
| 2293 | 2272 | session.import(&asset("test_av2.mp4")).expect("av2 matches"); |
| 2294 | 2273 | let second = session.sources()[1].path.clone(); |
| 2295 | 2274 | |
| 2296 | - assert!( | |
| 2297 | - session | |
| 2298 | - .place_stream_at(10.0, &second, 0, None) | |
| 2299 | - .expect("av2 is on this timeline") | |
| 2300 | - ); | |
| 2275 | + assert!(session | |
| 2276 | + .place_stream_at(10.0, &second, 0, None) | |
| 2277 | + .expect("av2 is on this timeline")); | |
| 2301 | 2278 | let clip0 = session.lane_clips(Lane::V1)[0]; |
| 2302 | 2279 | let clip1 = session.lane_clips(Lane::V1)[1]; |
| 2303 | 2280 | |
| 2304 | 2281 | let v2 = session.add_lane(LaneKind::Video); |
| 2305 | - assert!( | |
| 2306 | - session | |
| 2307 | - .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2308 | - .expect("test_av.mp4 is on this timeline") | |
| 2309 | - ); | |
| 2282 | + assert!(session | |
| 2283 | + .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2284 | + .expect("test_av.mp4 is on this timeline")); | |
| 2310 | 2285 | let clip_c = session.lane_clips(v2)[0]; |
| 2311 | 2286 | |
| 2312 | 2287 | // Copied in click order, out of the lanes each was clicked in -- exactly |
| @@ -2354,20 +2329,16 @@ fn a_colliding_set_paste_refuses_whole() { | ||
| 2354 | 2329 | session.import(&asset("test_av2.mp4")).expect("av2 matches"); |
| 2355 | 2330 | let second = session.sources()[1].path.clone(); |
| 2356 | 2331 | |
| 2357 | - assert!( | |
| 2358 | - session | |
| 2359 | - .place_stream_at(10.0, &second, 0, None) | |
| 2360 | - .expect("av2 is on this timeline") | |
| 2361 | - ); | |
| 2332 | + assert!(session | |
| 2333 | + .place_stream_at(10.0, &second, 0, None) | |
| 2334 | + .expect("av2 is on this timeline")); | |
| 2362 | 2335 | let clip0 = session.lane_clips(Lane::V1)[0]; |
| 2363 | 2336 | let clip1 = session.lane_clips(Lane::V1)[1]; |
| 2364 | 2337 | |
| 2365 | 2338 | let v2 = session.add_lane(LaneKind::Video); |
| 2366 | - assert!( | |
| 2367 | - session | |
| 2368 | - .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2369 | - .expect("test_av.mp4 is on this timeline") | |
| 2370 | - ); | |
| 2339 | + assert!(session | |
| 2340 | + .place_stream_at(20.0, &path, 0, Some(v2)) | |
| 2341 | + .expect("test_av.mp4 is on this timeline")); | |
| 2371 | 2342 | let clip_c = session.lane_clips(v2)[0]; |
| 2372 | 2343 | |
| 2373 | 2344 | let items = [(Lane::V1, clip0), (Lane::V1, clip1), (v2, clip_c)]; |
| @@ -2422,11 +2393,9 @@ fn a_grouped_clip_on_an_added_lane_closes_its_hole_with_its_caption() { | ||
| 2422 | 2393 | let (mut session, sub_lane) = with_subtitle_lane(); |
| 2423 | 2394 | let v2 = session.add_lane(LaneKind::Video); |
| 2424 | 2395 | let path = session.sources()[0].path.clone(); |
| 2425 | - assert!( | |
| 2426 | - session | |
| 2427 | - .place_stream_at(0.0, &path, 0, Some(v2)) | |
| 2428 | - .expect("its own file is on this timeline") | |
| 2429 | - ); | |
| 2396 | + assert!(session | |
| 2397 | + .place_stream_at(0.0, &path, 0, Some(v2)) | |
| 2398 | + .expect("its own file is on this timeline")); | |
| 2430 | 2399 | session |
| 2431 | 2400 | .place_sub(sub_lane, 0, one_second(0)) |
| 2432 | 2401 | .expect("the caption goes down"); |
| @@ -2486,20 +2455,38 @@ fn a_source_is_only_ever_asked_for_its_peaks_once() { | ||
| 2486 | 2455 | .collect::<Vec<_>>() |
| 2487 | 2456 | }; |
| 2488 | 2457 | let mut waves: HashMap<(PathBuf, usize), Wave> = HashMap::new(); |
| 2489 | - assert_eq!(unseen_sources(&sources, &waves), keys(&sources)); | |
| 2458 | + assert_eq!( | |
| 2459 | + unseen_sources(&sources, &waves, std::time::Instant::now()), | |
| 2460 | + keys(&sources) | |
| 2461 | + ); | |
| 2490 | 2462 | // The entry goes in when the decode *starts*, so the sixty repaints a |
| 2491 | 2463 | // second that happen while it runs must not start it again -- which is |
| 2492 | 2464 | // what this asserts about a key whose value is not an answer yet. |
| 2493 | 2465 | waves.insert((a.clone(), 0), Wave::Loading); |
| 2494 | 2466 | assert_eq!( |
| 2495 | - unseen_sources(&sources, &waves), | |
| 2467 | + unseen_sources(&sources, &waves, std::time::Instant::now()), | |
| 2496 | 2468 | keys(&sources[1..]), |
| 2497 | 2469 | "the file's other stream is a key of its own" |
| 2498 | 2470 | ); |
| 2499 | 2471 | // A file with no audio is an answer like any other: never re-asked. |
| 2500 | 2472 | waves.insert((a, 1), Wave::Silent); |
| 2501 | 2473 | waves.insert((b.clone(), 0), Wave::Silent); |
| 2502 | - assert!(unseen_sources(&sources, &waves).is_empty()); | |
| 2474 | + assert!(unseen_sources(&sources, &waves, std::time::Instant::now()).is_empty()); | |
| 2475 | + // A decode that *failed* is not an answer: the reason may have gone away | |
| 2476 | + // (the file was still being copied when it arrived), so it is asked again | |
| 2477 | + // -- once the stamp is older than the cooldown, so sixty repaints a second | |
| 2478 | + // do not become sixty decodes. | |
| 2479 | + let now = std::time::Instant::now(); | |
| 2480 | + waves.insert((b.clone(), 0), Wave::Failed(now)); | |
| 2481 | + assert!( | |
| 2482 | + unseen_sources(&sources, &waves, now).is_empty(), | |
| 2483 | + "a failure that just landed is not re-asked at once" | |
| 2484 | + ); | |
| 2485 | + assert_eq!( | |
| 2486 | + unseen_sources(&sources, &waves, now + crate::subs::WAVE_RETRY), | |
| 2487 | + keys(&sources[2..]), | |
| 2488 | + "and is asked again once the cooldown is out" | |
| 2489 | + ); | |
| 2503 | 2490 | // The stream probe is per *file*: the two entries of `a` ask once. |
| 2504 | 2491 | let mut streams: HashMap<PathBuf, Vec<StreamInfo>> = HashMap::new(); |
| 2505 | 2492 | assert_eq!( |
| @@ -2802,13 +2789,21 @@ fn every_verb_the_spine_carried_is_a_right_click_row() { | ||
| 2802 | 2789 | // Every menu is a list of actions the keyboard already reaches, so every |
| 2803 | 2790 | // row can wear its chord (DESIGN §4): a row built here out of an id the |
| 2804 | 2791 | // registry never files would print an empty column. |
| 2805 | - for action in MENU_ITEMS.into_iter().chain(BENCH_ITEMS).chain(heads.iter().copied()) { | |
| 2792 | + for action in MENU_ITEMS | |
| 2793 | + .into_iter() | |
| 2794 | + .chain(BENCH_ITEMS) | |
| 2795 | + .chain(heads.iter().copied()) | |
| 2796 | + { | |
| 2806 | 2797 | assert!( |
| 2807 | 2798 | ActionId::ALL.contains(&action), |
| 2808 | 2799 | "{action:?} is a menu row and not a registered action" |
| 2809 | 2800 | ); |
| 2810 | 2801 | } |
| 2811 | - for list in [MENU_ITEMS.to_vec(), BENCH_ITEMS.to_vec(), lane_items(Lane::A1)] { | |
| 2802 | + for list in [ | |
| 2803 | + MENU_ITEMS.to_vec(), | |
| 2804 | + BENCH_ITEMS.to_vec(), | |
| 2805 | + lane_items(Lane::A1), | |
| 2806 | + ] { | |
| 2812 | 2807 | let first = list.iter().position(|&a| destructive(a)); |
| 2813 | 2808 | if let Some(first) = first { |
| 2814 | 2809 | assert!( |