com.realtime.crossfire.jxclient.sound
Class ClipCache

java.lang.Object
  extended by com.realtime.crossfire.jxclient.sound.ClipCache

public class ClipCache
extends java.lang.Object

Allocates new sound clips.


Field Summary
private  AudioFileLoader audioFileLoader
          The AudioFileLoader for loading audio files.
private  DebugWriter debugSound
          The writer for logging sound related information or null to not log.
 
Constructor Summary
ClipCache(AudioFileLoader audioFileLoader, DebugWriter debugSound)
          Creates a new instance.
 
Method Summary
 javax.sound.sampled.DataLine allocateClip(java.lang.String name, java.lang.String action)
          Allocates a new clip.
 void freeClip(javax.sound.sampled.Line clip)
          Deallocates a clip.
private  javax.sound.sampled.DataLine newClip(java.lang.String name, java.lang.String action)
          Allocates a new clip.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

audioFileLoader

@NotNull
private final AudioFileLoader audioFileLoader
The AudioFileLoader for loading audio files.


debugSound

@Nullable
private final DebugWriter debugSound
The writer for logging sound related information or null to not log.

Constructor Detail

ClipCache

public ClipCache(@NotNull
                 AudioFileLoader audioFileLoader,
                 @Nullable
                 DebugWriter debugSound)
Creates a new instance.

Parameters:
audioFileLoader - the audio file loader for loading audio files
debugSound - the writer for logging sound related information or null to not log
Method Detail

allocateClip

@Nullable
public javax.sound.sampled.DataLine allocateClip(@Nullable
                                                          java.lang.String name,
                                                          @NotNull
                                                          java.lang.String action)
Allocates a new clip.

Parameters:
name - an optional prefix for the action name
action - the action name of the clip to allocate
Returns:
the new clip, or null if an error occurs

freeClip

public void freeClip(@NotNull
                     javax.sound.sampled.Line clip)
Deallocates a clip.

Parameters:
clip - the clip to deallocate

newClip

@Nullable
private javax.sound.sampled.DataLine newClip(@Nullable
                                                      java.lang.String name,
                                                      @NotNull
                                                      java.lang.String action)
Allocates a new clip.

Parameters:
name - an optional prefix for the action name
action - the action name of the clip to allocate
Returns:
the new clip, or null if an error occurs