Skip to content

Fix: a click in the shared game sound when packets are dropped after a burst - #128

Merged
AlxcBTW merged 2 commits into
mainfrom
fix/sound-test-peak
Oct 28, 2026
Merged

AlxcBTW merged 2 commits into
mainfrom
fix/sound-test-peak

Conversation

@fma-rc

@fma-rc fma-rc commented Oct 27, 2026 •

Copy link
Copy Markdown
Collaborator

When packets arrive in a burst, the share jitter buffer drops the oldest to keep the delay low. The decoder never saw those packets, so the next one was decoded as if it followed the last one played, and the two stretches of sound were overlapped at the join. On a 440 Hz tone at 0.25 that join peaks at up to 0.389 depending on where it is cut (swept over 11 cut points and 1 to 12 dropped packets): a click about 4 dB above the sound.

The jitter buffer now keeps what its latest pop dropped (take_dropped), and the receiver decodes those packets unheard before what pop answered. Over the same sweep the peak is 0.251, the tone's own.

packets_dropped_after_a_burst_do_not_make_a_click plays a tone, then a burst of 9 to 29 packets: without the change a burst of 11 peaks at 0.29; with it every burst stays under 0.27. a_burst_after_a_stall_does_not_keep_the_delay now also checks which packets come back from take_dropped.

This is the overshoot that made the_streamer_s_sound_is_played_by_the_viewer fail on macOS at 0.38 to 0.39 before #124. Voice chat's jitter buffer drops packets the same way; I have not measured it there.


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

When packets arrive in a burst the jitter buffer drops the oldest to keep the
delay low. The decoder never saw them, so it overlapped two stretches of sound
that were not next to each other: on a 0.25 tone the join peaks at up to 0.389,
a click about 4 dB above the sound.

The jitter buffer now keeps what its latest pop dropped, and the receiver
decodes those packets unheard before what pop answered.

@AlxcBTW AlxcBTW left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is a careful fix, and the way it is measured is the best part: sweeping the cut point and the number of dropped packets, then pinning the result in packets_dropped_after_a_burst_do_not_make_a_click. Decoding the dropped packets unheard so the decoder carries on from where the sound now is makes sense, the order (dropped, oldest first, then what pop answered) is right, out is cleared before the real decode, and take_dropped is empty after being taken, so the voice jitter buffer is not affected (its memory stays bounded because pop clears the list). The skipped == dropped.len() check in the existing test is a good guard.

The failing macOS check is real_window::the_worker_saves_a_clip_of_a_real_window ("no_window"), which is unrelated to sound. It was fixed on main in #127 and #131 after this branch was tested. I will close and reopen the PR so CI runs again against current main, and merge when all checks are green.

Approved.

@AlxcBTW AlxcBTW closed this Oct 27, 2026
@AlxcBTW AlxcBTW reopened this Oct 27, 2026
@AlxcBTW
AlxcBTW merged commit e70df49 into main Oct 28, 2026
18 checks passed
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