org.qtunes.speaker
Interface Speaker

All Superinterfaces:
Service
All Known Implementing Classes:
SpeakerImpl, SpeakerImpl, SpeakerImpl

public interface Speaker
extends Service

A Speaker is an output device, which may be a local JavaSound speaker, an Airtunes speaker, a network speaker or similar. A Player has one or more speakers and a Speaker may be assigned to exactly one Player, or unassigned. Writing to a Speaker should never throw an Exception of any sort - instead the internal Exception should be set. This is reset when the Speaker is opened.


Method Summary
 void close()
          Close the speaker, immediately stopping it and discarding any data.
 void drain()
          Block until the data already written to the speaker completes If it fails, set the error.
 void flush()
          Immediately stop the speaker and discard any cached data written to it If it fails, set the error.
 int getBufferSize()
          Return the size of the speaker buffer in bytes.
 int getDelay()
          Return the number of ms delay for this speaker, between a packet being written and it being heard
 java.lang.String getDisplayName()
          Return a nice name for the Speaker for display to the user
 java.lang.Exception getError()
          If this speaker has failed for some reason, return the Exception.
 Player getPlayer()
          Get the Player currently assigned to this speaker
 int getUniqueId()
          Return a unique ID for the speaker
 int getVolumeAdjustment()
          Get the volume adjustment that applies to this speaker (+ve or -ve, 0 for no adjustment
 boolean hasGain()
          Returns true if this speaker can have its gain adjusted
 boolean isOpen()
          True after open has been called, false after close has been called
 void open(float sampleRate, int sampleSizeInBits, int channels, boolean signed, boolean bigEndian)
          Open the Speaker and start it.
 void setGain(float gain)
          Set the gain of this speaker.
 void setPlayer(Player player)
          Set the player for the speaker.
 void setVolumeAdjustment(int volumeadjust)
          Set the volume adjustment that applies to this speaker, which should be be added to the gain for this speaker.
 void write(byte[] buf, int off, int len)
          Write data to the speaker.
 
Methods inherited from interface org.qtunes.core.Service
getContext, reportState, startService, stopService
 

Method Detail

getDelay

int getDelay()
Return the number of ms delay for this speaker, between a packet being written and it being heard


getBufferSize

int getBufferSize()
Return the size of the speaker buffer in bytes.


getDisplayName

java.lang.String getDisplayName()
Return a nice name for the Speaker for display to the user


getUniqueId

int getUniqueId()
Return a unique ID for the speaker


hasGain

boolean hasGain()
Returns true if this speaker can have its gain adjusted


setGain

void setGain(float gain)
Set the gain of this speaker. A value of NaN means "no audio". If this method fails, set the Error.


setPlayer

void setPlayer(Player player)
Set the player for the speaker. This method should call Player.removeSpeaker(org.qtunes.speaker.Speaker) on the old player and Player.addSpeaker(org.qtunes.speaker.Speaker) on the new one, and anyone moving speakers between players should call this method rather than those methods directly.


getPlayer

Player getPlayer()
Get the Player currently assigned to this speaker


getError

java.lang.Exception getError()
If this speaker has failed for some reason, return the Exception. Otherwise return null.


getVolumeAdjustment

int getVolumeAdjustment()
Get the volume adjustment that applies to this speaker (+ve or -ve, 0 for no adjustment


setVolumeAdjustment

void setVolumeAdjustment(int volumeadjust)
Set the volume adjustment that applies to this speaker, which should be be added to the gain for this speaker.


open

void open(float sampleRate,
          int sampleSizeInBits,
          int channels,
          boolean signed,
          boolean bigEndian)
Open the Speaker and start it. Reset any error that may have been set.


write

void write(byte[] buf,
           int off,
           int len)
Write data to the speaker. If it fails, set the error


flush

void flush()
Immediately stop the speaker and discard any cached data written to it If it fails, set the error.


drain

void drain()
Block until the data already written to the speaker completes If it fails, set the error.


close

void close()
Close the speaker, immediately stopping it and discarding any data. Does not throw exception or fail.


isOpen

boolean isOpen()
True after open has been called, false after close has been called