working on todo.md features

This commit is contained in:
Martino Ferrari committed 2026-10-10 22:52:12 +02:00
1 parent 210d124814
commit 8f54841c2c
110 files changed
+15932 -6576

No files matched your search

+41
View File
@@ -240,6 +240,18 @@ def main():
"opposite side of zero, so --quiet-at is its last zero crossing: the shape a "
"dropout trigger is read against. -1 = never",
)
ap.add_argument(
"--blackout-at",
type=float,
default=0.0,
help="seconds after start at which the stream goes silent (EMI link loss)",
)
ap.add_argument(
"--blackout",
type=float,
default=0.0,
help="seconds the stream stays silent; must exceed the client's 2 s silence timeout",
)
ap.add_argument(
"--drop-every",
type=int,
@@ -324,6 +336,8 @@ def main():
held = None # (counter, datagram, release_deadline) built but withheld, for --reorder-every
drop_left = 0
dropped = 0
blackout_left = 0.0
blackout_done = False
inverted = 0
noted_drop = False
noted_reorder = False
@@ -357,6 +371,33 @@ def main():
continue
now = time.monotonic()
# An EMI-style link loss: the producer keeps making samples but nothing gets
# through, so the client's silence timeout -- not a polite DISCONNECT -- is
# what ends the session, which is the case recovery has to survive.
if blackout_left > 0.0:
blackout_left -= 0.002 # the loop polls at most every 2 ms
if blackout_left <= 0.0:
print("mock udpstreamer: blackout over, resuming", flush=True)
elif (
args.blackout_at > 0.0
and args.blackout > 0.0
and not blackout_done
and started is not None
and now - started >= args.blackout_at
):
blackout_done = True
blackout_left = args.blackout
print(
f"mock udpstreamer: blackout for {args.blackout} s (link loss)",
flush=True,
)
if blackout_left > 0.0:
# Silent: the producer falls behind the wall clock, and when the link
# returns it resumes from *now* -- the backlog is what the link ate.
next_send = now
time.sleep(0.002)
continue
if now < next_send:
time.sleep(min(next_send - now, 0.002))
continue