com.groovemanager.spi.rex
Class REXFileReader

java.lang.Object
  extended by javax.sound.sampled.spi.AudioFileReader
      extended by com.groovemanager.spi.rex.REXFileReader

public class REXFileReader
extends javax.sound.sampled.spi.AudioFileReader

This implementation of the AudioFileReader SPI provides access to Recycle files such as REX/REX2/RX2/RCY. The files have to be provided as files because the REX API Doesn´t allow reading audio data from streams or URLs. Also - because the files always have to be loaded completely into memory, there is a maximum file size limit used by this provider. It is assumed that a file bigger than 4 MB won´t be a REX file.

Author:
Manu Robledo

Field Summary
(package private) static boolean dllLoaded
          Indicates whether the REX dll has already been loaded by this VM
(package private) static java.lang.String LIB_NAME
          The name of the jsrex library
(package private) static java.lang.String LIB_VERSION
          The version of the jsrex library version
 
Constructor Summary
REXFileReader()
           
 
Method Summary
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
          The AufdioFileFormat returned by this method will contain some additional information as properties.
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
          The REX API requires a full file to be loaded into memory for being able to get the AudioFileFormat out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown
 javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
          The REX API requires a full file to be loaded into memory for being able to get the AudioFileFormat out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
          Note that REX files bigger than 4 MB are not supported they will always have to be loaded into memory completely and REX files are usually much smaller than 1 MB.
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
          The REX API requires a full file to be loaded into memory for being able to get an AudioInputStream out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown
 javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
          The REX API requires a full file to be loaded into memory for being able to get an AudioInputStream out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown
(package private) static java.lang.String getLibName()
          Get the full library name to be loaded
private static int jREXLoadDLL()
           
private static void jREXUnloadDLL()
           
(package private) static void REXLoadDll()
          Load the REX dll only if it has not already been loaded by this VM instance.
(package private) static void REXUnloadDLL()
          Unload the REX dll
(package private) static void throwREXError(int code)
          Just a delegator to REXError.throwREXError()
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dllLoaded

static boolean dllLoaded
Indicates whether the REX dll has already been loaded by this VM


LIB_NAME

static final java.lang.String LIB_NAME
The name of the jsrex library

See Also:
Constant Field Values

LIB_VERSION

static final java.lang.String LIB_VERSION
The version of the jsrex library version

See Also:
Constant Field Values
Constructor Detail

REXFileReader

public REXFileReader()
Method Detail

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.File file)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
The AufdioFileFormat returned by this method will contain some additional information as properties. See REXAudioFileFormat for more details. Note that REX files bigger than 4 MB are not supported they will always have to be loaded into memory completely and REX files are usually much smaller than 1 MB.

Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioFileFormat(java.io.File), REXAudioFileFormat

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.io.InputStream stream)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
The REX API requires a full file to be loaded into memory for being able to get the AudioFileFormat out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown

Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioFileFormat(java.io.InputStream)

getAudioFileFormat

public javax.sound.sampled.AudioFileFormat getAudioFileFormat(java.net.URL url)
                                                       throws javax.sound.sampled.UnsupportedAudioFileException,
                                                              java.io.IOException
The REX API requires a full file to be loaded into memory for being able to get the AudioFileFormat out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown

Specified by:
getAudioFileFormat in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioFileFormat(java.net.URL)

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.File file)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
Note that REX files bigger than 4 MB are not supported they will always have to be loaded into memory completely and REX files are usually much smaller than 1 MB.

Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioInputStream(java.io.File)

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.io.InputStream stream)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
The REX API requires a full file to be loaded into memory for being able to get an AudioInputStream out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown

Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioInputStream(java.io.InputStream)

getAudioInputStream

public javax.sound.sampled.AudioInputStream getAudioInputStream(java.net.URL url)
                                                         throws javax.sound.sampled.UnsupportedAudioFileException,
                                                                java.io.IOException
The REX API requires a full file to be loaded into memory for being able to get an AudioInputStream out of it so a call to this method will always result in an UnsupportedAudioFileException being thrown

Specified by:
getAudioInputStream in class javax.sound.sampled.spi.AudioFileReader
Throws:
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
See Also:
AudioFileReader.getAudioInputStream(java.net.URL)

getLibName

static java.lang.String getLibName()
Get the full library name to be loaded

Returns:
The library name consisting of LIB_NAME + "_" + LIB_VERSION

jREXLoadDLL

private static int jREXLoadDLL()

jREXUnloadDLL

private static void jREXUnloadDLL()

REXLoadDll

static void REXLoadDll()
                throws REXError
Load the REX dll only if it has not already been loaded by this VM instance.

Throws:
REXError - If a REXError occured

REXUnloadDLL

static void REXUnloadDLL()
Unload the REX dll


throwREXError

static void throwREXError(int code)
                   throws REXError
Just a delegator to REXError.throwREXError()

Parameters:
code - The REXError constant
Throws:
REXError - If the given constant is not the same as REXError.NoError