Writes audio data to the mixer via this source data line. The requested
number of bytes of data are read from the specified array,
starting at the given offset into the array, and written to the data
line's buffer. If the caller attempts to write more data than can
currently be written (see
available
),
this method blocks until the requested amount of data has been written.
This applies even if the requested amount of data to write is greater
than the data line's buffer size. However, if the data line is closed,
stopped, or flushed before the requested amount has been written,
the method no longer blocks, but returns the number of bytes
written thus far.
The number of bytes that can be written without blocking can be ascertained
using the available
method of the
DataLine
interface. (While it is guaranteed that
this number of bytes can be written without blocking, there is no guarantee
that attempts to write additional data will block.)
The number of bytes to write must represent an integral number of
sample frames, such that:
[ bytes written ] % [frame size in bytes ] == 0
The return value will always meet this requirement. A request to write 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 written
Parameters:
-
b - a byte array containing data to be written to the data line
-
len - the length, in bytes, of the valid data in the array
(in other words, the requested amount of data to write, in bytes)
-
off - the offset from the beginning of the array, in bytes
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:
TargetDataLine.read(byte[], int, int)
,
DataLine.available()
,