APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.media.sound

pack-priv abstract Class AbstractDataLine

extends AbstractLine
implements DataLine
Class Inheritance
All Implemented Interfaces
javax.sound.sampled.DataLine, javax.sound.sampled.Line, java.lang.AutoCloseable
Known Direct Subclasses
com.sun.media.sound.DirectAudioDevice.DirectDL
Imports
javax.sound.sampled.AudioFormat, .AudioSystem, .Control, .DataLine, .LineEvent, .LineUnavailableException

AbstractDataLine
Author
Kara Kytle

Field Summary

Modifier and TypeField and Description
private volatile boolean
protected int
private final int
private final AudioFormat
protected AudioFormat
protected final Object
private volatile boolean
private volatile boolean
Inherited from com.sun.media.sound.AbstractLine:
controlsinfomixer

Constructor Summary

AccessConstructor and Description
protected
AbstractDataLine(DataLine.Info info, AbstractMixer mixer, Control[] controls)

Constructs a new AbstractLine.

protected
AbstractDataLine(DataLine.Info info, AbstractMixer mixer, Control[] controls, AudioFormat format, int bufferSize)

Constructs a new AbstractLine.

Method Summary

Modifier and TypeMethod and Description
public int
available()

Implements javax.sound.sampled.DataLine.available.

This implementation always returns 0.

public final void
close()

Implements abstract com.sun.media.sound.AbstractLine.close.

Implements javax.sound.sampled.Line.close.

This should also stop the line.

public void
drain()

Implements javax.sound.sampled.DataLine.drain.

This implementation does nothing.

public void
flush()

Implements javax.sound.sampled.DataLine.flush.

This implementation does nothing.

public final int
getBufferSize()

Implements javax.sound.sampled.DataLine.getBufferSize.

Obtains the maximum number of bytes of data that will fit in the data line's internal buffer.

public final AudioFormat
getFormat()

Implements javax.sound.sampled.DataLine.getFormat.

Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.

public final float
getLevel()

Implements javax.sound.sampled.DataLine.getLevel.

This implementation returns AudioSystem.NOT_SPECIFIED.

public final long
getMicrosecondPosition()

Implements javax.sound.sampled.DataLine.getMicrosecondPosition.

Obtains the current position in the audio data, in microseconds.

pack-priv abstract void
pack-priv abstract void
implOpen(AudioFormat format, int bufferSize)

pack-priv abstract void
pack-priv abstract void
public final boolean
isActive()

Implements javax.sound.sampled.DataLine.isActive.

Indicates whether the line is engaging in active I/O (such as playback or capture).

public final boolean
isRunning()

Implements javax.sound.sampled.DataLine.isRunning.

Indicates whether the line is running.

pack-priv final boolean
isStartedRunning()

running is true after start is called and before stop is called, regardless of whether data is actually being presented.

public final void
open(AudioFormat format, int bufferSize)

public final void
open(AudioFormat format)

public final void
open()

Implements abstract com.sun.media.sound.AbstractLine.open.

Implements javax.sound.sampled.Line.open.

Try to open the line with the current format and buffer size values.

pack-priv final void
setActive(boolean active)

This method sets the active state and generates events if it changes.

public final int
setBufferSize(int newSize)

This implementation does NOT change the buffer size

pack-priv final void
setEOM()

This method generates a STOP event and sets the started state to false.

pack-priv final void
setStarted(boolean started)

This method sets the started state and generates events if it changes.

public final void
start()

Implements javax.sound.sampled.DataLine.start.

Allows a line to engage in data I/O.

public final void
stop()

Implements javax.sound.sampled.DataLine.stop.

Stops the line.

Inherited from com.sun.media.sound.AbstractLine:
addLineListenergetControlgetControlsgetEventDispatchergetFramePositiongetLineInfogetLongFramePositiongetMixerisControlSupportedisOpenremoveLineListenersendEventssetOpen

Field Detail

activeback to summary
private volatile boolean active
bufferSizeback to summary
protected int bufferSize
defaultBufferSizeback to summary
private final int defaultBufferSize
defaultFormatback to summary
private final AudioFormat defaultFormat
formatback to summary
protected AudioFormat format
lockback to summary
protected final Object lock
runningback to summary
private volatile boolean running
startedback to summary
private volatile boolean started

Constructor Detail

AbstractDataLineback to summary
protected AbstractDataLine(DataLine.Info info, AbstractMixer mixer, Control[] controls)

Constructs a new AbstractLine.

AbstractDataLineback to summary
protected AbstractDataLine(DataLine.Info info, AbstractMixer mixer, Control[] controls, AudioFormat format, int bufferSize)

Constructs a new AbstractLine.

Method Detail

availableback to summary
public int available()

Implements javax.sound.sampled.DataLine.available.

This implementation always returns 0.

Annotations
@Override
closeback to summary
public final void close()

Implements abstract com.sun.media.sound.AbstractLine.close.

Implements javax.sound.sampled.Line.close.

This should also stop the line. The closed line should not be running or active. After we close the line, we reset the format and buffer size to the defaults.

Annotations
@Override
drainback to summary
public void drain()

Implements javax.sound.sampled.DataLine.drain.

This implementation does nothing.

Annotations
@Override
flushback to summary
public void flush()

Implements javax.sound.sampled.DataLine.flush.

This implementation does nothing.

Annotations
@Override
getBufferSizeback to summary
public final int getBufferSize()

Implements javax.sound.sampled.DataLine.getBufferSize.

Doc from javax.sound.sampled.DataLine.getBufferSize.

Obtains the maximum number of bytes of data that will fit in the data line's internal buffer. For a source data line, this is the size of the buffer to which data can be written. For a target data line, it is the size of the buffer from which data can be read. Note that the units used are bytes, but will always correspond to an integral number of sample frames of audio data.

Annotations
@Override
getFormatback to summary
public final AudioFormat getFormat()

Implements javax.sound.sampled.DataLine.getFormat.

Doc from javax.sound.sampled.DataLine.getFormat.

Obtains the current format (encoding, sample rate, number of channels, etc.) of the data line's audio data.

If the line is not open and has never been opened, it returns the default format. The default format is an implementation specific audio format, or, if the DataLine.Info object, which was used to retrieve this DataLine, specifies at least one fully qualified audio format, the last one will be used as the default format. Opening the line with a specific audio format (e.g. SourceDataLine#open(AudioFormat)) will override the default format.

Annotations
@Override
getLevelback to summary
public final float getLevel()

Implements javax.sound.sampled.DataLine.getLevel.

This implementation returns AudioSystem.NOT_SPECIFIED.

Annotations
@Override
getMicrosecondPositionback to summary
public final long getMicrosecondPosition()

Implements javax.sound.sampled.DataLine.getMicrosecondPosition.

Doc from javax.sound.sampled.DataLine.getMicrosecondPosition.

Obtains the current position in the audio data, in microseconds. The microsecond position measures the time corresponding to the number of sample frames captured by, or rendered from, the line since it was opened. The level of precision is not guaranteed. For example, an implementation might calculate the microsecond position from the current frame position and the audio sample frame rate. The precision in microseconds would then be limited to the number of microseconds per sample frame.

Annotations
@Override
implCloseback to summary
pack-priv abstract void implClose()
implOpenback to summary
pack-priv abstract void implOpen(AudioFormat format, int bufferSize) throws LineUnavailableException
implStartback to summary
pack-priv abstract void implStart()
implStopback to summary
pack-priv abstract void implStop()
isActiveback to summary
public final boolean isActive()

Implements javax.sound.sampled.DataLine.isActive.

Doc from javax.sound.sampled.DataLine.isActive.

Indicates whether the line is engaging in active I/O (such as playback or capture). When an inactive line becomes active, it sends a START event to its listeners. Similarly, when an active line becomes inactive, it sends a STOP event.

Annotations
@Override
isRunningback to summary
public final boolean isRunning()

Implements javax.sound.sampled.DataLine.isRunning.

Doc from javax.sound.sampled.DataLine.isRunning.

Indicates whether the line is running. The default is false. An open line begins running when the first data is presented in response to an invocation of the start method, and continues until presentation ceases in response to a call to stop or because playback completes.

Annotations
@Override
isStartedRunningback to summary
pack-priv final boolean isStartedRunning()

running is true after start is called and before stop is called, regardless of whether data is actually being presented.

openback to summary
public final void open(AudioFormat format, int bufferSize) throws LineUnavailableException
openback to summary
public final void open(AudioFormat format) throws LineUnavailableException
openback to summary
public final void open() throws LineUnavailableException

Implements abstract com.sun.media.sound.AbstractLine.open.

Implements javax.sound.sampled.Line.open.

Try to open the line with the current format and buffer size values. If the line is not open, these will be the defaults. If the line is open, this should return quietly because the values requested will match the current ones.

Annotations
@Override
Exceptions
LineUnavailableException:

Doc from javax.sound.sampled.Line.open.

if the line cannot be opened due to resource restrictions

setActiveback to summary
pack-priv final void setActive(boolean active)

This method sets the active state and generates events if it changes.

setBufferSizeback to summary
public final int setBufferSize(int newSize)

This implementation does NOT change the buffer size

setEOMback to summary
pack-priv final void setEOM()

This method generates a STOP event and sets the started state to false. It is here for historic reasons when an EOM event existed.

setStartedback to summary
pack-priv final void setStarted(boolean started)

This method sets the started state and generates events if it changes.

startback to summary
public final void start()

Implements javax.sound.sampled.DataLine.start.

Doc from javax.sound.sampled.DataLine.start.

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 START event is generated.

Annotations
@Override
stopback to summary
public final void stop()

Implements javax.sound.sampled.DataLine.stop.

Doc from javax.sound.sampled.DataLine.stop.

Stops the line. A stopped line should cease I/O activity. If the line is open and running, however, it should retain the resources required to resume activity. A stopped line should retain any audio data in its buffer instead of discarding it, so that upon resumption the I/O can continue where it left off, if possible. (This doesn't guarantee that there will never be discontinuities beyond the current buffer, of course; if the stopped condition continues for too long, input or output samples might be dropped.) If desired, the retained data can be discarded by invoking the flush method. When audio capture or playback stops, a STOP event is generated.

Annotations
@Override