APIdia Launch Partner
Top Description Constructors Methods
com.sun.media.sound

pack-priv abstract Class SunFileReader

extends AudioFileReader
Class Inheritance
Known Direct Subclasses
com.sun.media.sound.WaveExtensibleFileReader, com.sun.media.sound.WaveFileReader, com.sun.media.sound.WaveFloatFileReader, com.sun.media.sound.AiffFileReader, com.sun.media.sound.AuFileReader, com.sun.media.sound.SoftMidiAudioFileReader
Imports
java.io.BufferedInputStream, .DataInputStream, .EOFException, .File, .FileInputStream, .IOException, .InputStream, java.net.URL, javax.sound.sampled.AudioFileFormat, .AudioInputStream, .UnsupportedAudioFileException, javax.sound.sampled.spi.AudioFileReader

Abstract File Reader class.
Author
Jan Borgersen

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
pack-priv final int

Returns:

32 bits swapped value
big2little
(int i)

big2little Protected helper method to swap the order of bytes in a 32 bit int

pack-priv final short

Returns:

16 bits swapped value
big2littleShort
(short i)

big2little Protected helper method to swap the order of bytes in a 16 bit short

pack-priv static final int

Returns:

the size of a PCM frame in bytes.
calculatePCMFrameSize
(int
the size of a single sample in bits
sampleSizeInBits
,
int
the number of channels
channels
)

Calculates the frame size for PCM frames.

private static void
closeSilently(final InputStream
the InputStream which should be closed
is
)

Closes the InputStream when we have read all necessary data from it, and ignores an IOException.

public final StandardFileFormat
getAudioFileFormat(final InputStream stream)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the input stream provided.

public final AudioFileFormat
getAudioFileFormat(final URL url)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the URL provided.

public final AudioFileFormat
getAudioFileFormat(final File file)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the File provided.

pack-priv abstract StandardFileFormat

Returns:

an AudioFileFormat object describing the audio file format
getAudioFileFormatImpl
(InputStream
the input stream from which file format information should be extracted
stream
)

Obtains the audio file format of the input stream provided.

public AudioInputStream
getAudioInputStream(final InputStream stream)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the input stream provided.

public final AudioInputStream
getAudioInputStream(final URL url)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the URL provided.

public final AudioInputStream
getAudioInputStream(final File file)

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the File provided.

pack-priv final int

Returns:

32 bits swapped value.
rllong
(DataInputStream dis)

rllong Protected helper method to read 64 bits and changing the order of each bytes.

pack-priv final short

Returns:

the swapped value.
rlshort
(DataInputStream dis)

rlshort Protected helper method to read 16 bits value.

Constructor Detail

SunFileReaderback to summary
pack-priv SunFileReader()

Method Detail

big2littleback to summary
pack-priv final int big2little(int i)

big2little Protected helper method to swap the order of bytes in a 32 bit int

Returns:int

32 bits swapped value

big2littleShortback to summary
pack-priv final short big2littleShort(short i)

big2little Protected helper method to swap the order of bytes in a 16 bit short

Returns:short

16 bits swapped value

calculatePCMFrameSizeback to summary
pack-priv static final int calculatePCMFrameSize(int sampleSizeInBits, int channels)

Calculates the frame size for PCM frames. Note that this method is appropriate for non-packed samples. For instance, 12 bit, 2 channels will return 4 bytes, not 3.

Parameters
sampleSizeInBits:int

the size of a single sample in bits

channels:int

the number of channels

Returns:int

the size of a PCM frame in bytes.

closeSilentlyback to summary
private static void closeSilently(final InputStream is)

Closes the InputStream when we have read all necessary data from it, and ignores an IOException.

Parameters
is:InputStream

the InputStream which should be closed

getAudioFileFormatback to summary
public final StandardFileFormat getAudioFileFormat(final InputStream stream) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the input stream provided. The stream must point to valid audio file data. In general, audio file readers may need to read some data from the stream before determining whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and reset the stream's read pointer to its original position. If the input stream does not support this, this method may fail with an IOException.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the stream does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
getAudioFileFormatback to summary
public final AudioFileFormat getAudioFileFormat(final URL url) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the URL provided. The URL must point to valid audio file data.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the URL does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
getAudioFileFormatback to summary
public final AudioFileFormat getAudioFileFormat(final File file) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioFileFormat.

Obtains the audio file format of the File provided. The File must point to valid audio file data.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the File does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
getAudioFileFormatImplback to summary
pack-priv abstract StandardFileFormat getAudioFileFormatImpl(InputStream stream) throws UnsupportedAudioFileException, IOException

Obtains the audio file format of the input stream provided. The stream must point to valid audio file data. Note that default implementation of getAudioInputStream(InputStream) assume that this method leaves the input stream at the beginning of the audio data.

Parameters
stream:InputStream

the input stream from which file format information should be extracted

Returns:StandardFileFormat

an AudioFileFormat object describing the audio file format

Exceptions
UnsupportedAudioFileException:
if the stream does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
EOFException:
is used incorrectly by our readers instead of UnsupportedAudioFileException if the header is less than was expected
getAudioInputStreamback to summary
public AudioInputStream getAudioInputStream(final InputStream stream) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the input stream provided. The stream must point to valid audio file data. In general, audio file readers may need to read some data from the stream before determining whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and reset the stream's read pointer to its original position. If the input stream does not support this, this method may fail with an IOException.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the stream does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
getAudioInputStreamback to summary
public final AudioInputStream getAudioInputStream(final URL url) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the URL does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
getAudioInputStreamback to summary
public final AudioInputStream getAudioInputStream(final File file) throws UnsupportedAudioFileException, IOException

Implements abstract javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Doc from javax.sound.sampled.spi.AudioFileReader.getAudioInputStream.

Obtains an audio input stream from the File provided. The File must point to valid audio file data.

Annotations
@Override
Exceptions
UnsupportedAudioFileException:
if the File does not point to valid audio file data recognized by the system
IOException:
if an I/O exception occurs
rllongback to summary
pack-priv final int rllong(DataInputStream dis) throws IOException

rllong Protected helper method to read 64 bits and changing the order of each bytes.

Returns:int

32 bits swapped value.

rlshortback to summary
pack-priv final short rlshort(DataInputStream dis) throws IOException

rlshort Protected helper method to read 16 bits value. Swap high with low byte.

Returns:short

the swapped value.