"""A/V hold queue: video is delayed to match the audio hop.""" from collections import deque from run_worker import drain_held_frames def test_drain_nothing_until_hold(): q = deque([(0.0, b"a"), (0.05, b"b")]) assert list(drain_held_frames(q, now=0.1, hold_s=0.2)) == [] assert len(q) == 2 def test_drain_ready_frames(): q = deque([(0.0, b"a"), (0.05, b"b"), (0.25, b"c")]) got = list(drain_held_frames(q, now=0.26, hold_s=0.2)) assert got == [b"a", b"b"] assert list(q) == [(0.25, b"c")] def test_no_hold_drains_all(): q = deque([(1.0, b"x")]) assert list(drain_held_frames(q, now=1.0, hold_s=0.0)) == [b"x"] assert not q