The multi-audio layout refusal test pins the width refusal that is left
Browse files at this commit1e84d82d09aefd30b2683955b2452433f7c4b388Parent: ccfe87c- fix
- the multi-audio layout refusal test pins the width refusal that is left
1 changed file +33 -8
crates/engine/tests/audio_multi.rsmodified+33 -8
| @@ -253,17 +253,42 @@ fn the_join_carries_no_second_priming_packet() { | ||
| 253 | 253 | fn a_source_that_disagrees_on_layout_is_refused() { |
| 254 | 254 | // Import refuses these up front (one output device, one *layout*); the copy |
| 255 | 255 | // and the decode paths refuse them again rather than mislabel one esds for |
| 256 | - // two different tracks. Stream 1 of the multi-audio fixture is 22.05 kHz | |
| 257 | - // mono against the timeline's 44.1 kHz stereo -- its rate is conformed at | |
| 258 | - // the decoder's door now, its layout is what is left to refuse. | |
| 259 | - let mixed = [(asset("test_av.mp4"), 0), (asset("test_multiaudio.mp4"), 1)]; | |
| 256 | + // two different tracks. What a *decode* still refuses (c871d71 let a mono | |
| 257 | + // source up-mix, DEBT #46; ceddd4c before it conformed the rate) is a | |
| 258 | + // source **wider** than the timeline -- a stereo source on a mono one is | |
| 259 | + // the same refusal read the other way. Stream 1 of the multi-audio fixture | |
| 260 | + // is the shape that stopped being a refusal: 22.05 kHz mono against a | |
| 261 | + // 44.1 kHz stereo timeline. The decode path widens and resamples it; the | |
| 262 | + // copy path still refuses it, because copied packets can be neither | |
| 263 | + // widened nor resampled and one esds cannot declare two tracks. | |
| 264 | + let mono = [(asset("test_av.mp4"), 0), (asset("test_multiaudio.mp4"), 1)]; | |
| 260 | 265 | let segs = [(Some(0), 0.0, 1.0), (Some(1), 0.0, 1.0)]; |
| 261 | - // (`.err()`, not `unwrap_err`: neither Ok payload is `Debug`.) | |
| 266 | + let msg = AudioSession::copy_multi_streams(&mono, &segs) | |
| 267 | + .err() | |
| 268 | + .expect("copied packets cannot be widened or resampled") | |
| 269 | + .to_string(); | |
| 270 | + assert!(msg.contains("source 1"), "{msg}"); | |
| 271 | + // (`.expect` twice: neither Ok payload is `Debug`.) | |
| 272 | + let (_, rx) = AudioSession::open_multi_streams(&mono, &segs) | |
| 273 | + .expect("a mono source at another rate is conformed, not refused") | |
| 274 | + .expect("the first source has an audio track"); | |
| 275 | + let (samples, _, _) = drain(rx); | |
| 276 | + let frames = samples.len() / CHANNELS; | |
| 277 | + assert!( | |
| 278 | + (frames as i64 - 2 * RATE as i64).unsigned_abs() < PACKET, | |
| 279 | + "{frames} frames for two seconds" | |
| 280 | + ); | |
| 281 | + assert!(samples.iter().any(|s| *s != 0.0), "the widened stream plays"); | |
| 282 | + | |
| 283 | + // The refusal that is left, in both paths, in words that name the source: | |
| 284 | + // stereo onto a timeline whose first source is mono. (`test_audio_only` | |
| 285 | + // is 44.1 kHz *mono* -- no rate in the way, only the width.) | |
| 286 | + let wide = [(asset("test_audio_only.mp4"), 0), (asset("test_av.mp4"), 0)]; | |
| 262 | 287 | for e in [ |
| 263 | - AudioSession::copy_multi_streams(&mixed, &segs).err(), | |
| 264 | - AudioSession::open_multi_streams(&mixed, &segs).err(), | |
| 288 | + AudioSession::copy_multi_streams(&wide, &segs).err(), | |
| 289 | + AudioSession::open_multi_streams(&wide, &segs).err(), | |
| 265 | 290 | ] |
| 266 | - .map(|e| e.expect("a source at another rate must be refused")) | |
| 291 | + .map(|e| e.expect("a source wider than the timeline must be refused")) | |
| 267 | 292 | { |
| 268 | 293 | let msg = e.to_string(); |
| 269 | 294 | assert!(msg.contains("source 1"), "{msg}"); |