 |
Crossfire JXClient, Trunk
|
Go to the documentation of this file.
23 package com.realtime.crossfire.jxclient.sound;
26 import java.util.concurrent.Callable;
27 import java.util.concurrent.CompletionService;
28 import java.util.concurrent.ExecutionException;
29 import java.util.concurrent.ExecutorCompletionService;
30 import java.util.concurrent.ExecutorService;
31 import java.util.concurrent.Executors;
32 import java.util.concurrent.Future;
33 import java.util.concurrent.Semaphore;
34 import javax.sound.sampled.DataLine;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
105 public void play(@NotNull
final CharSequence action) {
125 while (!Thread.currentThread().isInterrupted()) {
126 final Future<@Nullable Task> future;
129 }
catch (
final InterruptedException ignored) {
130 Thread.currentThread().interrupt();
137 }
catch (
final InterruptedException ex) {
138 Thread.currentThread().interrupt();
143 }
catch (
final ExecutionException ex) {
171 public void shutdown() throws InterruptedException {
197 private final int id;
219 subId = parent.subId+1;
225 return id+
"."+
subId+
"/"+getClass().getSimpleName();
258 final long t0 = System.currentTimeMillis();
409 final long t0 = System.currentTimeMillis();
final ExecutorService executorService
The executor service used to play sound clips.
final Semaphore concurrentClips
Counts the number of concurrently active sound clips.
final DataLine clip
The clip to play.
ClipPlayTask(@NotNull final AbstractTask parent, @NotNull final DataLine clip)
Creates a new instance.
final CompletionService< @Nullable Task > executorCompletionService
Plays the scheduled sound clips as soon as they have been loaded.
void freeClip(@NotNull final Line clip)
Deallocates a clip.
void executeAndWait(@NotNull final Runnable task)
Schedules a task for execution.
Stops playing a sound clip.
Abstract base class for Task implementations.
final CharSequence action
The action name of the sound effect to play.
Callable< @Nullable Task > getCallable()
Returns the next step to play.
void playClips()
Plays the scheduled sound clips.
DataLine allocateClip(@NotNull final CharSequence action)
Allocates a new clip.
void shutdown()
Terminates all running clips and free resources.
Allocates new sound clips.
A step while playing a sound clip.
Callable< @NotNull Task > getCallable()
Returns the next step to play.
int nextClipId
The ID for the next clip.
Manages a set of sound clips (short sound effects).
void debugProtocolWrite(@NotNull final CharSequence str)
Writes a message to the debug protocol.
final DataLine clip
The clip to play.
AbstractTask(@NotNull final AbstractTask parent)
Creates a new instance.
AbstractTask(final int id)
Creates a new instance.
Callable< @Nullable Task > getCallable()
Returns the next step to play.
ClipLoadTask(final int id, @NotNull final CharSequence action)
Creates a new instance.
final int id
The sound clip ID for debug messages.
void play(@NotNull final CharSequence action)
Plays the given sound effect.
ClipStartTask(@NotNull final AbstractTask parent, @NotNull final DataLine clip)
Creates a new instance.
Executes non-blocking tasks for sound-related functions.
Callable< @NotNull Task > getCallable()
Returns the next step to play.
final int subId
The secondary ID for debug messages.
Callable< @Nullable Task > getCallable()
Returns the next step to play.
ClipFreeTask(@NotNull final AbstractTask parent, @NotNull final DataLine clip)
Creates a new instance.
final DataLine clip
The clip to play.
final ClipLoader clipLoader
The clip loader used to load clips.
Writer debug information to a log file.
ClipStopTask(@NotNull final AbstractTask parent, @NotNull final DataLine clip)
Creates a new instance.
Waits until a sound clip has finished.
Starts to play a sound clip.
Callable< @NotNull Task > getCallable()
Returns the next step to play.
final SoundTaskExecutor soundTaskExecutor
The global SoundTaskExecutor instance.
ClipManager(@NotNull final AudioFileLoader audioFileLoader, @Nullable final DebugWriter debugSound, @NotNull final SoundTaskExecutor soundTaskExecutor)
Creates a new instance.
final DebugWriter debugSound
The writer for logging sound related information or.
final DataLine clip
The clip to play.