In AudioFormatReader lengthInSamples is an int64, but in searchForLevel it gets cast to an int before a comparison. Bug?
I’ve also a place, but forgotten where now, where it’s assumed that lengthInSamples != std::numeric_limits::max() … which unfortunately my special reader used to say it was infinitely long…
Might be worth a bit of a code review where the int64 size numbers are used at some point.
Not really sure what’s going no here as both bufferStart and lengthInSamples are already int64s?
if (bufferStart >= (int) lengthInSamples)
break;