Skip to content

MP3File: Bug fixes #2375

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

Merged
merged 2 commits into from
Dec 12, 2019
Merged

MP3File: Bug fixes #2375

merged 2 commits into from
Dec 12, 2019

Conversation

jepler
Copy link

@jepler jepler commented Dec 12, 2019

Avoid crash in get_buffer when deinitted:

  • When a playing mp3 is deinitted, it's possible to reach get_buffer, but all the internal pointers are NULL. This would lead to a hard fault. Avoid it by returning GET_BUFFER_ERROR instead.

Properly play back stereo on samd AudioOut

  • Several problems prevented the "right" channel from getting the correct samples

When a playing mp3 is deinitted, it's possible to reach get_buffer,
but all the internal pointers are NULL.  This would lead to a hard fault.
Avoid it by returning GET_BUFFER_ERROR instead.
@jepler
Copy link
Author

jepler commented Dec 12, 2019

Testing performed: Before this change, I regularly saw hardfaults with my mp3player app. After, I don't.

There were several problems with the way this worked -- the read_count
approach was too complicated and I made a mistake "simplifying" it from
WaveFile.  And when the right channel was returned, it was off by 1 byte,
making it into static.

Instead, directly track which is the "other" channel that has data
available, and by using the right data type make the "+ channel"
arithmetic give the right result.

This requires a double cast (int16_t*)(void*) due to an alignment warning;
the alignment is now ensured manually, but the compiler doesn't make the
necessary inference that the low address bit must be clear.
@jepler jepler changed the title MP3File: Avoid crash in get_buffer when deinitted MP3File: Bug fixes Dec 12, 2019
@jepler
Copy link
Author

jepler commented Dec 12, 2019

Testing performed: stereo plays back properly now

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 bf8796b into adafruit:master Dec 12, 2019
@jepler jepler deleted the mp3-hardfault branch November 3, 2021 21:10
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy