|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.cloudgarden.audio.DefaultAudioObject | +--com.cloudgarden.audio.DefaultAudioSource
The base class which implements all the functionality of a generic AudioSource except the read method.
Field Summary | |
protected boolean |
sending
|
protected java.lang.Thread |
sendThread
|
protected AudioSink |
sink
|
Fields inherited from class com.cloudgarden.audio.DefaultAudioObject |
contentType, exception, format, listeners, paused, pauseSync, running, waiting |
Fields inherited from interface com.cloudgarden.audio.AudioObject |
END_OF_DATA |
Constructor Summary | |
DefaultAudioSource()
Creates new AudioSource |
Method Summary | |
void |
drain()
Blocks until END_OF_DATA is written to or read from this AudioObject. |
AudioSink |
getSink()
Returns the AudioSink set using setSink |
boolean |
isSending()
Returns true if the thread started by the startSending method is still writing data to the AudioSink. |
int |
read(byte[] data,
int len)
Convenience method - should call read(data, 0, len) |
void |
setAudioFormat(javax.sound.sampled.AudioFormat format)
Sets the AudioFormat for this AudioObject. |
void |
setBufferSize(int size)
|
void |
setContentType(java.lang.String contentType)
Sets the content type for this AudioObject - contentType must be one of the FileTypeDescriptor String fields, eg MPEG_AUDIO. |
void |
setSink(AudioSink sink)
Sets the sink for this source - this method should also call the setSource method on the sink object (making sure to avaoid an endless loop) to ensure that source and sink are connected to each other (and not to different sinks/sources). |
void |
startSending()
This method should start a thread which repeatedly writes data to the AudioSink object which this object is connected to, until it writes data with length END_OF_DATA, or until the stopSending method is called. |
void |
stopSending()
|
Methods inherited from class com.cloudgarden.audio.DefaultAudioObject |
addTransferListener, blockWhilePaused, blockWhileWaiting, bytesTransferred, canSetAudioFormat, getAudioFormat, getContentType, getLastException, isPaused, isWaiting, removeTransferListener, setPaused |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.cloudgarden.audio.AudioSource |
read |
Methods inherited from interface com.cloudgarden.audio.AudioObject |
addTransferListener, canSetAudioFormat, getAudioFormat, getContentType, isPaused, isWaiting, removeTransferListener, setPaused |
Field Detail |
protected java.lang.Thread sendThread
protected boolean sending
protected AudioSink sink
Constructor Detail |
public DefaultAudioSource()
Method Detail |
public boolean isSending()
AudioSource
isSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.startSending()
public void setBufferSize(int size)
public int read(byte[] data, int len) throws java.io.IOException
AudioSource
read
in interface AudioSource
public void startSending() throws java.io.IOException
AudioSource
startSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
an
- IOException if the source is unable to start sending data - for example,
if an audio file is unable to be opened to supply the data to be sent.AudioSource.setSink(com.cloudgarden.audio.AudioSink)
,
AudioObject.drain()
public void stopSending()
stopSending
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.startSending()
public void setSink(AudioSink sink) throws java.io.IOException
AudioSource
If the sink's AudioFormat is null or the sink's format differs from this AudioSource's format, then the sink's format is set equal to that of this AudioSource.
If the sink's AudioFormat is not null and this AudioSource's format is null then this AudioSource's format is set equal to the sink's.
The same is done for the ContentType as described above for the AudioFormat.
Note: if the sink is an AudioConverter then the get/setIncomingAudioFormat method is called instead of get/setAudioFormat.
setSink
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.getSink()
public void setAudioFormat(javax.sound.sampled.AudioFormat format) throws java.io.IOException
AudioObject
This ensures that the AudioFormat is uniform along a set of connected AudioObjects until the format is changed by an AudioConverter.
setAudioFormat
in interface AudioObject
setAudioFormat
in class DefaultAudioObject
com.cloudgarden.audio.AudioObject
java.io.IOException
- if unable to set the AudioFormat for any reason
(eg. if canSetAudioFormat returns false and setAudioFormat is used
to try to change the AudioFormat).AudioObject.getAudioFormat()
public void setContentType(java.lang.String contentType) throws java.io.IOException
AudioObject
setContentType
in interface AudioObject
setContentType
in class DefaultAudioObject
public AudioSink getSink()
AudioSource
getSink
in interface AudioSource
com.cloudgarden.audio.AudioSource
AudioSource.setSink(com.cloudgarden.audio.AudioSink)
public void drain() throws java.io.IOException
AudioObject
drain
in interface AudioObject
drain
in class DefaultAudioObject
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |