Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions crates/os-app/src/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,11 @@ pub fn render(o: &Opts) -> Result<(), String> {
let peak = audio.iter().fold(0.0f32, |m, v| m.max(v.abs()));
eprintln!("RENDERED {:.2} s (song {:.2} s) at {} Hz in {:.1} s, peak {peak:.3}", audio.len() as f64 / 2.0 / rate as f64, len as f64 / rate as f64, o.rate, t1.elapsed().as_secs_f64());
crate::project_io::reset_hosted(&mut ses);
// The instances let go are destroyed now, on this thread, as the window does at exit: left on the retired list
// they were destroyed in the process's exit, after Windows had ended their threads, and a plugin that joins a
// thread of its own in its destructor (Citrus) aborted the process: a render that had written its file exited 127.
drop(ses);
crate::plugins::sweep_retired();
written.map_err(|e| format!("{}: {e}", o.out.display()))
}

Expand Down Expand Up @@ -312,6 +317,9 @@ mod tests {
let file = os_flp::project::create(&p).expect("create");
std::fs::write(&flp, file.to_bytes().expect("bytes")).unwrap();
render(&Opts { hosted: Hosted::Builtin, seconds: Some(1.5), ..Opts::new(flp, out.clone()) }).expect("render");
// Its Lemon Sampler is destroyed before the render returns, not left for the process's exit (where a plugin
// that joins its own thread aborted a finished command-line render).
assert_eq!(crate::plugins::retired_count(), 0, "a render destroys the instances it hosted");

let wav = std::fs::read(&out).unwrap();
let at = wav.windows(4).position(|w| w == b"data").expect("data chunk") + 8;
Expand Down
10 changes: 7 additions & 3 deletions crates/os-session/src/dropout_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -235,11 +235,15 @@ mod tests {
let h = Hold::start();
std::thread::sleep(Duration::from_millis(20));
assert!(h.ran().unwrap() < Duration::from_millis(5), "asleep: {:?}", h.ran());
// Works until it has run 10 ms: a loaded machine (CI) takes the thread off the CPU for part of any fixed span
// (20 ms of work once ran 9.9 ms), so the span is not fixed; a running time that never grows fails at 2 s.
let h = Hold::start();
while h.elapsed() < Duration::from_millis(20) {
std::hint::black_box(0u64);
while h.ran().unwrap() < Duration::from_millis(10) && h.elapsed() < Duration::from_secs(2) {
for _ in 0..1000 {
std::hint::black_box(0u64);
}
}
assert!(h.ran().unwrap() >= Duration::from_millis(10), "working: {:?}", h.ran());
assert!(h.ran().unwrap() >= Duration::from_millis(10), "working: {:?} in {:?}", h.ran(), h.elapsed());
}

#[test]
Expand Down
Loading