You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(i2s): stop DMA before freeing clockless frame - #5484
On classic ESP32, clockless I2S DMA descriptors point directly at the engine's scratch buffer. If the teardown wait expires, stop the peripheral and unregister the callback before releasing channels or freeing that buffer.
The host regression reproduces a free while the peripheral still reports busy. It passes under ASan/UBSan after the fix and confirms cleanup releases the channel and buffer. Changed-file lint passed. Full host C++ and hosted ESP32 checks are running.
Summary by CodeRabbit
Bug Fixes
Improved audio reliability when an engine is shut down during an active transmission. The peripheral is now properly deinitialized, and channel resources are released without leaving buffers outstanding or the channel marked as in use.
CodeRabbit is using all valid settings from your configuration. Unrecognized properties (listed below) have been ignored and may indicate typos or deprecated fields that can be removed.
Parsing warnings: 1
Validation error: Unrecognized key: "enabled" at "reviews.pre_merge_checks"
If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json
No actionable comments were generated in the recent review.
Walkthrough
The I2S engine destructor now waits for transmission activity, deinitializes an initialized peripheral, and unregisters its transmit callback before releasing channel marks and the scratch buffer. A unit test checks buffer release when the engine is destroyed during transmission.
Changes: I2S teardown
Layer / File(s)
Summary
Order teardown and verify buffer release src/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp.hpp, tests/unit/platforms/esp/32/drivers/i2s/channel_engine_i2s_esp32dev.cpp
The destructor deinitializes the peripheral and unregisters the transmit callback before releasing channel marks and the scratch buffer. The test helper can check that the mock is idle before freeing a buffer, and a new test checks teardown during active transmission.
FastLED/FastLED#5482 — Both changes address scratch-buffer lifetime while DMA may still be active; this PR handles teardown, while #5482 handles a wait timeout.
Merge Risk: Minimal · up to bbaf9
This change reorders I2S engine teardown so DMA is stopped before the scratch buffer is freed, which prevents use-after-free on classic ESP32. No actionable merge-blocking risk was found. The one CI failure is an infrastructure error in project automation and does not reflect the code.
Pre-merge checks: 4
Check name
Status
Explanation
Description Check
Check skipped - CodeRabbit’s high-level summary is enabled.
Title check
The title "fix(i2s): stop DMA before freeing clockless frame" matches the main change. The changeset reorders teardown in ChannelEngineI2sEsp32Dev so the peripheral is deinitialized and the transmit c…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(i2s): stop DMA before freeing clockless frame" matches the main change. The changeset reorders teardown in ChannelEngineI2sEsp32Dev so the peripheral is deinitialized and the transmit callback is unregistered before channel marks and the scratch buffer are released. The added test covers destroying the engine during an active transmission, and the PR objectives describe stopping the peripheral before freeing the buffer. The title is specific and uses the conventional commit format.
Finishing Touches
Generate unit tests (beta)
Commit to this branch
Create a new PR
Fix failing CI checks
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
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.
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 4 remain after this review.
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
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.
Follow-up to #5356.
On classic ESP32, clockless I2S DMA descriptors point directly at the engine's scratch buffer. If the teardown wait expires, stop the peripheral and unregister the callback before releasing channels or freeing that buffer.
The host regression reproduces a free while the peripheral still reports busy. It passes under ASan/UBSan after the fix and confirms cleanup releases the channel and buffer. Changed-file lint passed. Full host C++ and hosted ESP32 checks are running.
Summary by CodeRabbit