Skip to content

refactor(i2s): switch over DriverState in Phase 2c poll() - #3545

Merged
zackees merged 1 commit into
masterfrom
refactor/poll-switch-3526-2c
Jul 1, 2026
Merged

zackees merged 1 commit into
masterfrom
refactor/poll-switch-3526-2c

Conversation

@zackees

@zackees zackees commented Jul 1, 2026 •

Copy link
Copy Markdown
Member

Replaces if/else chain with switch over enum for compiler-enforced coverage. No behavior change.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of channel completion and delegate states to make streaming behavior more reliable.
    • Fixed edge cases where busy, draining, or error conditions could leave the system in an inconsistent state.
    • Added clearer state handling for in-progress transfers, helping avoid stalled or incomplete playback/recording.

…3526)

Replaces the if/else chain in `ChannelEngineI2sEsp32Dev::poll()`'s
SPI-delegate handling with an explicit `switch` over
`DriverState::Value`. Compiler now enforces coverage — if a new
DriverState enum value gets added, the missing case is a warning /
error at build time rather than a silent unhandled state.

Same behavior as the if/else version: READY / DRAINING / ERROR
surface up to callers with the appropriate cleanup; BUSY stays in
the current state.

Follow-up to #3544.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@zackees
zackees merged commit de9ddd9 into master Jul 1, 2026
11 checks passed
@coderabbitai

coderabbitai Bot commented Jul 1, 2026 •

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ff5257dd-a085-459f-912a-6af12e300eed

📥 Commits

Reviewing files that changed from the base of the PR and between 3387877 and 0cce21d.

📒 Files selected for processing (1)
  • src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp.hpp

📝 Walkthrough

Walkthrough

The SPI-delegate completion handling in ChannelEngineI2sEsp32Dev::poll() was refactored from an if/else chain to a switch statement over delegate_state.state, with explicit case arms for READY, DRAINING, ERROR, and BUSY states.

Changes

Poll() Delegate State Refactor

Layer / File(s) Summary
Switch-based delegate completion handling
src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp.hpp
Replaces if/else chain with a switch on delegate_state.state; DRAINING sets mState to DRAINING, ERROR performs cleanup (releasing in-flight channels, clearing mInFlightChannels, resetting mTransmitCompleted) and sets mState to ERROR, and BUSY is an explicit no-op case.

Estimated code review effort: 2 (Simple) | ~10 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/poll-switch-3526-2c

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant