Reads audio data from the data line's input buffer. The requested
number of bytes is read into the specified array, starting at
the specified offset into the array in bytes. This method blocks until
the requested amount of data has been read. However, if the data line
is closed, stopped, drained, or flushed before the requested amount has
been read, the method no longer blocks, but returns the number of bytes
read thus far.
The number of bytes that can be read without blocking can be ascertained
using the available
method of the
DataLine
interface. (While it is guaranteed that
this number of bytes can be read without blocking, there is no guarantee
that attempts to read additional data will block.)
The number of bytes to be read must represent an integral number of
sample frames, such that:
[ bytes read ] % [frame size in bytes ] == 0
The return value will always meet this requirement. A request to read a
number of bytes representing a non-integral number of sample frames cannot
be fulfilled and may result in an IllegalArgumentException.
Returns:
the number of bytes actually read
Parameters:
-
b - a byte array that will contain the requested input data when
this method returns
-
off - the offset from the beginning of the array, in bytes
-
len - the requested number of bytes to read
Throws:
-
IllegalArgumentException - if the requested number of bytes does
not represent an integral number of sample frames.
or if
len
is negative.
-
ArrayIndexOutOfBoundsException - if
off
is negative,
or
off+len
is greater than the length of the array
b
.
See Also:
SourceDataLine.write(byte[], int, int)
,
DataLine.available()
,