Module java.desktop

Interface DataLine

All Superinterfaces:
AutoCloseable, Line
All Known Subinterfaces:
Clip, SourceDataLine, TargetDataLine

public interface DataLine
extends Line
DataLine adds media-related functionality to its superinterface, Line. This functionality includes transport-control methods that start, stop, drain, and flush the audio data that passes through the line. A data line can also report the current position, volume, and audio format of the media. Data lines are used for output of audio by means of the subinterfaces SourceDataLine or Clip, which allow an application program to write data. Similarly, audio input is handled by the subinterface TargetDataLine, which allows data to be read.

A data line has an internal buffer in which the incoming or outgoing audio data is queued. The drain() method blocks until this internal buffer becomes empty, usually because all queued data has been processed. The flush() method discards any available queued data from the internal buffer.

A data line produces START and STOP events whenever it begins or ceases active presentation or capture of data. These events can be generated in response to specific requests, or as a result of less direct state changes. For example, if start() is called on an inactive data line, and data is available for capture or playback, a START event will be generated shortly, when data playback or capture actually begins. Or, if the flow of data to an active data line is constricted so that a gap occurs in the presentation of data, a STOP event is generated.

Mixers often support synchronized control of multiple data lines. Synchronization can be established through the Mixer interface's synchronize method. See the description of the Mixer interface for a more complete description.

Since:
1.3
See Also:
LineEvent
  • Nested Class Summary

    Nested Classes 
    Modifier and Type Interface Description
    static class  DataLine.Info
    Besides the class information inherited from its superclass, DataLine.Info provides additional information specific to data lines.
  • Method Summary

    Modifier and Type Method Description
    int available()
    Obtains the number of bytes of data currently available to the application for processing in the data line's internal buffer.
    void drain()
    Drains queued data from the line by continuing data I/O until the data line's internal buffer has been emptied.
    void flush()
    Flushes queued data from the line.
    int getBufferSize()
    Obtains the maximum number of bytes of data that will fit in the data line's internal buffer.
    AudioFormat getFormat()
    Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.
    int getFramePosition()
    Obtains the current position in the audio data, in sample frames.
    float getLevel()
    Obtains the current volume level for the line.
    long getLongFramePosition()
    Obtains the current position in the audio data, in sample frames.
    long getMicrosecondPosition()
    Obtains the current position in the audio data, in microseconds.
    boolean isActive()
    Indicates whether the line is engaging in active I/O (such as playback or capture).
    boolean isRunning()
    Indicates whether the line is running.
    void start()
    Allows a line to engage in data I/O.
    void stop()
    Stops the line.

    Methods declared in interface javax.sound.sampled.Line

    addLineListener, close, getControl, getControls, getLineInfo, isControlSupported,