Repository navigation
Conversation
Each 0x58 frame was emitted from its own Dispatchers.IO coroutine, so frames overtook each other (21-37 of every 400 out of order on a Pro 3). AAC-ELD overlaps neighbouring frames, so every swap garbled the audio. Emit synchronously with tryEmit on the AACP reader thread instead (0 of 400).
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.
The AACP
0x58handler launches one coroutine per microphone frame:Dispatchers.IOruns these in parallel, so frames from the same packet (and from back-to-back packets, which often arrive within 1 ms of each other) can overtake each other before they reachmicrophoneFrames. AAC-ELD overlaps neighbouring frames, so every swap garbles the decoded audio around it. It sounds robotic or crackly.Measured on AirPods Pro 3 by checking that each frame's timestamp is larger than the previous one (timestamps step by 180 per frame): 21 and 37 of every 400 frames arrived out of order. With this change: 0 of 400 over several streams, and the audio sounds clean.
The fix emits synchronously on the AACP reader thread with
tryEmit, so frames keep their arrival order. The flow already hasextraBufferCapacity = 64and collectors only need to hand frames off, sotryEmitshouldn't drop anything in practice; a failedtryEmitis logged.Tested on Android 17 with MediaCodec decoding (AAC-ELD, 480 samples, 64 kHz).