Open
Conversation
Author
|
Related to #7227 |
Open
1 task
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This pull request introduces improvements to the DMA (Direct Memory Access) handling for audio output on STM32 platforms, focusing on more robust detection of buffer underruns and safer stopping of the DMA stream. The main goal is to reduce unnecessary start/stop cycles (thrashing) when the audio producer briefly lags, and to ensure DMA flags are properly managed for reliable operation.
DMA underrun detection and handling:
_empty_dma_halves) and a threshold (DMA_EMPTY_HALVES_STOP_THRESHOLD) to require sustained silence (multiple empty DMA buffer halves) before stopping the DMA stream, preventing rapid start/stop cycles when the audio buffer briefly runs out of data. [1] [2]_empty_dma_halvesonly when buffer underruns are detected, and resets it when new data is available. DMA is only stopped when the threshold is reached. [1] [2]DMA flag management and stream control:
dac_clear_dma_flags()to clear any stale DMA half/complete transfer flags before starting or after stopping a DMA transfer, ensuring the DMA state machine operates from a clean slate.dac_close_dma_xfer()to wait for the DMA enable bit to clear and then reset DMA flags, improving robustness when stopping the stream.dac_start_dma()to clear DMA flags before enabling the stream and interrupts, preventing spurious interrupts from previous transfers.These changes should make audio playback more resilient to brief underruns and improve the reliability of DMA operations.