com.cloudgarden.audio
Interface AudioSink

All Superinterfaces:
AudioObject
All Known Subinterfaces:
AudioConnector, AudioConverter
All Known Implementing Classes:
CGAudioManager, DefaultAudioSink, AudioServerSink

public interface AudioSink
extends AudioObject

An interface representing a class which accepts audio data, and which can be connected to an AudioSource.


Fields inherited from interface com.cloudgarden.audio.AudioObject
END_OF_DATA
 
Method Summary
 AudioSource getSource()
          Returns the AudioSource set by setSource
 void setSource(AudioSource source)
          Sets the source for this sink - this method should also call the setSink method on the source object (while avoiding an endless loop) to ensure that sink and source are connected to each other (and not to different sinks/sources).
 int write(byte[] data, int len)
          Convenience method - should call write(data, 0, len)
 int write(byte[] data, int offset, int len)
          Used to write data to this sink - called by the AudioSource which this sink is connected to (if its startSending method is used) so need not be called explicitly by an application.
 
Methods inherited from interface com.cloudgarden.audio.AudioObject
addTransferListener, canSetAudioFormat, drain, getAudioFormat, getContentType, isPaused, isWaiting, removeTransferListener, setAudioFormat, setContentType, setPaused
 

Method Detail

write

public int write(byte[] data,
                 int offset,
                 int len)
          throws java.io.IOException
Used to write data to this sink - called by the AudioSource which this sink is connected to (if its startSending method is used) so need not be called explicitly by an application. Blocks if this sink is paused.
See Also:
setSource(com.cloudgarden.audio.AudioSource), AudioSource.startSending(), AudioObject.setPaused(boolean)

write

public int write(byte[] data,
                 int len)
          throws java.io.IOException
Convenience method - should call write(data, 0, len)

setSource

public void setSource(AudioSource source)
               throws java.io.IOException
Sets the source for this sink - this method should also call the setSink method on the source object (while avoiding an endless loop) to ensure that sink and source are connected to each other (and not to different sinks/sources). Also ensures continuity of the AudioFormat and ContentType (as described below).

If the source's AudioFormat is null or the source's format differs from this AudioSink's format, then the source's format is set equal to that of this AudioSink.

If the source's AudioFormat is not null and this AudioSink's format is null then this AudioSink's format is set equal to the source's.

The same is done for the ContentType as described above for the AudioFormat.

See Also:
getSource()

getSource

public AudioSource getSource()
Returns the AudioSource set by setSource
See Also:
setSource(com.cloudgarden.audio.AudioSource)