InputStream read error codes

In the MP3 decoder we have this code:

            bytesRead = source->read (buffer, bufferSize);

            if (bytesRead < 0)
                return false;

Is -1 supposed to be an error code from InputStream::read? It’s not mentioned in the InputStream documentation.

We have a streaming audio playing built on top of this which I need to handle aborting for during quitting (currently it hangs waiting for a lock in TimeSliceThread!). Turns out sometimes we have no more data turning up and waiting is pointless - e.g.if the network goes down - and aborting would fix this!

Bit unclear what that -1 is about actually :slight_smile:

However - to answer my own question. If I return -1 there and also ensure isExhausted() returns true when the network is no longer delivering any data and the local buffer is already empty then it looks like it behaves.