public abstract class AudioDeviceBase extends java.lang.Object implements AudioDevice
AudioDeviceBase
class provides a simple thread-safe
implementation of the AudioDevice
interface.
Template methods are provided for subclasses to override and
in doing so provide the implementation for the main operations
of the AudioDevice
interface.Constructor and Description |
---|
AudioDeviceBase() |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this audio device.
|
protected void |
closeImpl()
Template method to provide the implementation for
closing the audio device.
|
void |
flush()
Waits for any buffered audio samples to be played by the
audio device.
|
protected void |
flushImpl()
Template method to provide the implementation for
flushing any buffered audio data.
|
protected Decoder |
getDecoder()
Retrieves the decoder that provides audio data to this
audio device.
|
boolean |
isOpen()
Determines if this audio device is open or not.
|
void |
open(Decoder decoder)
Opens this audio device.
|
protected void |
openImpl()
Template method to provide the
implementation for the opening of the audio device.
|
protected void |
setOpen(boolean open)
Sets the open state for this audio device.
|
void |
write(short[] samples,
int offs,
int len)
Writes audio data to this audio device.
|
protected void |
writeImpl(short[] samples,
int offs,
int len)
Template method to provide the implementation for
writing audio samples to the audio device.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPosition
public void open(Decoder decoder) throws JavaLayerException
open
in interface AudioDevice
decoder
- The decoder that will provide audio data
to this audio device.JavaLayerException
protected void openImpl() throws JavaLayerException
JavaLayerException
protected void setOpen(boolean open)
public boolean isOpen()
isOpen
in interface AudioDevice
true
if the audio device is open,
false
if it is not.public void close()
close
in interface AudioDevice
protected void closeImpl()
public void write(short[] samples, int offs, int len) throws JavaLayerException
write
in interface AudioDevice
samples
- The samples to write to the audio device.offs
- The offset into the array of the first sample to write.len
- The number of samples from the array to write.JavaLayerException
- if the audio data could not be
written to the audio device.
If the audio device is not open, this method does nthing.protected void writeImpl(short[] samples, int offs, int len) throws JavaLayerException
JavaLayerException
public void flush()
flush
in interface AudioDevice
protected void flushImpl()
protected Decoder getDecoder()