forge
Explore
Log in

Don't you dare go Hollow

A setting nobody can hear stops rebuilding the sound

Browse files at this commit

0689e40378d844b160e0a0af921e55bc1dc918dcAhmet Kaan GümüşParent: 64a9817
  • fix
    • a setting nobody can hear stops rebuilding the sound
Show full message
🐛 fix(mix): a setting nobody can hear stops rebuilding the sound

Two ways the mix handle lied about who was listening.

A ceiling dragged while the limiter is **off** was a full audio rebuild per
nudge on the flat single-lane timeline -- a flush, a re-open and a hole in
the sound for a number that changes not one sample, because there was no
mixer to hand it to and rebuilding was the only thing `push_mix` knew. It
now rebuilds only for a setting that actually needs a mixer
(`AudioSession::is_mixed`), and hands everything else nowhere, which is
where it belongs.

And the handle left over from an open that found nothing -- a silent
timeline, a source that would not open -- read as a live mixer forever
after, so a fader moved later was written into a `MixControls` no thread
was reading and never retried. The feeder marks it detached when its open
comes back without a mixer (`MixControls::detach`/`is_reachable`), and a
mix that cannot be reached rebuilds instead.

Guard: 20 ceiling nudges with the limiter off leave the device queue full
and start no worker, beside the existing fader/limiter test.
crates/engine/tests/invalidation.rsmodified+44 -0
@@ -218,6 +218,50 @@ fn a_fader_during_playback_stops_restarting_the_sound() {
218 eprintln!("20 fader nudges and 8 limiter moves: not one restart");218 eprintln!("20 fader nudges and 8 limiter moves: not one restart");
219 }219 }
220 220
221+/// The same rule on the timeline that has **no mixer at all**: one audio lane
222+/// at unity with the limiter off is the bit-exact single-stream path, and a
223+/// ceiling dragged while the limiter is *off* changes not one sample of it.
224+/// That drag used to reopen the sound at every nudge -- there was no mixer to
225+/// hand the number to, so the rebuild was the only way to apply a setting that
226+/// did not apply to anything.
227+///
228+/// The device queue is the oracle, as above; the worker count is the second
229+/// one, because a rebuild is a feeder thread per nudge whether the ear catches
230+/// it or not.
231+#[test]
232+fn a_ceiling_dragged_with_the_limiter_off_rebuilds_nothing() {
233+ let mut session = open(&asset("test_av.mp4"));
234+ let filled = play_until_heard(&mut session);
235+ let workers = session.live_workers();
236+
237+ for step in 1..=20 {
238+ // Off throughout: this is the setting nobody can hear yet. Every step a
239+ // different ceiling, since setting the one already in force is refused
240+ // and would measure nothing.
241+ let limiter = Limiter {
242+ on: false,
243+ ..Limiter::default()
244+ }
245+ .with_ceiling(-1.0 - step as f32 * 0.25);
246+ assert!(session.set_limiter(limiter), "ceiling {step}");
247+ assert_eq!(
248+ heard(&session),
249+ filled,
250+ "nudge {step} emptied the device queue -- a silent setting restarted the stream"
251+ );
252+ assert!(
253+ session.live_workers() <= workers,
254+ "nudge {step} started a worker: {} against {workers} before the drag",
255+ session.live_workers()
256+ );
257+ }
258+
259+ // ...and turning it *on* is the one move that has to open a mixer, which is
260+ // a rebuild and is allowed to be one.
261+ assert!(session.set_limiter(Limiter::default().with_ceiling(-1.0)), "limiter on");
262+ eprintln!("20 ceiling nudges with the limiter off: not one rebuild");
263+}
264+
221 /// The other half of the rule, and the one that makes it a *classification*265 /// The other half of the rule, and the one that makes it a *classification*
222 /// rather than a blanket "never rebuild": an equalizer really is a change to266 /// rather than a blanket "never rebuild": an equalizer really is a change to
223 /// the samples, so it does restart the audio -- and must leave the picture267 /// the samples, so it does restart the audio -- and must leave the picture