Package javazoom.jl.player
Interface AudioDevice
-
- All Known Implementing Classes:
AudioDeviceBase
,JavaSoundAudioDevice
,NullAudioDevice
public interface AudioDevice
TheAudioDevice
interface provides an abstraction for a device capable of sounding audio samples. Samples are written to the device wia the write() method. The device assumes that these samples are signed 16-bit samples taken at the output frequency of the decoder. If the decoder outputs more than one channel, the samples for each channel are assumed to appear consecutively, with the lower numbered channels preceeding higher-numbered channels. E.g. if there are two channels, the samples will appear in this order:l0, r0, l1, r1, l2, r2... where lx indicates the xth sample on channel 0 rx indicates the xth sample on channel 1
- Since:
- 0.0.8
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
Closes this audio device.void
flush()
Blocks until all audio samples previously written to this audio device have been heard.int
getPosition()
Retrieves the current playback position in milliseconds.boolean
isOpen()
Retrieves the open state of this audio device.void
open(Decoder decoder)
Prepares the AudioDevice for playback of audio samples.void
write(short[] samples, int offs, int len)
Writes a number of samples to thisAudioDevice
.
-
-
-
Method Detail
-
open
void open(Decoder decoder) throws JavaLayerException
Prepares the AudioDevice for playback of audio samples.- Parameters:
decoder
- The decoder that will be providing the audio samples. If the audio device is already open, this method returns silently.- Throws:
JavaLayerException
-
isOpen
boolean isOpen()
Retrieves the open state of this audio device.- Returns:
true
if this audio device is open and playing audio samples, orfalse
otherwise.
-
write
void write(short[] samples, int offs, int len) throws JavaLayerException
Writes a number of samples to thisAudioDevice
.- Parameters:
samples
- The array of signed 16-bit samples to write to the audio device.offs
- The offset of the first sample.len
- The number of samples to write. This method may return prior to the samples actually being played by the audio device.- Throws:
JavaLayerException
-
close
void close()
Closes this audio device. Any currently playing audio is stopped as soon as possible. Any previously written audio data that has not been heard is discarded. The implementation should ensure that any threads currently blocking on the device (e.g. during awrite
orflush
operation should be unblocked by this method.
-
flush
void flush()
Blocks until all audio samples previously written to this audio device have been heard.
-
getPosition
int getPosition()
Retrieves the current playback position in milliseconds.
-
-