Skip to content

fix/pacer and resampler follow ups - #25

Merged
dangusev merged 10 commits into
fix/sender-replace-follow-upsfrom
fix/pacer-and-resampler-follow-ups
Oct 13, 2026
Merged

dangusev merged 10 commits into
fix/sender-replace-follow-upsfrom
fix/pacer-and-resampler-follow-ups

Conversation

@dangusev

Copy link
Copy Markdown
Collaborator

Stack created with GitHub Stacks CLI • Give Feedback 💬

@dangusev
dangusev added this pull request to stack #31 October 13, 2026 14:22
@dangusev
dangusev force-pushed the fix/pacer-and-resampler-follow-ups branch from 3e61d8c to 78e8818 Compare October 13, 2026 14:54
@dangusev
dangusev force-pushed the fix/pacer-and-resampler-follow-ups branch from 3e61d8c to 78e8818 Compare October 13, 2026 14:54
The sinc filter blocked a runtime worker for about 130 ms for a 30 s write at 24 kHz, and the pacer waited on the resampler lock for that time. write_pcm now resamples in spawn_blocking, as write_i420 does for video. take_pcm uses try_lock, so the pacer does not wait for a write and takes no resampler audio during it.
The pacer flushed the resampler at each tick with less than one frame in the queue, also between the writes of a continuous stream. The first tick after the first write always found a short queue. Each flush made the next write start with 128 input frames of silence, an 11 ms gap at 16 kHz. take_pcm now flushes only when no write_pcm came since the last tick, so the end of an utterance still plays.
write_pcm started the pacer with start_pacing, which also enabled pacing, so an earlier pause_pacing was lost. pacing_enabled now starts as the pace setting, and write_pcm only starts the pacer task. The user pause (pacing_enabled) and the publication hold (held) stay separate.
With pace on, the first write_pcm started the pacer, and its first tick came at once. Before Call::publish_audio, the track had no sender, so the pacer sent the audio nowhere (webrtc-rs returns Ok(0)). The publication hold started too late to keep it. write_pcm now starts the pacer only when a negotiated PeerConnection can send the track.
A new track on a kept sender continued from the timestamp that the stopped track had at the stop, and a paused or held pacer did not advance the clock. The RTCP sender reports advance with the wall clock, so the next packet and the reports disagreed. continue_rtp_from now adds the time since the stop, for audio and video, and a paused or held tick advances the clock by 20 ms, as a muted tick does.
@dangusev
dangusev force-pushed the fix/pacer-and-resampler-follow-ups branch from 78e8818 to d4ceaba Compare October 13, 2026 15:02
@dangusev
dangusev merged commit 0521bf7 into main Oct 13, 2026
6 of 11 checks passed
@dangusev
dangusev deleted the fix/pacer-and-resampler-follow-ups branch October 13, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants