Skip to content

Fix Link Audio packet sizing and timing changes - #183

Merged
fgo-ableton merged 2 commits into
Ableton:masterfrom
silver-ben:fix/link-audio-packet-timing
Sep 21, 2026
Merged

fgo-ableton merged 2 commits into
Ableton:masterfrom
silver-ben:fix/link-audio-packet-timing

Conversation

@silver-ben

Copy link
Copy Markdown
Contributor

Resizer only 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:

  • Debug: LinkAudioTest, LinkCoreTest, LinkDiscoveryTest, and LinkUtilTest passed.
  • Release: LinkAudioTest passed.
  • UndefinedBehaviorSanitizer: LinkAudioTest passed.
  • clang-format 19.1.7 and git diff --check passed.

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.

silver-ben and others added 2 commits September 20, 2026 13:35
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
fgo-ableton force-pushed the fix/link-audio-packet-timing branch from 18a4af3 to a753254 Compare September 21, 2026 10:43
@fgo-ableton

Copy link
Copy Markdown
Contributor

Thank you!

@fgo-ableton
fgo-ableton merged commit 13c5744 into Ableton:master Sep 21, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants