BufferInputStream error handling


In ensureBuffer() in BufferedInputStream setPosition is called, which returns false if the stream cannot seek to some position. But BufferedInputStream just discards it and then reads anyway …? (As does ZipInputStream and a few other classes).

Suspect it would be better to fail at this point rather than load invalid data…

        bufferStart = position;
        source->setPosition (bufferStart);
        bytesRead = source->read (buffer, bufferSize);
        lastReadPos = bufferStart + bytesRead;


Ah, that’s some pretty old code! Thanks, I’ll have a look at that…


Yeah, I’d have a skip through all the uses of setPosition I think, there’s some shady stuff there :wink:

I’ve managed to get this URL streaming audio playback working by the way … but not really happy with the solution. The web calls are happening on the audio thread. Also, it turns out the first thing the WindowsMedia audio reader does is seek right to the end of the stream (not very trusting I’d say!)… the MP3AudioFormat doesn’t through fortunately.