Repository navigation
fix(libobs): own-clock audio from a fast sender no longer builds up delay (#4143) - #4202
Merged
Merged
Conversation
…lay (RED) #4143: since #4049, audio on a clock of its own is placed at its own timestamps plus an offset that only the first packet sets. A sender whose audio clock runs faster than the system clock delivers more audio than the mix plays, and the delay between a packet's arrival and its playout grows without a limit (about 0.18 s per hour at 50 ppm). The new case sends the own-clock source's packets 1.10 times as fast as real time, stamped by their samples, with every 10th packet silent as a marker, and measures how long after its packet was sent each marker starts in the program audio. It expects every delay under 200 ms. The existing cases keep rate 1 and no markers, so they run as before. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…REEN) #4143: own_clock_timing_adjust, set by the first packet on a clock of its own, is moved by nothing else: a continuous packet never takes under_lock's MAX_TS_VAR reset, and a fast sender's audio is never late, so the discard path never runs. A sender clock faster than the system clock then places its audio later and later after its arrival. When a packet on its own clock would be placed more than TS_SMOOTHING_THRESHOLD (70 ms) after its arrival, its timing is taken again from its arrival, as the first packet's is. under_lock then sees a jump of more than the smoothing threshold and places the packet by its timestamp. In C (obs-source-audio-output.c.h, also the C reference and the oracle) and in Rust (obs_source::audio_output). Co-Authored-By: Claude Opus 5.5 <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
vpacher
enabled auto-merge
November 9, 2026 08:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #4143. The smooth correction (no steps) is #4182.
Problem
Since #4049, audio on a clock of its own is placed at its own timestamps plus an offset that only the first packet sets. A sender whose audio clock runs faster than the system clock delivers more audio than the mix plays, and the delay between a packet's arrival and its playout grows without a limit: about 0.18 s per hour at 50 ppm. Before #4049 it stayed at 0.
Change
When a packet on its own clock would be placed more than
TS_SMOOTHING_THRESHOLD(70 ms) after its arrival,own_clock_timing_adjustis taken again from its arrival, as the first packet's is.under_lockthen sees a jump of more than the smoothing threshold and places the packet by its timestamp. In C (obs-source-audio-output.c.h: hybrid's C reference and the oracle) and in Rust (obs_source::audio_output).Side effect, measured: each step overwrites the ~60 ms of audio already buffered past the new position, a short skip. At 50 ppm that is once every 23 minutes. #4182 replaces the steps with resampler compensation.
Tests
test_async_audio_own_clock, new casefast_sender_clock_does_not_build_up_delay: a sender clock 1.10 times the system clock, a silent marker packet every 10th, the delay from each marker's send to its start in the program audio must stay under 200 ms. C reference:marker delays (ms): 218 309 400 490 581 672 763 854 945→ FAILED. The four existing cases keep rate 1 and no markers and pass unchanged.rust/obs-source/tests/source/audio_output.rs:a_continuous_packet_far_ahead_on_another_clock_takes_its_timing_againFAILED;a_continuous_packet_at_the_threshold_on_another_clock_keeps_its_timing(the boundary) passes.test_async_audio_own_clock3 more times in each mode, all passed. The new case:marker delays (ms): 0 18 36 54 0 18 36 54 0 18 36(11 sent, 11 heard).audio_outputtests pass.source_seam::audio_output_parity10/10 (the oracle includes the C file, so it carries the change)../lintpasses.RESOURCE_LOCK timing. No new Rust test threads; the two Tier 1 cases run in under 1 ms.Stimulus simulation (not in this PR)
A local harness played the 135 s audio-check stimulus through the same own-clock test source at a sender clock 1.01 times the system clock (hybrid build, program audio from
obs_add_raw_audio_callback):I did not run the stimulus on master; the tone probe in #4143 shows master without steps but with a delay that grows by the clock difference (+2.2 s in 24 s at 1.10).
🤖 Generated with Claude Code