com.threerings.openal
Class OpenALSoundPlayer

java.lang.Object
  extended by com.threerings.media.sound.SoundPlayer
      extended by com.threerings.openal.OpenALSoundPlayer
All Implemented Interfaces:
ClipProvider

public class OpenALSoundPlayer
extends SoundPlayer
implements ClipProvider

Implements the abstract pieces of SoundPlayer via OpenAL.


Nested Class Summary
protected  class OpenALSoundPlayer.MediaALSoundManager
          Extends sound manager to allow sounds to be pulled out of the locked map.
protected  class OpenALSoundPlayer.SoundGrabber
          Loads a sound in its run method and calls subclasses with soundLoaded to let them know it's ready.
protected  class OpenALSoundPlayer.TickingQueue
          Updates the sound manager's streams every STREAM_UPDATE_INTERVAL and processes sound runnables added to its queue.
 
Nested classes/interfaces inherited from class com.threerings.media.sound.SoundPlayer
SoundPlayer.Frob, SoundPlayer.SoundType
 
Field Summary
protected  SoundManager _alSoundManager
           
protected  SoundGroup _group
           
protected  SoundLoader _loader
           
protected  Map<String,ClipBuffer> _locked
           
protected  OpenALSoundPlayer.TickingQueue _ticker
           
protected  int SOURCE_COUNT
          Number of sounds that can be played simultaneously.
protected static int STREAM_UPDATE_INTERVAL
          Number of milliseconds to wait between stream updates.
 
Fields inherited from class com.threerings.media.sound.SoundPlayer
_clipVol, _disabledTypes, _enabledObservers, DEFAULT, PAN_CENTER, PAN_LEFT, PAN_RIGHT
 
Constructor Summary
OpenALSoundPlayer(SoundLoader loader)
           
 
Method Summary
protected  SoundManager createSoundManager()
          Creates our SoundManager.
protected  String[] getPaths(String pkgPath, String key)
          Returns bundle:path for all sounds under key in pkgPath.
 SoundLoader getSoundLoader()
          Returns the loader used by this player.
 RunQueue getSoundQueue()
          Gets the run queue on which sound should be played.
 Clip loadClip(String path)
          Loads the specified clip from the appropriate source.
 void lock(String pkgPath, String... keys)
          Optionally lock each of these keys prior to playing, to guarantee that it will be quickly available for playing.
 SoundPlayer.Frob loop(SoundPlayer.SoundType type, String pkgPath, String key, float gain, float[] pos)
           
 SoundPlayer.Frob loop(String pkgPath, String key, float pan)
          Loop the specified sound, stopping as quickly as possible when stop is called.
 SoundPlayer.Frob loop(String pkgPath, String key, float pan, float gain)
           
 boolean play(SoundPlayer.SoundType type, String pkgPath, String key, float gain, float[] pos)
           
 void play(String pkgPath, String key, float pan)
          Play the specified sound after the specified delay.
 void play(String pkgPath, String key, float pan, float gain)
           
 void setClipVolume(float vol)
          Sets the volume for all sound clips.
 void shutdown()
          Shut the damn thing off.
 void stream(String bundle, String path, boolean loop, ResultListener<Stream> listener)
          Streams ogg files from the given bundle and path.
 void unlock(String pkgPath, String... keys)
          Unlock the specified sounds so that its resources can be freed.
 
Methods inherited from class com.threerings.media.sound.SoundPlayer
addSoundEnabledObserver, getClipVolume, isEnabled, loop, loop, play, play, play, play, removeSoundEnabledObserver, setEnabled, shouldPlay, summarizeState
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

STREAM_UPDATE_INTERVAL

protected static final int STREAM_UPDATE_INTERVAL
Number of milliseconds to wait between stream updates.

See Also:
Constant Field Values

_ticker

protected OpenALSoundPlayer.TickingQueue _ticker

_locked

protected Map<String,ClipBuffer> _locked

_loader

protected SoundLoader _loader

_group

protected SoundGroup _group

_alSoundManager

protected SoundManager _alSoundManager

SOURCE_COUNT

protected final int SOURCE_COUNT
Number of sounds that can be played simultaneously.

See Also:
Constant Field Values
Constructor Detail

OpenALSoundPlayer

public OpenALSoundPlayer(SoundLoader loader)
Method Detail

loadClip

public Clip loadClip(String path)
              throws IOException
Description copied from interface: ClipProvider
Loads the specified clip from the appropriate source.

Specified by:
loadClip in interface ClipProvider
Throws:
IOException

getSoundLoader

public SoundLoader getSoundLoader()
Returns the loader used by this player.


getSoundQueue

public RunQueue getSoundQueue()
Description copied from class: SoundPlayer
Gets the run queue on which sound should be played. It defaults to RunQueue.AWT.

Specified by:
getSoundQueue in class SoundPlayer

setClipVolume

public void setClipVolume(float vol)
Description copied from class: SoundPlayer
Sets the volume for all sound clips.

Overrides:
setClipVolume in class SoundPlayer
Parameters:
vol - a volume parameter between 0f and 1f, inclusive.

lock

public void lock(String pkgPath,
                 String... keys)
Description copied from class: SoundPlayer
Optionally lock each of these keys prior to playing, to guarantee that it will be quickly available for playing.

Specified by:
lock in class SoundPlayer

unlock

public void unlock(String pkgPath,
                   String... keys)
Description copied from class: SoundPlayer
Unlock the specified sounds so that its resources can be freed.

Specified by:
unlock in class SoundPlayer

stream

public void stream(String bundle,
                   String path,
                   boolean loop,
                   ResultListener<Stream> listener)
            throws IOException
Streams ogg files from the given bundle and path.

Throws:
IOException

loop

public SoundPlayer.Frob loop(String pkgPath,
                             String key,
                             float pan)
Description copied from class: SoundPlayer
Loop the specified sound, stopping as quickly as possible when stop is called.

Specified by:
loop in class SoundPlayer

loop

public SoundPlayer.Frob loop(String pkgPath,
                             String key,
                             float pan,
                             float gain)

loop

public SoundPlayer.Frob loop(SoundPlayer.SoundType type,
                             String pkgPath,
                             String key,
                             float gain,
                             float[] pos)

play

public void play(String pkgPath,
                 String key,
                 float pan)
Description copied from class: SoundPlayer
Play the specified sound after the specified delay.

Specified by:
play in class SoundPlayer
pan - a value from -1f (all left) to +1f (all right).

play

public void play(String pkgPath,
                 String key,
                 float pan,
                 float gain)

play

public boolean play(SoundPlayer.SoundType type,
                    String pkgPath,
                    String key,
                    float gain,
                    float[] pos)

shutdown

public void shutdown()
Description copied from class: SoundPlayer
Shut the damn thing off.

Specified by:
shutdown in class SoundPlayer

getPaths

protected String[] getPaths(String pkgPath,
                            String key)
Returns bundle:path for all sounds under key in pkgPath.


createSoundManager

protected SoundManager createSoundManager()
Creates our SoundManager.