The seat line finishes the sentence about the sound
Browse files at this commitaa6d6991f27d2f32d88bc1de405c0ed41eba2a9dParent: 9fdee6f- fix
- the seat line finishes the sentence about the sound
2 changed files +67 -44
- crates/engine/src/export.rs +17 -0
- crates/engine/tests/backends.rs +50 -44
crates/engine/src/export.rsmodified+17 -0
| @@ -2221,6 +2221,23 @@ fn run( | ||
| 2221 | 2221 | "export audio: waited for after {:.1} s of picture", |
| 2222 | 2222 | picture_started.elapsed().as_secs_f64() |
| 2223 | 2223 | ); |
| 2224 | + // ...and the line on screen finished with it. The loop above | |
| 2225 | + // publishes the measured codec the moment the pass lands | |
| 2226 | + // under the picture, but a picture that outran the mix never | |
| 2227 | + // reaches that branch -- and "working out the sound…" would | |
| 2228 | + // then be the last thing the card ever said about a track it | |
| 2229 | + // had long since written. | |
| 2230 | + publish_seats( | |
| 2231 | + shared, | |
| 2232 | + seat, | |
| 2233 | + project, | |
| 2234 | + settings, | |
| 2235 | + track.as_ref().map(|track| track.copied), | |
| 2236 | + track | |
| 2237 | + .as_ref() | |
| 2238 | + .is_some_and(|track| track.opus_pre_skip.is_some()), | |
| 2239 | + false, | |
| 2240 | + ); | |
| 2224 | 2241 | track |
| 2225 | 2242 | } |
| 2226 | 2243 | None => late, |
crates/engine/tests/backends.rsmodified+50 -44
| @@ -123,22 +123,7 @@ fn the_planned_encoders_are_the_ones_the_job_opens() { | ||
| 123 | 123 | ); |
| 124 | 124 | let out = out_path("planned", ext); |
| 125 | 125 | let handle = session.export_to_with(&out, &settings); |
| 126 | - let started = Instant::now(); | |
| 127 | - let opened = loop { | |
| 128 | - if let Some(line) = handle.encoders() { | |
| 129 | - break line; | |
| 130 | - } | |
| 131 | - assert!( | |
| 132 | - !handle.is_finished(), | |
| 133 | - "the export settled before it opened an encoder: {:?}", | |
| 134 | - handle.result().map(|r| r.err()) | |
| 135 | - ); | |
| 136 | - assert!( | |
| 137 | - started.elapsed() < Duration::from_secs(60), | |
| 138 | - "no encoder was published" | |
| 139 | - ); | |
| 140 | - std::thread::sleep(Duration::from_millis(10)); | |
| 141 | - }; | |
| 126 | + let opened = published_encoders(&handle, ext); | |
| 142 | 127 | // Nothing here wants the file, only the seat it was going to be written |
| 143 | 128 | // with: cancelling deletes the `.part` the worker had started. |
| 144 | 129 | handle.cancel(); |
| @@ -201,22 +186,7 @@ fn the_planned_seat_follows_the_size_and_the_pin() { | ||
| 201 | 186 | } |
| 202 | 187 | let out = out_path("seat", ext); |
| 203 | 188 | let handle = session.export_to_with(&out, &settings); |
| 204 | - let started = Instant::now(); | |
| 205 | - let opened = loop { | |
| 206 | - if let Some(line) = handle.encoders() { | |
| 207 | - break line; | |
| 208 | - } | |
| 209 | - assert!( | |
| 210 | - !handle.is_finished(), | |
| 211 | - "{ext} {width}x{height}: settled before an encoder opened: {:?}", | |
| 212 | - handle.result().map(|r| r.err()) | |
| 213 | - ); | |
| 214 | - assert!( | |
| 215 | - started.elapsed() < Duration::from_secs(60), | |
| 216 | - "no encoder was published" | |
| 217 | - ); | |
| 218 | - std::thread::sleep(Duration::from_millis(10)); | |
| 219 | - }; | |
| 189 | + let opened = published_encoders(&handle, &format!("{ext} {width}x{height}")); | |
| 220 | 190 | handle.cancel(); |
| 221 | 191 | wind_down(&handle); |
| 222 | 192 | assert!( |
| @@ -313,28 +283,64 @@ fn a_mixed_timeline_says_it_re_encodes_and_then_does() { | ||
| 313 | 283 | ..ExportSettings::default() |
| 314 | 284 | }, |
| 315 | 285 | ); |
| 286 | + let opened = published_encoders(&handle, "a mixed timeline"); | |
| 287 | + assert!( | |
| 288 | + opened.ends_with(&planned), | |
| 289 | + "{opened} does not end in {planned}" | |
| 290 | + ); | |
| 291 | + // ...and it is the line the job *settles* on, which is why this one runs to | |
| 292 | + // the end instead of cancelling: an mp4 mixes its sound beside the picture, | |
| 293 | + // and a hardware picture is through first, so the measured codec reaches the | |
| 294 | + // line where the pass is collected under the muxer rather than in the frame | |
| 295 | + // loop. A card left saying "working out the sound…" over a written file is | |
| 296 | + // the same lie as one naming a codec that never ran. | |
| 316 | 297 | let started = Instant::now(); |
| 317 | - let opened = loop { | |
| 318 | - if let Some(line) = handle.encoders() { | |
| 319 | - break line; | |
| 298 | + while !handle.is_finished() { | |
| 299 | + assert!( | |
| 300 | + started.elapsed() < Duration::from_secs(300), | |
| 301 | + "the export did not finish in 300 s" | |
| 302 | + ); | |
| 303 | + std::thread::sleep(Duration::from_millis(10)); | |
| 304 | + } | |
| 305 | + handle.result().expect("an outcome").expect("the export"); | |
| 306 | + let settled = handle.encoders().expect("a finished job still names its seats"); | |
| 307 | + assert!( | |
| 308 | + settled.ends_with(&planned), | |
| 309 | + "the export settled on {settled}, which does not end in {planned}" | |
| 310 | + ); | |
| 311 | +} | |
| 312 | + | |
| 313 | +/// The half-line an export shows while its sound is still being mixed on the | |
| 314 | +/// thread beside the picture (`engine::export::publish_seats`). An mp4 job | |
| 315 | +/// overlaps the two passes, so this is what the *first* line out of one says | |
| 316 | +/// about a codec that has not run yet. | |
| 317 | +const MIXING: &str = "working out the sound…"; | |
| 318 | + | |
| 319 | +/// The encoders line a running job settles on: published as soon as the picture | |
| 320 | +/// seat is open, and completed once the sound has been measured. Waiting for the | |
| 321 | +/// second half is what makes this the line a card shows rather than a snapshot | |
| 322 | +/// of an export mid-decision -- and, because a job that ends without ever | |
| 323 | +/// completing it fails here, it is also the pin on that completion happening at | |
| 324 | +/// all, whichever of the two passes finishes first. | |
| 325 | +fn published_encoders(handle: &ExportHandle, what: &str) -> String { | |
| 326 | + let started = Instant::now(); | |
| 327 | + loop { | |
| 328 | + match handle.encoders() { | |
| 329 | + Some(line) if !line.ends_with(MIXING) => return line, | |
| 330 | + _ => {} | |
| 320 | 331 | } |
| 321 | 332 | assert!( |
| 322 | 333 | !handle.is_finished(), |
| 323 | - "the export settled before it opened an encoder: {:?}", | |
| 334 | + "{what}: the export settled without naming its encoders ({:?}): {:?}", | |
| 335 | + handle.encoders(), | |
| 324 | 336 | handle.result().map(|r| r.err()) |
| 325 | 337 | ); |
| 326 | 338 | assert!( |
| 327 | 339 | started.elapsed() < Duration::from_secs(60), |
| 328 | - "no encoder was published" | |
| 340 | + "{what}: no encoder was published" | |
| 329 | 341 | ); |
| 330 | 342 | std::thread::sleep(Duration::from_millis(10)); |
| 331 | - }; | |
| 332 | - handle.cancel(); | |
| 333 | - wind_down(&handle); | |
| 334 | - assert!( | |
| 335 | - opened.ends_with(&planned), | |
| 336 | - "{opened} does not end in {planned}" | |
| 337 | - ); | |
| 343 | + } | |
| 338 | 344 | } |
| 339 | 345 | |
| 340 | 346 | /// Waits for a cancelled job to settle, so its `.part` is gone before the test |