Wrong assertion in AiffAudioFormatWriter::writeHeader()


#1

there is a small mistake in juce_appframework\audio\audio_file_formats\juce_AiffAudioFormat.cpp (547) :

[code] void writeHeader()
{
const int newPos = output->setPosition (headerPosition);
(void) newPos;

    // if this fails, you've given it an output stream that can't seek! It needs
    // to be able to seek back to write the header
    jassert (newPos == headerPosition);

[/code]

should be

[code] void writeHeader()
{
const bool seekedOk = output->setPosition (headerPosition);
(void) seekedOk;

    // if this fails, you've given it an output stream that can't seek! It needs
    // to be able to seek back to write the header
    jassert (seekedOk);[/code]

like in juce_appframework\audio\audio_file_formats\juce_WavAudioFormat.cpp


#2

Ah yes - I think that maybe originally it used to return a position rather than a bool! Thanks for letting me know!


#3

“(void) seekedOk;”

WTF does that do?


#4

It’s done because some compilers would warn you about unused variable.
It’s the case in release builds for ‘seekedOk’ cause jassert won’t be compiled.


#5