public interface Line extends AutoCloseable
Lineinterface represents a mono or multi-channel audio feed. A line is an element of the digital audio "pipeline," such as a mixer, an input or output port, or a data path into or out of a mixer.
A line can have controls, such as gain, pan, and reverb.
The controls themselves are instances of classes that extend the
Line interface provides two accessor methods for
obtaining the line's controls:
entire set, and
returns a single control of
Lines exist in various states at different times. When a line opens, it reserves system
resources for itself, and when it closes, these resources are freed for
other objects or applications. The
you discover whether a line is open or closed.
An open line need not be processing data, however. Such processing is
typically initiated by subinterface methods such as
You can register an object to receive notifications whenever the line's
state changes. The object must implement the
interface, which consists of the single method
This method will be invoked when a line opens and closes (and, if it's a
DataLine, when it starts and stops).
An object can be registered to listen to multiple lines. The event it
receives in its
update method will specify which line created
the event, what type of event it was
and how many sample frames the line had processed at the time the event occurred.
Certain line operations, such as open and close, can generate security exceptions if invoked by unprivileged code when the line is a shared audio resource.
|Modifier and Type||Interface and Description|
|Modifier and Type||Method and Description|
Adds a listener to this line.
Closes the line, indicating that any system resources in use by the line can be released.
Obtains a control of the specified type, if there is any.
Obtains the set of controls associated with this line.
Indicates whether the line supports a control of the specified type.
Indicates whether the line is open, meaning that it has reserved system resources and is operational, although it might not currently be playing or capturing sound.
Opens the line, indicating that it should acquire any required system resources and become operational.
Removes the specified listener from this line's list of listeners.
Line.Infoobject describing this line.
void open() throws LineUnavailableException
OPENevent is dispatched to the line's listeners.
Note that some lines, once closed, cannot be reopened. Attempts
to reopen such a line will always result in an
Some types of lines have configurable properties that may affect
resource allocation. For example, a
be opened with a particular format and buffer size. Such lines
should provide a mechanism for configuring these properties, such
as an additional
open method or methods which allow
an application to specify the desired settings.
This method takes no arguments, and opens the line with the current
objects, this means that the line is
opened with default settings. For a
the buffer size is determined when data is loaded. Since this method does not
allow the application to specify any data to load, an IllegalArgumentException
is thrown. Therefore, you should instead use one of the
provided in the
Clip interface to load data into the
DataLine's, if the
object which was used to retrieve the line, specifies at least
one fully qualified audio format, the last one will be used
as the default format.
IllegalArgumentException- if this method is called on a Clip instance.
LineUnavailableException- if the line cannot be opened due to resource restrictions.
SecurityException- if the line cannot be opened due to security restrictions.
Clip.open(AudioFormat, byte, int, int),
CLOSEevent is dispatched to the line's listeners.
boolean isControlSupported(Control.Type control)
control- the type of the control for which support is queried
trueif at least one control of the specified type is supported, otherwise
Control getControl(Control.Type control)
void addLineListener(LineListener listener)
update()method is called with a
LineEventobject that describes the change.
listener- the object to add as a listener to this line
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.