Skip to content

refactor(m5stack-tab5): audio task on the shared I2S TX feed policy (follow-up to #869) - #875

Merged
finger563 merged 2 commits into
mainfrom
refactor/tab5-i2s-tx-feed
Nov 2, 2026
Merged

finger563 merged 2 commits into
mainfrom
refactor/tab5-i2s-tx-feed

Conversation

@finger563

@finger563 finger563 commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The follow-up promised in #869: the Tab5 was the one audio BSP still carrying its own copy of the I2S TX feeding policy that #868 introduced. It now uses the shared espp::i2s_tx_feed header from components/codec like the other nine boards.

  • audio_task_callback() is attach_current_task() + fill_block() + the I2S write; the misaligned-stream reset is reported by the feeder and logged here.
  • play_audio() calls notify_if_block_ready() after a successful send (send -> notify -> return).
  • The ring depth and the static_assert use the header's constants and ring_outlasts_wait() against the Tab5's own UPDATE_FREQUENCY.
  • The init failure path calls detach_task() before stopping the playback task.
  • The two per-instance members (audio_tx_task_handle_, audio_tx_was_flowing_) are replaced by one Feeder, and the long explanation block is gone in favour of a pointer at the header.

No behaviour change intended: same 12 x 240 ring, same 24 ms bounded wait, same whole-block writes, same stream and trigger level. The Tab5's own specifics (full-duplex RX channel, the microphone task, the ES8388/ES7210 codec setup, the frame-aligned producer) are untouched.

Test plan

🤖 Generated with Claude Code

https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU

…codec/i2s_tx_feed.hpp)

The follow-up promised in #869: the Tab5 was the one audio BSP still
carrying its own copy of the feeding policy from #868. Its playback task
now uses espp::i2s_tx_feed::Feeder like the other nine boards
(attach_current_task / fill_block / notify_if_block_ready / detach_task),
with the ring depth and static_assert taken from the header's constants.
No behaviour change: same 12 x 240 ring, 24 ms bounded wait, whole-block
writes, stream and trigger level; the Tab5's own specifics (full-duplex RX
channel, microphone task, codec setup, frame-aligned producer) are
untouched.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
Copilot AI balanced review requested due to automatic review settings November 2, 2026 15:05
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Refactors the M5Stack Tab5 audio playback path to use the shared espp::i2s_tx_feed feeding policy (as introduced elsewhere in the repo), removing the Tab5-specific duplicated implementation while keeping behavior consistent.

Changes:

  • Replace Tab5-local I2S TX feed policy (whole-block writes, bounded wait, ring sizing) with the shared espp::i2s_tx_feed::Feeder.
  • Update playback signaling to use notify_if_block_ready() and centralize misalignment handling via the feeder.
  • Use shared DMA ring constants and helper (ring_outlasts_wait) for the I2S TX ring safety static assert.
File Description
components/​m5stack-tab5/​src/​audio.cpp Switches playback task and producer notification logic to the shared I2S TX feeder implementation and constants.
components/​m5stack-tab5/​include/​m5stack-tab5.hpp Replaces per-instance playback state with a shared Feeder member and adds the feeder header include.

Review effort: Lite

Comment thread components/m5stack-tab5/src/audio.cpp Resolved
…eam warning

The shared feeder resets the stream when it finds a partial frame, so the
BSP's warning had lost the byte count the old Tab5 code logged. The Feeder
now records how many bytes the stream held (misaligned_bytes, additive, no
API change for the other boards) and the Tab5 warning reports it together
with the partial remainder and the frame size.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
@finger563
finger563 merged commit cfe78dd into main Nov 2, 2026
179 checks passed
@finger563
finger563 deleted the refactor/tab5-i2s-tx-feed branch November 2, 2026 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants