From 2355be1cefe3d2ee8d7df1a6e9bf0d3aec2c39ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Laignel?= Date: Mon, 12 Sep 2022 17:39:52 +0200 Subject: [PATCH] ts/jitterbuffer: extra robustness for Windows CI jitterbuffer tests crash on Windows CI sometimes. Activating logs showed time values which are probably not expected in a regular environment, but which can happen there. Adding extra robustness to `next_wakeup` computation seems to fix the problem judging by the few runs I triggered. --- generic/threadshare/src/jitterbuffer/imp.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/generic/threadshare/src/jitterbuffer/imp.rs b/generic/threadshare/src/jitterbuffer/imp.rs index 699f7df5..3499e891 100644 --- a/generic/threadshare/src/jitterbuffer/imp.rs +++ b/generic/threadshare/src/jitterbuffer/imp.rs @@ -872,9 +872,11 @@ impl SrcHandler { return (now, None); } - let next_wakeup = state - .earliest_pts - .map(|earliest_pts| earliest_pts + latency - state.packet_spacing - context_wait / 2); + let next_wakeup = state.earliest_pts.map(|earliest_pts| { + (earliest_pts + latency) + .saturating_sub(state.packet_spacing) + .saturating_sub(context_wait / 2) + }); let delay = next_wakeup .opt_saturating_sub(now)