Repository navigation
Description
Unit
Port the delay decisions of process_audio_delay() in libobs/audio-monitoring/win32/wasapi-output.c.h (45-116) to rust/obs-audio-monitoring, as a new module monitor_delay, next to pulse_monitor. On Windows they decide, for every packet of a monitored source that has video, whether its audio is held back, cut or played to stay in step with the source's video:
- the stale cut (57-59): more than 1 s since the last packet arrived empties the delay buffer, and the receive time is stored;
- the front judgement (75-78, 81, 100): the front packet's timestamp minus the device padding, its difference from the source's last video timestamp, and the verdict: play when there is no video timestamp yet, when they are more than 5 s apart or when the video has stood still past
AUDIO_MONITOR_VIDEO_STALL_NS; otherwise hold the queue when the audio is more than 75 ms ahead (rushing), drop the packet when it is more than 75 ms behind and more are queued (dragging), and play it otherwise.
These stay in C: every deque_* call and da_resize, os_gettime_ns, the reads of last_frame_ts, sync_offset, the sample rate and the stall count where they are today, both util_mul_div64 calls, the "more are queued" test after the pops, the two DEBUG_AUDIO logs, the loop and its returns, and all of on_audio_playback() (the lock, the WASAPI calls, the resample, the volume).
audio_monitor_track_video_ts() (the video stall tracking) stays a static inline in monitor-video-sync.h: the existing tests test_monitor_video_sync and test_media_cover_art_monitor include the header and call it, and they stay unchanged.
Phase and position
Phase 6, Windows host code in the windows+ unity group; the WASAPI counterpart of the PulseAudio monitor steps port (#2470). Tracking: #4.
Dependencies and existing tests
- No dependency; no open PR touches
wasapi-output.c.hor thewindows+group. - Real libobs: the WASAPI monitor runs only on Windows, and no test reaches
process_audio_delay().test_monitor_video_syncandtest_media_cover_art_monitorcover the stall tracking, which this port leaves alone. - No characterization:
test_audio_monitor_delay_stepslands first in the same PR. The moved file includes no Windows header, so it builds and runs on every OS.
Notes
One PR, separate commits: the behaviour-neutral move into libobs/audio-monitoring/monitor-delay.c.h (hidden functions on plain integers, the thresholds as named constants), characterization, RED, GREEN (group libobs.ported-monitor-delay), Tier 3 (grids around every threshold and a proptest over packet runs), docs.
No intentional difference is expected. The C subtracts in uint64_t and casts to int64_t; Rust wraps the same way. llabs(INT64_MIN) is undefined in C, so the parity test leaves out that one difference.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
rdoupe commentedon Oct 30, 2026
Claiming: #3105
Plan, one PR with separate commits:
libobs: Movethe stale cut and the front judgement ofprocess_audio_delay()intolibobs/audio-monitoring/monitor-delay.c.h: hidden functions on plain integers, declared in a newmonitor-delay.hwith the 1 s, 5 s and 75 ms thresholds named; behaviour-neutral, checked by building master's and the moved code side by side over logging stand-ins on the same inputs, with planted mutants.test_audio_monitor_delay_steps, building the moved file on its own (no Windows header), on every OS.obs_audio_monitoring::monitor_delayagainsttodo!()stubs.src/ffi/monitor_delay.rs, grouplibobs.ported-monitor-delayin the Windows ported sources.Decisions:
audio_monitor_track_video_ts()) stays astatic inlineinmonitor-video-sync.h, unported:test_monitor_video_syncandtest_media_cover_art_monitorinclude the header and call it, and existing C tests stay unchanged.util_mul_div64()calls (the packet's and the padding's duration) stay in C at their call sites, so the core takes nanoseconds and never divides. The "more are queued" test also stays in C, after the pops, where it is read today.I expect the draft PR today, within a few hours.
libobs: Move the WASAPI monitor delay decisions
test: Characterize the WASAPI monitor delay
obs-audio-monitoring: Test the monitor delay port
obs-audio-monitoring: Port the monitor delay
obs-audio-monitoring: Compare monitor delay to C
docs: Record the WASAPI monitor delay port
libobs: Move the WASAPI monitor delay decisions
test: Characterize the WASAPI monitor delay
obs-audio-monitoring: Test the monitor delay port
obs-audio-monitoring: Port the monitor delay
obs-audio-monitoring: Compare monitor delay to C
docs: Record the WASAPI monitor delay port
rdoupe commentedon Oct 31, 2026
Fixed by PR #3107, merged through the queue as c717200.
The WASAPI monitor's delay decisions (the 1 s stale cut and the front packet's verdict: hold at 75 ms ahead, drop at 75 ms behind with more queued, play on no video timestamp, 5 s apart or a stalled video) now run from
rust/obs-audio-monitoring(monitor_delay), with no change in behaviour. Tier 3 parity against the C and a 24-mutant check are in.Left, by decision and not as work: the delay queue calls, the two
util_mul_div64()calls, the "more are queued" test, theDEBUG_AUDIOlogs andon_audio_playback()stay in C, and so does the video stall tracking (audio_monitor_track_video_ts()), which existing C tests call. Nothing has run on a Windows machine yet beyond PR CI.Follow-up issue: none; nothing in this unit's scope is left. Its tracking issue (#4) has no checkbox for this unit, so none was ticked.
libobs: Port the WASAPI monitor delay decisions (obs-rust#3107)