BR: BufferedInputStream broken for most mp3 files

BufferedInputStream used in conjunction with AudioFormatManager::createReaderFor was broken by this commit for most mp3 files I tested (on Mac, haven’t tested on Win yet).
The BufferedInputStream is created successfully, but AudioFormatManager::createReaderFor fails.

Reverting the commit fixes the issue. To be more precise, reverting the changes to BufferedInputStream is enough to fix the issue.

To repro, open the AudioPlaybackDemo, and change the following code:

if (audioURL.isLocalFile())
{
     reader = formatManager.createReaderFor (audioURL.getLocalFile());
}

to:

if (audioURL.isLocalFile())
{
    auto fileStream = std::make_unique<FileInputStream>( audioURL.getLocalFile() );
    if ( fileStream->openedOk() )
    {
        auto bufferedInputStream = std::make_unique<juce::BufferedInputStream>( fileStream.release(), 512*10, true );
        reader = formatManager.createReaderFor( std::move( bufferedInputStream ) );
    }
}

Thanks for reporting, this was due to a bug in the buffering mechanism. It should be fixed here:

Please try it out and let us know if you encounter any new issues.

2 Likes

That fixes the issue. Thanks @reuk!