Fix Link Audio packet sizing and timing changes - #183
Merged
fgo-ableton merged 2 commits intoSep 21, 2026
Merged
Conversation
Reserve space for additional timing chunks before admitting them and use the remaining frame capacity when filling packets. Preserve the existing single-chunk audio allowance and avoid creating chunks for empty input. Start a new chunk when either tempo or beat position changes. Cover timing discontinuities, serialized packet limits, sample preservation, and continuation after a format-change flush.
The timeline computes beats via absolute time conversion in beatAtTime while chunkEndBeats uses incremental frame counting. The different floating-point paths can diverge and thus call newChunk() on every callback. So we add an error margin of 1 micro beat as a fix.
fgo-ableton
force-pushed
the
fix/link-audio-packet-timing
branch
from
September 21, 2026 10:43
18a4af3 to
a753254
Compare
Contributor
|
Thank you! |
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.
Resizeronly starts a new timing chunk when both tempo and beat position change. This loses timestamp discontinuities at unchanged tempo, and tempo changes at an otherwise continuous beat boundary.Changing that condition alone can expose a second problem: packet filling ignores the space used by additional timing chunks. With small input buffers, the resulting packet can exceed the serializer's maximum message size.
This change accounts for each additional chunk before admitting it, flushes when the next chunk and audio frame would not fit, and uses the remaining frame capacity when filling packets. Single-chunk audio capacity stays unchanged. Zero-frame calls still flush on a format or session change, without creating an empty chunk.
The timing condition now starts a new chunk when either tempo or beat position changes. Tests cover both timing changes, mono/stereo packet bounds, sample preservation, and continuing after an empty format-change flush. The Encoder test fixture also initializes its session ID.
Validation on macOS arm64:
LinkAudioTest,LinkCoreTest,LinkDiscoveryTest, andLinkUtilTestpassed.LinkAudioTestpassed.LinkAudioTestpassed.git diff --checkpassed.AddressSanitizer could not be verified because the local Apple sanitizer hangs during initialization, before
main. Windows and Linux have not been tested locally.I have signed the Ableton CLA.