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
Fixed Wave file writer writing wrong header values #1281
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.
Looks good.
@@ -191,8 +188,9 @@ void SoundFileWriterWav::close() | |||
m_file.flush(); | |||
|
|||
// Update the main chunk size and data sub-chunk size | |||
Uint32 dataChunkSize = static_cast<Uint32>(m_sampleCount * m_channelCount * 2); | |||
Uint32 mainChunkSize = dataChunkSize + 36; | |||
Uint32 fileSize = m_file.tellp(); |
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.
No compiler warning about type conversion here?
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.
Our VS CI builds have warnings for it.
src\SFML\Audio\SoundFileWriterWav.cpp(191) : warning C4244: 'initializing' : conversion from 'std::streamoff' to 'sf::Uint32', possible loss of data
Look good, but I think you can remove m_channelCount as well. |
You're right, didn't notice! |
480a021
to
da0282a
Compare
Previously when updating the header fields, SFML assumed the number of samples written would be the number of samples per channel, which wasn't the case. Therefore for stereo files the written file length was actually twice the correct value. This fix uses the file size written as a basis, no longer counting the samples written alltogether. This fixes issue #1280.
da0282a
to
b3d6e48
Compare
Fixes #1280.
Previously when updating the header fields, SFML assumed the number of samples written would be the number of samples per channel, which wasn't the case. Therefore for stereo files the written file length was actually twice the correct value. This fix uses the file size written as a basis, no longer counting the samples written altogether.