/*
* @(#)DataLine.java 1.34 05/11/17
*
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
package javax.sound.sampled;
/**
* <code>DataLine</code> adds media-related functionality to its
* superinterface, <code>{@link Line}</code>. 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 <code>{@link SourceDataLine}</code> or
* <code>{@link Clip}</code>, which allow an application program to write data. Similarly,
* audio input is handled by the subinterface <code>{@link TargetDataLine}</code>,
* which allows data to be read.
* <p>
* A data line has an internal buffer in which
* the incoming or outgoing audio data is queued. The
* <code>{@link #drain()}</code> method blocks until this internal buffer
* becomes empty, usually because all queued data has been processed. The
* <code>{@link #flush()}</code> method discards any available queued data
* from the internal buffer.
* <p>
* A data line produces <code>{@link LineEvent.Type#START START}</code> and
* <code>{@link LineEvent.Type#STOP STOP}</code> 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 <code>{@link #start()}</code> is called
* on an inactive data line, and data is available for capture or playback, a
* <code>START</code> 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 <code>STOP</code> event is generated.
* <p>
* Mixers often support synchronized control of multiple data lines.
* Synchronization can be established through the Mixer interface's
* <code>{@link Mixer#synchronize synchronize}</code> method.
* See the description of the <code>{@link Mixer Mixer}</code> interface
* for a more complete description.
*
* @author Kara Kytle
* @version 1.34, 05/11/17
* @see LineEvent
* @since 1.3
*/
public interface DataLine extends Line {
/**
* Drains queued data from the line by continuing data I/O until the
* data line's internal buffer has been emptied.
* This method blocks until the draining is complete. Because this is a
* blocking method, it should be used with care. If <code>drain()</code>
* is invoked on a stopped line that has data in its queue, the method will
* block until the line is running and the data queue becomes empty. If
* <code>drain()</code> is invoked by one thread, and another continues to
* fill the data queue, the operation will not complete.
* This method always returns when the data line is closed.
*
* @see #flush()
*/
public void drain();
/**
* Flushes queued data from the line. The flushed data is discarded.
* In some cases, not all queued data can be discarded. For example, a
* mixer can flush data from the buffer for a specific input line, but any
* unplayed data already in the output buffer (the result of the mix) will
* still be played. You can invoke this method after pausing a line (the
* normal case) if you want to skip the "stale" data when you restart
* playback or capture. (It is legal to flush a line that is not stopped,
* but doing so on an active line is likely to cause a discontinuity in the
* data, resulting in a perceptible click.)
*
* @see #stop()
* @see #drain()
*/
public void flush();
/**
* Allows a line to engage in data I/O. If invoked on a line
* that is already running, this method does nothing. Unless the data in
* the buffer has been flushed, the line resumes I/O starting
* with the first frame that was unprocessed at the time the line was
* stopped. When audio capture or playback starts, a
* <code>{@link LineEvent.Type#START START}</code> event is generated.
*
* @see #stop()
* @see #isRunning()
* @see LineEvent
*/
public void start();
/**
* Stops the line. A stopped line should cease I/O activity.
=1= |