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
MP3 reader support #1796
MP3 reader support #1796
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should update the comments on the these three openFrom* functions in the InputSoundFile header.
You may also add a comment regarding APEv2 causing potential issues.
SFML/include/SFML/Audio/InputSoundFile.hpp
Lines 90 to 101 in 43b2e9d
//////////////////////////////////////////////////////////// | |
/// \brief Open a sound file from a custom stream for reading | |
/// | |
/// The supported audio formats are: WAV (PCM only), OGG/Vorbis, FLAC. | |
/// The supported sample sizes for FLAC and WAV are 8, 16, 24 and 32 bit. | |
/// | |
/// \param stream Source stream to read from | |
/// | |
/// \return True if the file was successfully opened | |
/// | |
//////////////////////////////////////////////////////////// | |
bool openFromStream(InputStream& stream); |
You should also update the license.md to include the license for minimp3 |
f50c7f1
to
8371a4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the two comments regarding use system deps and the windows.h conflict
4682f3a
to
65293e7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for the contribution!
I noticed a few smaller issues, but overall it looks good 🙂
b58c4a8
to
5f46044
Compare
m_io.read = readCallback; | ||
m_io.seek = seekCallback; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rest of m_io
remains uninitialized, since its type is a POD (plain old data) without constructor. This might lead to UB if one of the SoundFileReaderMp3
methods is called without a prior open()
call, where m_io
is fully initialized.
Also, m_decoder
is not initialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added memset initialize. Updated the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When the memory is zeroed, seek()
and other operations are safe (i.e. fail properly)?
I don't know the implementation and assumptions of the underlying library.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be fine, added tests for such case lieff/minimp3@b18d274 .
But calling open() method twice will lead to mem leak. Same for SoundFileReaderOgg as I can see. So calling it twice is forbidden? Or may be add protection against it?
Woops, I screwed up, while trying to update the branch. Had to opened a new PR #1851 with the changes... |
Is something needed from my side? Looks like PR stuck on email delivery or something. |
Nope, yeah seems like it somehow got lost, sorry about that. |
This PR is related to the issue #1232 and adds mp3 reading support.
Also discussed on the forum
Example SFML/examples/sound/Sound.cpp is extended to play an mp3 file.