Skip to content

fix: skip zero-length ISO OUT packets in audio read thread - #271

Open
Nictrla wants to merge 1 commit into
eclipse-threadx:devfrom
Nictrla:fix/device-audio-skip-zero-length-iso-out-frames
Open

fix: skip zero-length ISO OUT packets in audio read thread#271
Nictrla wants to merge 1 commit into
eclipse-threadx:devfrom
Nictrla:fix/device-audio-skip-zero-length-iso-out-frames

Conversation

@Nictrla

@Nictrla Nictrla commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

A zero-length isochronous OUT transfer (actual_length == 0) carries no audio data, but the read thread still recorded it as a frame: it wrote frame_length = 0 into the slot at transfer_pos, advanced transfer_pos and fired the frame_done callback.

Because the frame FIFO uses frame_length == 0 as the sentinel for an empty slot, this made the slot indistinguishable from a free one. The consumer then read at access_pos, saw frame_length == 0, reported it as an underflow (UX_BUFFER_OVERFLOW) and did not advance access_pos. As a result transfer_pos moved forward while access_pos stayed put, permanently desyncing the producer/consumer positions.

Skip zero-length packets entirely: leave transfer_pos in place, do not fire the callback, and re-issue the transfer at the same slot. This preserves the "frame_length == 0 means empty slot" invariant and keeps the transfer and access positions in sync.

A zero-length isochronous OUT transfer (actual_length == 0) carries no
audio data, but the read thread still recorded it as a frame: it wrote
frame_length = 0 into the slot at transfer_pos, advanced transfer_pos
and fired the frame_done callback.

Because the frame FIFO uses frame_length == 0 as the sentinel for an
empty slot, this made the slot indistinguishable from a free one.
The consumer then read at access_pos, saw frame_length == 0, reported
it as an underflow (UX_BUFFER_OVERFLOW) and did not advance access_pos.
As a result transfer_pos moved forward while access_pos stayed put,
permanently desyncing the producer/consumer positions.

Skip zero-length packets entirely: leave transfer_pos in place,
do not fire the callback, and re-issue the transfer at the same slot.
This preserves the "frame_length == 0 means empty slot" invariant
and keeps the transfer and access positions in sync.
@Nictrla
Nictrla force-pushed the fix/device-audio-skip-zero-length-iso-out-frames branch from 4d2519b to 8e2d74b Compare July 27, 2026 10:21
@fdesbiens
fdesbiens changed the base branch from master to dev July 28, 2026 15:04
@fdesbiens

Copy link
Copy Markdown
Contributor

Hi @Nictrla.

Thank you for this contribution!

@rahmanih: Can you review, please?

@fdesbiens
fdesbiens requested review from fdesbiens and rahmanih July 28, 2026 15:05
@fdesbiens fdesbiens moved this to In review in ThreadX Roadmap Jul 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In review

Development

Successfully merging this pull request may close these issues.

2 participants