Repository navigation
fix(audio): bound the audio queue by duration instead of packet count - #45
Open
code-new-bie wants to merge 1 commit into
Open
code-new-bie wants to merge 1 commit into
code-new-bie wants to merge 1 commit into
Conversation
Each audio renderer creates its codec and AudioTrack before it reads its queue, and that took about 1.2 s on a BYD head unit. The queue held 64 packets and dropped the newest when full. A wired LPCM packet holds about 7 ms of audio, so 64 packets covered under half a second and the rest of the start-up audio was dropped: the beginning of every wired stream was cut. The queue is now bounded by the audio it holds, 2 s, as jitter buffers such as GStreamer's rtpjitterbuffer and WebRTC's NetEq are. When it is over budget the oldest audio goes, so a stalled output catches up on the newest audio and latency stays bounded. Packet durations come from the codec: LPCM from the payload size, AAC-LC as 1024 frames, Opus from the TOC byte (RFC 6716, section 3.1). Items without a duration are never dropped, and a cap of 2048 items guards against packets that report none. AudioPacketQueueTest covers wired start-up audio fitting without drops, AAC, dropping the oldest audio, a blocking take and the per-codec durations.
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.
Each audio renderer creates its codec and AudioTrack before it reads its
queue, and that took about 1.2 s on a BYD head unit. The queue held 64
packets and dropped the newest when full. A wired LPCM packet holds about
7 ms of audio, so 64 packets covered under half a second and the rest of the
start-up audio was dropped: the beginning of every wired stream was cut.
The queue is now bounded by the audio it holds, 2 s, as jitter buffers such
as GStreamer's rtpjitterbuffer and WebRTC's NetEq are. When it is over budget
the oldest audio goes, so a stalled output catches up on the newest audio and
latency stays bounded. Packet durations come from the codec: LPCM from the
payload size, AAC-LC as 1024 frames, Opus from the TOC byte (RFC 6716,
section 3.1). Items without a duration are never dropped, and a cap of 2048
items guards against packets that report none.
AudioPacketQueueTest covers wired start-up audio fitting without drops, AAC,
dropping the oldest audio, a blocking take and the per-codec durations.