at.tuwien.ifs.somtoolbox.apps.viewer.controls.multichannelPlayback
Class PlaybackThread

java.lang.Object
  extended by java.lang.Thread
      extended by at.tuwien.ifs.somtoolbox.apps.viewer.controls.multichannelPlayback.PlaybackThread
All Implemented Interfaces:
Runnable

public class PlaybackThread
extends Thread

Represents two nodes / one output line

Version:
$Id: PlaybackThread.java 3590 2010-05-21 10:43:45Z mayer $
Author:
Ewald Peiszer

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
(package private)  boolean[] aEmpty
          Flag if channel is empty: in this case, there will be silence on the respective channel
(package private)  File[][] aFiles
          Files to play
protected  AudioInputStream[] ain
           
(package private)  Point[] aPos
           
(package private)  boolean[] aWaitForDecoder
          Flag: if true, then the respective channel is waiting for a DecoderThread to finish.
(package private)  boolean bOtherChannelAlreadyFinished
          (if bRepeat == false): if the first channel's musicfile stops, it is set to true.
protected  boolean bQuitLoop
           
(package private)  boolean bRepeat_Shuffle
          Flag: if true, then music is played endlessly, alwas repeating.
protected  byte[][] buffer
           
(package private)  boolean bUpdStats
          Flag: if false, no global statistic variable will be updated by this Thread
protected  byte[] datalinebuffer
           
protected  int datalineframesize
           
protected  File file1
           
protected  File file2
           
(package private)  String id
           
protected  SourceDataLine line
           
protected  int monoframesize
           
(package private)  float p_decode
          Probability to decode a mp3 file to wav
protected  boolean ready
           
private  boolean threadSuspended
           
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
PlaybackThread(String id, TPlaybackThreadDataRecord record, SourceDataLine line)
          Convenience constructur that takes a TPlaybackThreadDataRecord and pulls all data from it to create a new thread
PlaybackThread(String id, TPlaybackThreadDataRecord record, SourceDataLine line, boolean bRepeat, float p_decode)
           
PlaybackThread(String id, TPlaybackThreadDataRecord record, SourceDataLine line, boolean bRepeat, float p_decode, boolean bUpdStats)
           
 
Method Summary
 void decodingFailed(int channel, boolean stats)
           
 void decodingFinished(File file, int channel, boolean stats, DecoderThread dt)
           
 AudioInputStream getNextSong(int channel, boolean stats)
           
protected  void log_fine(String msg)
           
protected  void log_info(String msg)
           
protected  void log_warning(String msg)
           
 void muteChannel(int channel)
           
 void pause_playback()
           
 AudioInputStream prepareAin(File file, int channel, boolean stats)
           
 void resume_playback()
           
 void run()
           
 void stop_playback()
           
 void unmuteChannel(int channel)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

id

String id

aPos

Point[] aPos

aFiles

File[][] aFiles
Files to play


aEmpty

boolean[] aEmpty
Flag if channel is empty: in this case, there will be silence on the respective channel


aWaitForDecoder

boolean[] aWaitForDecoder
Flag: if true, then the respective channel is waiting for a DecoderThread to finish.


bRepeat_Shuffle

boolean bRepeat_Shuffle
Flag: if true, then music is played endlessly, alwas repeating. Songs are picked in random order.

If false, then on each channel there will be played each song in the list, from the first to the last, then exit.


bUpdStats

boolean bUpdStats
Flag: if false, no global statistic variable will be updated by this Thread


p_decode

float p_decode
Probability to decode a mp3 file to wav


bOtherChannelAlreadyFinished

boolean bOtherChannelAlreadyFinished
(if bRepeat == false): if the first channel's musicfile stops, it is set to true.

If the second channel's musicfile stops, this thread is stopped.


threadSuspended

private boolean threadSuspended

file1

protected File file1

file2

protected File file2

line

protected SourceDataLine line

ain

protected AudioInputStream[] ain

ready

protected boolean ready

bQuitLoop

protected boolean bQuitLoop

datalineframesize

protected int datalineframesize

monoframesize

protected int monoframesize

buffer

protected byte[][] buffer

datalinebuffer

protected byte[] datalinebuffer
Constructor Detail

PlaybackThread

public PlaybackThread(String id,
                      TPlaybackThreadDataRecord record,
                      SourceDataLine line,
                      boolean bRepeat,
                      float p_decode,
                      boolean bUpdStats)

PlaybackThread

public PlaybackThread(String id,
                      TPlaybackThreadDataRecord record,
                      SourceDataLine line,
                      boolean bRepeat,
                      float p_decode)

PlaybackThread

public PlaybackThread(String id,
                      TPlaybackThreadDataRecord record,
                      SourceDataLine line)
Convenience constructur that takes a TPlaybackThreadDataRecord and pulls all data from it to create a new thread

Note the constructor call that looks quite crazy with all its necessary casts.

Method Detail

muteChannel

public void muteChannel(int channel)

unmuteChannel

public void unmuteChannel(int channel)

getNextSong

public AudioInputStream getNextSong(int channel,
                                    boolean stats)
                             throws IOException,
                                    UnsupportedAudioFileException
Throws:
IOException
UnsupportedAudioFileException

prepareAin

public AudioInputStream prepareAin(File file,
                                   int channel,
                                   boolean stats)
                            throws IOException,
                                   UnsupportedAudioFileException
Throws:
IOException
UnsupportedAudioFileException

decodingFinished

public void decodingFinished(File file,
                             int channel,
                             boolean stats,
                             DecoderThread dt)

decodingFailed

public void decodingFailed(int channel,
                           boolean stats)

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

stop_playback

public void stop_playback()

pause_playback

public void pause_playback()

resume_playback

public void resume_playback()

log_fine

protected void log_fine(String msg)

log_info

protected void log_info(String msg)

log_warning

protected void log_warning(String msg)