Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle errors during audio DMA playback setup for RP2 ports #9989

Merged
merged 2 commits into from
Jan 22, 2025

Conversation

eightycc
Copy link

Fixes #9983.

Add handling for errors that may occur during setup of an audio DMA player. audio_dma_setup_playback() calls audio_dma_load_next_block() to fill one or two buffers with audio source data. This PR adds preservation of the error indication in the new dma_result field in audio_dma_t and examines it in audio_dma_setup_playback(). If an error indication is present, shuts down the player and throws an "Audio source error".

For #9983, the error indication occurs frequently due to the MP3 decoder being unable to synchronize with the incoming MP3 stream. The app can now retry (sometimes a few times) to synchronize with the stream.

@eightycc eightycc changed the title Issue 9983 Handle errors during audio DMA playback setup for RP2 ports Jan 22, 2025
@eightycc
Copy link
Author

@bablokb Please give this a try. There may be more gravel in this gearbox.

Copy link
Member

@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you!

@tannewt tannewt merged commit 78a747e into adafruit:main Jan 22, 2025
591 checks passed
@bablokb
Copy link

bablokb commented Jan 23, 2025

@bablokb Please give this a try. There may be more gravel in this gearbox.

Works perfectly and the retry in case of an exception is so fast that from a user-perspective it is not noticed.

I do think there is some other error lurking around, because when I play this French url: http://icecast.radiofrance.fr/francemusiquebaroque-midfi.mp3 the playback stops about after half a second. But this seems to be handled internally (no crash) since I2SOut.playing will switch from True to False. My application does detect this and the user can switch to a different station. And it is not RP2xxx-related, since this also happens with my ESP32-S3 setup.

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.

Pico2W crashes when sequentially streaming mp3 from URLs
3 participants