fix voice packet timing drift causing periodic audio hiccups#457
Open
coderobe wants to merge 1 commit into
Open
fix voice packet timing drift causing periodic audio hiccups#457coderobe wants to merge 1 commit into
coderobe wants to merge 1 commit into
Conversation
The send loop was rebasing its timer on the actual clock time after send_audio completed, so encryption and UDP latency accumulated into the inter-packet interval. RTP timestamps still incremented by exactly 20ms per packet, meaning Discord's jitter buffer would gradually drain and produce a periodic glitch. Switch to a fixed schedule (next_packet_at += IDEAL_LENGTH) so any per-packet send latency is absorbed by the next frame's sleep rather than compounding. Also rebase the schedule on resume after a pause to avoid bursting buffered frames. While here: fix `options: null` (NameError) → `options: ''` in ffmpeg_command, remove a dead clock_gettime call, and mark the now-noop adjust_interval/adjust_offset/adjust_average/length_override attrs as deprecated
Author
|
without this change, any audio longer than a brief sound effect seems to repeatedly hiccup in semi-regular intervals. tested cherry-picked on top of #453 |
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.
Summary
the send loop was rebasing its timer on the actual clock time after send_audio completed, so encryption and UDP latency accumulated into the inter-packet interval. RTP timestamps still incremented by exactly 20ms per packet, meaning Discord's jitter buffer would gradually drain and produce a periodic audio glitch when playing longer audio files
this switches to a fixed schedule (next_packet_at += IDEAL_LENGTH) so any per-packet send latency is absorbed by the next frame's sleep rather than compounding. Also rebase the schedule on resume after a pause to avoid bursting buffered frames.
While here: fixed
options: null(NameError) ->options: ''in ffmpeg_command, removed a dead clock_gettime call, and marked the now-noop adjust_interval/adjust_offset/adjust_average/length_override attrs as deprecatedChanged
Discordrb::Voicevoice_bot.rb, encoder.rbDeprecated
Discordrb::Voice#adjust_intervalDiscordrb::Voice#adjust_offsetDiscordrb::Voice#adjust_averageDiscordrb::Voice#length_overrideFixed
Discordrb::Voice: voice_bot audio playback stutter