/// <summary> Reads the exact number of bytes from the source
/// input stream into a byte array.
/// *
/// </summary>
/// <param name="b The">byte array to read the specified number
/// of bytes into.
/// </param>
/// <param name="offs The">index in the array where the first byte
/// read should be stored.
/// </param>
/// <param name="len the">number of bytes to read.
/// *
/// </param>
/// <exception cref=""> BitstreamException is thrown if the specified
/// number of bytes could not be read from the stream.
///
/// </exception>
private void readFully(sbyte[] b, int offs, int len)
{
try
{
while (len > 0)
{
int bytesread = source.Read(b, offs, len);
if (bytesread == -1 ||
bytesread == 0) // t/DD -- .NET returns 0 at end-of-stream!
{
// t/DD: this really SHOULD throw an exception here...
Trace.WriteLine("readFully -- returning success at EOF? (" + bytesread + ")",
"Bitstream");
while (len-- > 0)
{
b[offs++] = 0;
}
break;
//throw newBitstreamException(UNEXPECTED_EOF, new EOFException());
}
offs += bytesread;
len -= bytesread;
}
}
catch (System.IO.IOException ex)
{
throw newBitstreamException(javazoom.jl.decoder.BitstreamErrors_Fields.STREAM_ERROR, ex);
}
}