OGG (vorbis) File puts JUCE OggReader in infinite loop

Hi,
Reading this ogg file causes juce’s ogg code to get stuck in an infinite loop.

File: https://www.dropbox.com/s/iy0dtqq3slzofsv/coverTest.ogg?dl=0

Sample Code to trigger the issue:

AudioFormatManager mgr;
mgr.registerBasicFormats();

auto afReader = std::unique_ptr<AudioFormatReader>(mgr.createReaderFor(oggFile));

const int channels = int(afReader->numChannels);
const int lengthInSamples = int(afReader->lengthInSamples);

AudioSampleBuffer buffer(channels, lengthInSamples);

// this line leads to the infinite loop
afReader->read(&buffer, 0, lengthInSamples, 0, true, true);

The loop that ends up going round and round is while(offset==-1) in: static ogg_int64_t _get_prev_page(OggVorbis_File *vf,ogg_page *og)
vf->offset and end are both 0, so the while(vf->offset<end) loop never runs.

The example file is the shortest out of a number we’ve found that have the issue.

They are obviously not well formed Oggs but this is part of a service where the user chooses the file to analyse, which then hangs.

Any ideas on how to detect the issue before starting the read would be appreciated too! :slight_smile:

EDIT: to be clear these oggs all play fine in other DAWs / media players etc…

Dave

Thanks for the report! We’ve updated the Ogg Vorbis library bundled with JUCE from 1.3.2 to 1.3.7 in 35d0a8c which has fixed the issue with this file. I’d be interested to know if it has fixed the other troublesome files for you too.

3 Likes

Excelent, thanks!
I tried on a few others and they all worked as expected.

Dave

1 Like

Would it be permissable to apply this to JUCE 5? From a brief glance it just appears that the library has been updated and in any of the JUCE files the include paths updated appropriately.

I’m afraid not, this change is a part of the JUCE 6 code and therefore requires a JUCE 6 licence to use.