Crossfire JXClient, Trunk
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
com.realtime.crossfire.jxclient.sound.ClipManager Class Reference
Collaboration diagram for com.realtime.crossfire.jxclient.sound.ClipManager:
Collaboration graph

Classes

class  AbstractTask
 
class  ClipFreeTask
 
class  ClipLoadTask
 
class  ClipPlayTask
 
class  ClipStartTask
 
class  ClipStopTask
 
interface  Task
 

Public Member Functions

 ClipManager (@NotNull final AudioFileLoader audioFileLoader, @Nullable final DebugWriter debugSound, @NotNull final SoundTaskExecutor soundTaskExecutor)
 
void play (@NotNull final CharSequence action)
 
void shutdown () throws InterruptedException
 

Private Member Functions

void playClips ()
 

Private Attributes

final ClipLoader clipLoader
 
final Semaphore concurrentClips = new Semaphore(8)
 
final DebugWriter debugSound
 
final CompletionService< @Nullable TaskexecutorCompletionService = new ExecutorCompletionService<>(executorService)
 
final ExecutorService executorService = Executors.newCachedThreadPool()
 
int nextClipId
 
final SoundTaskExecutor soundTaskExecutor
 

Detailed Description

Manages a set of sound clips (short sound effects). Multiple sound effects can be played simultaneously.

Author
Andreas Kirschbaum

Definition at line 43 of file ClipManager.java.

Constructor & Destructor Documentation

◆ ClipManager()

com.realtime.crossfire.jxclient.sound.ClipManager.ClipManager ( @NotNull final AudioFileLoader  audioFileLoader,
@Nullable final DebugWriter  debugSound,
@NotNull final SoundTaskExecutor  soundTaskExecutor 
)

Creates a new instance.

Parameters
audioFileLoaderthe audio file loader for loading audio files
debugSoundthe writer for logging sound related information or
null
to not log
soundTaskExecutorthe global sound task executor

Definition at line 94 of file ClipManager.java.

References com.realtime.crossfire.jxclient.sound.ClipManager.clipLoader, com.realtime.crossfire.jxclient.sound.ClipManager.debugSound, com.realtime.crossfire.jxclient.sound.ClipManager.executorService, and com.realtime.crossfire.jxclient.sound.ClipManager.soundTaskExecutor.

Member Function Documentation

◆ play()

void com.realtime.crossfire.jxclient.sound.ClipManager.play ( @NotNull final CharSequence  action)

Plays the given sound effect. This function returns immediately.

Parameters
actionthe action name of the sound effect

Definition at line 105 of file ClipManager.java.

References com.realtime.crossfire.jxclient.sound.ClipManager.concurrentClips, com.realtime.crossfire.jxclient.util.DebugWriter.debugProtocolWrite(), com.realtime.crossfire.jxclient.sound.ClipManager.debugSound, com.realtime.crossfire.jxclient.sound.ClipManager.executorCompletionService, and com.realtime.crossfire.jxclient.sound.ClipManager.nextClipId.

Referenced by com.realtime.crossfire.jxclient.sound.SoundManager.playClip().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ playClips()

void com.realtime.crossfire.jxclient.sound.ClipManager.playClips ( )
private

◆ shutdown()

void com.realtime.crossfire.jxclient.sound.ClipManager.shutdown ( ) throws InterruptedException

Terminates all running clips and free resources.

Exceptions
InterruptedExceptionif the current thread was interrupted while waiting for the shutdown

Definition at line 171 of file ClipManager.java.

References com.realtime.crossfire.jxclient.sound.SoundTaskExecutor.executeAndWait(), and com.realtime.crossfire.jxclient.sound.ClipManager.soundTaskExecutor.

Referenced by com.realtime.crossfire.jxclient.sound.SoundManager.shutdown().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ clipLoader

final ClipLoader com.realtime.crossfire.jxclient.sound.ClipManager.clipLoader
private

◆ concurrentClips

final Semaphore com.realtime.crossfire.jxclient.sound.ClipManager.concurrentClips = new Semaphore(8)
private

◆ debugSound

final DebugWriter com.realtime.crossfire.jxclient.sound.ClipManager.debugSound
private

◆ executorCompletionService

final CompletionService<@Nullable Task> com.realtime.crossfire.jxclient.sound.ClipManager.executorCompletionService = new ExecutorCompletionService<>(executorService)
private

Plays the scheduled sound clips as soon as they have been loaded.

Definition at line 68 of file ClipManager.java.

Referenced by com.realtime.crossfire.jxclient.sound.ClipManager.play(), and com.realtime.crossfire.jxclient.sound.ClipManager.playClips().

◆ executorService

final ExecutorService com.realtime.crossfire.jxclient.sound.ClipManager.executorService = Executors.newCachedThreadPool()
private

The executor service used to play sound clips.

Definition at line 62 of file ClipManager.java.

Referenced by com.realtime.crossfire.jxclient.sound.ClipManager.ClipManager().

◆ nextClipId

int com.realtime.crossfire.jxclient.sound.ClipManager.nextClipId
private

The ID for the next clip.

Definition at line 85 of file ClipManager.java.

Referenced by com.realtime.crossfire.jxclient.sound.ClipManager.play().

◆ soundTaskExecutor

final SoundTaskExecutor com.realtime.crossfire.jxclient.sound.ClipManager.soundTaskExecutor
private

The documentation for this class was generated from the following file: