From 60907470b0fcc334ff4454102ff1d901f9596950 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 12:29:15 -0800 Subject: [PATCH 1/4] chore(quest): claim quest/m1/push-to-talk-resume-latency.md Quest-Claim: df0fcff3b3ab909f From ad6da04fb2b1edc0a6d3682967f8c61378e0dd0f Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 12:34:28 -0800 Subject: [PATCH 2/4] fix(mux): back-to-back segments continue the old schedule Co-Authored-By: Claude Opus 5.5 --- rs/moq-mux/src/sync.rs | 77 ++++++++++++++++--- .../clients/js/ptt-analyze.test.ts | 18 ++++- test/audio-quality/clients/js/ptt-analyze.ts | 18 ++++- 3 files changed, 99 insertions(+), 14 deletions(-) diff --git a/rs/moq-mux/src/sync.rs b/rs/moq-mux/src/sync.rs index 48c5de29969..7e10147521f 100644 --- a/rs/moq-mux/src/sync.rs +++ b/rs/moq-mux/src/sync.rs @@ -573,7 +573,7 @@ impl Resume<'_> { if let Some(mapping) = state.transition(self.transition).and_then(|pending| pending.mapping) { return Poll::Ready(Ok(mapping)); } - let end = state + let tail = state .ends .iter() .flatten() @@ -581,7 +581,7 @@ impl Resume<'_> { .filter_map(|boundary| state.due(media(boundary.end))) .chain(state.tails.iter().copied()) .max(); - if let Some(end) = end.filter(|end| *end > now) { + if let Some(end) = tail.filter(|end| *end > now) { let timer = self.timer.get_or_insert_with(|| kio::clock::sleep_until(end)); if timer.deadline() != end { timer.reset(end); @@ -592,7 +592,7 @@ impl Resume<'_> { let own = self.track.role as usize; // A transition abandoned under this resume, by a gap the caller rechecks, // maps alone like one no peer joined. - let (mapping, paired) = state.transition(self.transition).map_or((None, None), |pending| { + let (mapping, paired, own_plan) = state.transition(self.transition).map_or((None, None, None), |pending| { let mut plans = pending .members .iter() @@ -608,7 +608,7 @@ impl Resume<'_> { })) }) .flatten(); - (pending.mapping, origin.filter(|_| joined)) + (pending.mapping, origin.filter(|_| joined), pending.plans[own]) }); // The peer already resumed this transition. if let Some(mapping) = mapping { @@ -618,11 +618,24 @@ impl Resume<'_> { // origin, keeping the media offsets between them, even when its delay // differs from the others'. Otherwise this role maps alone and a peer // joining later follows it. - let (source, delay) = match paired { - Some(origin) => (origin.source, origin.delay), - None => (Duration::from(self.source), self.delay.unwrap_or(state.delay())), + let (source, delay, arrived) = match paired { + Some(origin) => (origin.source, origin.delay, Some(origin.arrived)), + None => ( + Duration::from(self.source), + self.delay.unwrap_or(state.delay()), + own_plan.map(|plan| plan.arrived), + ), + }; + // Media that arrived before the old tail ended continues its schedule: + // it starts one delay after arriving, or as the tail ends if later, so + // back-to-back segments add no hold. Only after a real gap, where the + // sink underruns anyway, does it re-buffer one delay from now. + let starts = match (tail, arrived) { + (Some(end), Some(arrived)) if arrived <= end => { + arrived.checked_add(delay).ok_or(Error::DelayOverflow)?.max(end) + } + _ => now.checked_add(delay).ok_or(Error::DelayOverflow)?, }; - let starts = now.checked_add(delay).ok_or(Error::DelayOverflow)?; let mapping = Mapping { source, target: state.position(starts).unwrap_or(source), @@ -1110,6 +1123,43 @@ mod tests { assert_eq!(clock.state.lock().unwrap().due(next), now.checked_add(DELAY)); } + /// A press arriving while the previous one still plays continues its + /// schedule, so back-to-back presses add no delay; one after a gap + /// re-buffers one delay. + #[tokio::test] + async fn back_to_back_segments_keep_their_delay() { + tokio::time::pause(); + let start = kio::clock::now(); + let clock = Arc::new(Clock::new(DELAY)); + let audio = Track::new(clock.clone(), Kind::Audio); + audio.received(ms(0), start); + for press in 1..=5u64 { + // Each press lasts 1 s, and the next arrives as it ends. + let transition = audio.declare(); + audio.end(ms(1_000)).unwrap(); + tokio::time::advance(start.saturating_add(Duration::from_secs(press)) - kio::clock::now()).await; + let arrived = kio::clock::now(); + audio.plan(transition, ms(0), Some(DELAY)); + let mapping = audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(); + audio.apply(transition, mapping); + assert_eq!( + clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), + arrived.checked_add(DELAY), + "press {press} drifted" + ); + } + + // After a gap, the tail has drained: it re-buffers one delay from now. + let transition = audio.declare(); + audio.end(ms(1_000)).unwrap(); + tokio::time::advance(Duration::from_secs(5)).await; + let arrived = kio::clock::now(); + audio.plan(transition, ms(0), Some(DELAY)); + let mapping = audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(); + audio.apply(transition, mapping); + assert_eq!(clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), arrived.checked_add(DELAY)); + } + #[tokio::test] async fn a_late_paired_replacement_keeps_its_media_offset() { tokio::time::pause(); @@ -1219,8 +1269,9 @@ mod tests { audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(), ); video.apply(next, video.resume(next, ms(5_000), None).ready().await.unwrap()); - // The later replacement maps onto the running clock, not the audio restart's. - let resumed = kio::clock::now().saturating_add(DELAY); + // The later replacement maps onto the running clock, not the audio + // restart's, continuing as the tail ends since it arrived before then. + let resumed = kio::clock::now(); assert_eq!( clock.state.lock().unwrap().due(video.map(ms(5_000)).unwrap()), Some(resumed) @@ -1244,7 +1295,8 @@ mod tests { transition, video.resume(transition, ms(40), None).ready().await.unwrap(), ); - let resumed = kio::clock::now().saturating_add(DELAY); + // Video arrived before the tail ended, so it continues as the tail ends. + let resumed = kio::clock::now(); assert_eq!( clock.state.lock().unwrap().due(video.map(ms(40)).unwrap()), Some(resumed) @@ -1392,7 +1444,8 @@ mod tests { ); assert_eq!( clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), - Some(now.saturating_add(Duration::from_millis(200))) + // The pair arrived before the tail ended, so it continues as the tail ends. + Some(now.saturating_add(Duration::from_millis(120))) ); } } diff --git a/test/audio-quality/clients/js/ptt-analyze.test.ts b/test/audio-quality/clients/js/ptt-analyze.test.ts index 6291b469052..6e30bca5e62 100644 --- a/test/audio-quality/clients/js/ptt-analyze.test.ts +++ b/test/audio-quality/clients/js/ptt-analyze.test.ts @@ -79,6 +79,7 @@ function nativeTrace(result: ReturnType) { at, render: at - 500, stalled: false, + delay: 250, comfort: mutes.reduce((sum, [from, to]) => sum + Math.min(Math.max(page - from, 0), to - from), 0), utterances: heads.filter((head) => head.at <= at && head.at > at - 250), }); @@ -210,7 +211,7 @@ test("the native listener's results sit beside each press", async () => { expect(exitCode).toBe(0); expect(summary.native.offset).toBe(NATIVE + 2); expect(summary.native.playback).toEqual({ underruns: 0, stalls: 0 }); - expect(summary.presses[0].native).toEqual({ head: true, comfort: null }); + expect(summary.presses[0].native).toEqual({ head: true, lag: NATIVE + 2, comfort: null }); // A separated press's mute, less the 300 ms its previous utterance still played, give or take a // sample on each side. const comfort = summary.presses[8].native.comfort; @@ -228,6 +229,21 @@ test("a native utterance resumed past its head fails the run", async () => { expect(stderr).toContain("native: an utterance did not resume on its head"); }); +test("back-to-back native resumes that each re-buffer a playout delay fail the run", async () => { + const result = trace(); + const native = nativeTrace(result); + // Each back-to-back press resumes one delay later than the one before it. + native + .flatMap((sample) => sample.utterances ?? []) + .slice(1, 8) + .forEach((utterance, i) => { + utterance.at += 250 * (i + 1); + }); + const { exitCode, stderr } = await analyze(result, native); + expect(exitCode).toBe(1); + expect(stderr).toContain("native: back-to-back press 2, 3, 4, 5, 6, 7, 8 added a playout delay"); +}); + test("a native mute without comfort noise fails the run", async () => { const result = trace(); const native = nativeTrace(result); diff --git a/test/audio-quality/clients/js/ptt-analyze.ts b/test/audio-quality/clients/js/ptt-analyze.ts index ec84bc00cfc..3c9723f465d 100644 --- a/test/audio-quality/clients/js/ptt-analyze.ts +++ b/test/audio-quality/clients/js/ptt-analyze.ts @@ -127,7 +127,12 @@ const presses = result.presses path, // The native listener: whether it resumed on this utterance's head, and how much comfort // noise it played in the mute before it, filled in below once its clock is placed. - native: { head: resumed !== undefined, comfort: null as number | null }, + // `lag` is its head's write-to-resume time, which includes the clocks' fixed offset. + native: { + head: resumed !== undefined, + lag: resumed && written ? resumed.at - written.at : null, + comfort: null as number | null, + }, }; }); const summarize = (values: (number | null)[]) => { @@ -227,6 +232,17 @@ if (presses.some((press) => !press.native.head)) failures.push("native: an utter if (presses.some((press, i) => i >= 8 && !press.native.comfort)) failures.push("native: a mute played no comfort noise"); if (start === undefined || !windowed.length) failures.push("native: no playback from the first press"); +// Presses 1-8 follow each other with no gap, so each must continue the previous one's schedule. A +// resume that re-buffers adds one playout delay to the lag, and repeated ones compound. +const nativeDelay = summarize(native.map((sample) => sample.delay ?? null))?.median; +const rebuffered = presses.slice(1, 8).filter((press, i) => { + const before = presses[i].native.lag; + const lag = press.native.lag; + return nativeDelay === undefined || before === null || lag === null || lag - before >= nativeDelay; +}); +if (rebuffered.length) { + failures.push(`native: back-to-back press ${rebuffered.map((press) => press.press).join(", ")} added a playout delay`); +} if (failures.length) { console.error(failures.join("; ")); process.exitCode = 1; From a762c4636c8dba58f6cb481841ad6e2dc2c90d17 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 13:00:21 -0800 Subject: [PATCH 3/4] fix(mux): resume one delay before the tail ends so the sink plays it as the tail ends Co-Authored-By: Claude Opus 5.5 --- quest/m1/push-to-talk-resume-latency.md | 17 ---------- rs/moq-cli/src/play/video.rs | 11 +++++-- rs/moq-mux/src/sync.rs | 31 ++++++++++++------- .../clients/js/ptt-analyze.test.ts | 2 +- test/audio-quality/clients/js/ptt-analyze.ts | 15 ++++----- 5 files changed, 36 insertions(+), 40 deletions(-) delete mode 100644 quest/m1/push-to-talk-resume-latency.md diff --git a/quest/m1/push-to-talk-resume-latency.md b/quest/m1/push-to-talk-resume-latency.md deleted file mode 100644 index 05bc2eea45e..00000000000 --- a/quest/m1/push-to-talk-resume-latency.md +++ /dev/null @@ -1,17 +0,0 @@ -# [S] Back-to-back push-to-talk presses keep their latency - -## Goal - -A press that starts while the previous press is still playing continues on the old schedule, so `just test push-to-talk`'s delay stays flat across back-to-back presses instead of growing by about 250 ms per press. - -## Plan - -Today each resume in `rs/moq-mux/src/sync.rs` (`Track::plan`/`resume`) starts one delay after the old tail drains, even when no gap separates the presses. The added hold (`held`) only shrinks at an eviction or a long mute. - -Recommendation: when the new segment's first media is due no later than the old tail ends, plus one frame, map it onto the old schedule with no added hold. Re-buffer one delay only after a real gap, where the sink would underrun anyway. Mirror the same rule in `js/watch` if its audio sync has the same resume. Make `just test push-to-talk` fail when the delay grows across back-to-back presses. - -Public API: none expected. Wire: none. - -## Related - -- [Gapless audio switch](/quest/m3/gapless-audio-switch.md) - the same schedule continuity across a track change diff --git a/rs/moq-cli/src/play/video.rs b/rs/moq-cli/src/play/video.rs index 2fa4ac56271..b989498c012 100644 --- a/rs/moq-cli/src/play/video.rs +++ b/rs/moq-cli/src/play/video.rs @@ -1377,7 +1377,11 @@ mod tests { .ready() .await .unwrap(); - assert!(Instant::now() >= last, "audio resumed over the video tail"); + // It maps one delay early, so its first write plays as the tail ends. + assert!( + Instant::now() >= last.checked_sub(delay).unwrap(), + "audio resumed over the video tail" + ); } #[tokio::test] @@ -1606,8 +1610,11 @@ mod tests { track, moq_mux::catalog::hang::Container::Legacy(moq_mux::container::Kind::Video), ); + // The old segment declares its last picture's duration, so its end follows that picture. for ms in [0, 33, 66] { - producer.write(frame(ms, ms == 0)).unwrap(); + let mut frame = frame(ms, ms == 0); + frame.duration = Some(moq_net::Timestamp::from_millis(33).unwrap()); + producer.write(frame).unwrap(); } producer.discontinuity().unwrap(); for ms in [100, 133, 166] { diff --git a/rs/moq-mux/src/sync.rs b/rs/moq-mux/src/sync.rs index 7e10147521f..61ec76067b6 100644 --- a/rs/moq-mux/src/sync.rs +++ b/rs/moq-mux/src/sync.rs @@ -516,7 +516,7 @@ impl Track { self.clock.wake(); } - /// Prepare a mapping after the old media drains; dropping the wait leaves the track unchanged. + /// Prepare a mapping one delay before the old media drains; dropping the wait leaves the track unchanged. pub fn resume(&self, transition: Transition, source: Timestamp, delay: Option) -> Resume<'_> { Resume { track: self, @@ -564,7 +564,7 @@ pub struct Resume<'a> { } impl Resume<'_> { - /// The replacement's mapping, once all declared old media has drained. + /// The replacement's mapping, once all declared old media is due to drain within one delay. #[cfg_attr(feature = "async", kio::wrapper)] pub fn poll_ready(&mut self, waiter: &kio::Waiter) -> Poll> { let _ = self.track.clock.changed.poll(waiter, |_| Poll::Pending); @@ -581,10 +581,15 @@ impl Resume<'_> { .filter_map(|boundary| state.due(media(boundary.end))) .chain(state.tails.iter().copied()) .max(); - if let Some(end) = tail.filter(|end| *end > now) { - let timer = self.timer.get_or_insert_with(|| kio::clock::sleep_until(end)); - if timer.deadline() != end { - timer.reset(end); + // Wake one delay before the tail ends: media written then plays as it ends. + let lead = self.delay.unwrap_or(state.delay()); + if let Some(wake) = tail + .map(|end| end.checked_sub(lead).unwrap_or(now)) + .filter(|wake| *wake > now) + { + let timer = self.timer.get_or_insert_with(|| kio::clock::sleep_until(wake)); + if timer.deadline() != wake { + timer.reset(wake); } std::task::ready!(waiter.poll_future(Pin::new(timer))); } @@ -1087,8 +1092,8 @@ mod tests { let mapping = audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(); audio.apply(transition, mapping); assert!( - kio::clock::now() >= start.saturating_add(DELAY * 2), - "the replacement waited for the tail" + kio::clock::now() >= start.saturating_add(DELAY), + "the replacement waited until one delay before the tail ends" ); let unchanged = clock.state.lock().unwrap().due(ms(10_500)); for frame in 0..10 { @@ -1157,7 +1162,10 @@ mod tests { audio.plan(transition, ms(0), Some(DELAY)); let mapping = audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(); audio.apply(transition, mapping); - assert_eq!(clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), arrived.checked_add(DELAY)); + assert_eq!( + clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), + arrived.checked_add(DELAY) + ); } #[tokio::test] @@ -1363,8 +1371,9 @@ mod tests { let transition = video.declare(); video.end(ms(10_000)).unwrap(); video.plan(transition, ms(0), None); + // It may map one delay before the tail ends, so its media plays as the tail ends. let resume = kio::clock::timeout( - DELAY + Duration::from_millis(150), + Duration::from_millis(150), video.resume(transition, ms(0), None).ready(), ) .await; @@ -1407,7 +1416,7 @@ mod tests { let transition = video.declare(); video.plan(transition, ms(0), None); let resume = kio::clock::timeout( - Duration::from_millis(250), + Duration::from_millis(150), video.resume(transition, ms(0), None).ready(), ) .await; diff --git a/test/audio-quality/clients/js/ptt-analyze.test.ts b/test/audio-quality/clients/js/ptt-analyze.test.ts index 6e30bca5e62..aeef1b289b3 100644 --- a/test/audio-quality/clients/js/ptt-analyze.test.ts +++ b/test/audio-quality/clients/js/ptt-analyze.test.ts @@ -241,7 +241,7 @@ test("back-to-back native resumes that each re-buffer a playout delay fail the r }); const { exitCode, stderr } = await analyze(result, native); expect(exitCode).toBe(1); - expect(stderr).toContain("native: back-to-back press 2, 3, 4, 5, 6, 7, 8 added a playout delay"); + expect(stderr).toContain("native: back-to-back presses grew the latency by a playout delay"); }); test("a native mute without comfort noise fails the run", async () => { diff --git a/test/audio-quality/clients/js/ptt-analyze.ts b/test/audio-quality/clients/js/ptt-analyze.ts index 3c9723f465d..5a96d2ab6e6 100644 --- a/test/audio-quality/clients/js/ptt-analyze.ts +++ b/test/audio-quality/clients/js/ptt-analyze.ts @@ -232,16 +232,13 @@ if (presses.some((press) => !press.native.head)) failures.push("native: an utter if (presses.some((press, i) => i >= 8 && !press.native.comfort)) failures.push("native: a mute played no comfort noise"); if (start === undefined || !windowed.length) failures.push("native: no playback from the first press"); -// Presses 1-8 follow each other with no gap, so each must continue the previous one's schedule. A -// resume that re-buffers adds one playout delay to the lag, and repeated ones compound. +// Presses 2-8 each follow the one before with no gap, so they share one schedule. A resume that +// re-buffers adds up to a playout delay to its head's lag, and repeated ones compound, so the run +// must end within one delay of where it started. const nativeDelay = summarize(native.map((sample) => sample.delay ?? null))?.median; -const rebuffered = presses.slice(1, 8).filter((press, i) => { - const before = presses[i].native.lag; - const lag = press.native.lag; - return nativeDelay === undefined || before === null || lag === null || lag - before >= nativeDelay; -}); -if (rebuffered.length) { - failures.push(`native: back-to-back press ${rebuffered.map((press) => press.press).join(", ")} added a playout delay`); +const [firstLag, lastLag] = [presses[1].native.lag, presses[7].native.lag]; +if (nativeDelay === undefined || firstLag === null || lastLag === null || lastLag - firstLag >= nativeDelay) { + failures.push("native: back-to-back presses grew the latency by a playout delay"); } if (failures.length) { console.error(failures.join("; ")); From 8451d590ac34ec7e96cc8e51a33c82eec4d61acb Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Thu, 12 Nov 2026 13:26:00 -0800 Subject: [PATCH 4/4] fix(mux): a continuing segment starts one tick past a durationless tail Co-Authored-By: Claude Opus 5.5 --- rs/moq-cli/src/play/video.rs | 14 ++++++-------- rs/moq-mux/src/sync.rs | 17 ++++++++++++----- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/rs/moq-cli/src/play/video.rs b/rs/moq-cli/src/play/video.rs index b989498c012..aab4c036253 100644 --- a/rs/moq-cli/src/play/video.rs +++ b/rs/moq-cli/src/play/video.rs @@ -1610,11 +1610,9 @@ mod tests { track, moq_mux::catalog::hang::Container::Legacy(moq_mux::container::Kind::Video), ); - // The old segment declares its last picture's duration, so its end follows that picture. + // No durations: the declared end is the last picture's own timestamp. for ms in [0, 33, 66] { - let mut frame = frame(ms, ms == 0); - frame.duration = Some(moq_net::Timestamp::from_millis(33).unwrap()); - producer.write(frame).unwrap(); + producer.write(frame(ms, ms == 0)).unwrap(); } producer.discontinuity().unwrap(); for ms in [100, 133, 166] { @@ -1632,16 +1630,16 @@ mod tests { for _ in 0..1_000 { tokio::task::yield_now().await; if let Some(timestamp) = media.output.present(&media) { - shown.push(timestamp.as_millis()); + shown.push(timestamp.as_micros()); } tokio::time::advance(Duration::from_millis(1)).await; } task.await.unwrap().unwrap(); - assert_eq!(&shown[..3], [0, 33, 66]); + assert_eq!(&shown[..3], [0, 33_000, 66_000]); assert_eq!(shown.len(), 6); assert!(shown[3] > shown[2], "the resumed segment follows every old picture"); - assert_eq!(shown[4] - shown[3], 33); - assert_eq!(shown[5] - shown[4], 33); + assert_eq!(shown[4] - shown[3], 33_000); + assert_eq!(shown[5] - shown[4], 33_000); assert_eq!( *flushed.lock().unwrap(), 2, diff --git a/rs/moq-mux/src/sync.rs b/rs/moq-mux/src/sync.rs index 61ec76067b6..6d25f569958 100644 --- a/rs/moq-mux/src/sync.rs +++ b/rs/moq-mux/src/sync.rs @@ -637,7 +637,11 @@ impl Resume<'_> { // sink underruns anyway, does it re-buffer one delay from now. let starts = match (tail, arrived) { (Some(end), Some(arrived)) if arrived <= end => { - arrived.checked_add(delay).ok_or(Error::DelayOverflow)?.max(end) + // One tick past the end: a tail whose last frame declared no + // duration ends at that frame's timestamp, which the first new + // frame must not share. + let after = end.checked_add(Duration::from_micros(1)).ok_or(Error::DelayOverflow)?; + arrived.checked_add(delay).ok_or(Error::DelayOverflow)?.max(after) } _ => now.checked_add(delay).ok_or(Error::DelayOverflow)?, }; @@ -771,6 +775,8 @@ mod tests { use super::*; const DELAY: Duration = Duration::from_millis(100); + /// How far past the tail's end a continuing segment starts. + const TICK: Duration = Duration::from_micros(1); fn ms(millis: u64) -> Timestamp { Timestamp::from_millis(millis).unwrap() @@ -1147,9 +1153,10 @@ mod tests { audio.plan(transition, ms(0), Some(DELAY)); let mapping = audio.resume(transition, ms(0), Some(DELAY)).ready().await.unwrap(); audio.apply(transition, mapping); + // Each press starts one tick past the tail it touches. assert_eq!( clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), - arrived.checked_add(DELAY), + arrived.checked_add(DELAY + TICK * press as u32), "press {press} drifted" ); } @@ -1279,7 +1286,7 @@ mod tests { video.apply(next, video.resume(next, ms(5_000), None).ready().await.unwrap()); // The later replacement maps onto the running clock, not the audio // restart's, continuing as the tail ends since it arrived before then. - let resumed = kio::clock::now(); + let resumed = kio::clock::now().saturating_add(TICK); assert_eq!( clock.state.lock().unwrap().due(video.map(ms(5_000)).unwrap()), Some(resumed) @@ -1304,7 +1311,7 @@ mod tests { video.resume(transition, ms(40), None).ready().await.unwrap(), ); // Video arrived before the tail ended, so it continues as the tail ends. - let resumed = kio::clock::now(); + let resumed = kio::clock::now().saturating_add(TICK); assert_eq!( clock.state.lock().unwrap().due(video.map(ms(40)).unwrap()), Some(resumed) @@ -1454,7 +1461,7 @@ mod tests { assert_eq!( clock.state.lock().unwrap().due(audio.map(ms(0)).unwrap()), // The pair arrived before the tail ended, so it continues as the tail ends. - Some(now.saturating_add(Duration::from_millis(120))) + Some(now.saturating_add(Duration::from_millis(120) + TICK)) ); } }