Repository navigation
Fix: a click in the shared game sound when packets are dropped after a burst - #128
Conversation
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
left a comment
There was a problem hiding this comment.
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.
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
popdropped (take_dropped), and the receiver decodes those packets unheard before whatpopanswered. Over the same sweep the peak is 0.251, the tone's own.packets_dropped_after_a_burst_do_not_make_a_clickplays 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_delaynow also checks which packets come back fromtake_dropped.This is the overshoot that made
the_streamer_s_sound_is_played_by_the_viewerfail 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.Need help on this PR? Tag
@codesmith-botwith what you need.