com.threerings.openal
Class OggStreamDecoder

java.lang.Object
  extended by com.threerings.openal.StreamDecoder
      extended by com.threerings.openal.OggStreamDecoder

public class OggStreamDecoder
extends StreamDecoder

Decodes Ogg Vorbis streams.


Field Summary
protected  com.jcraft.jorbis.Block _block
          The output block.
protected  short[] _data
          Intermediate storage for converted data.
protected  com.jcraft.jorbis.DspState _dsp
          The DSP state.
protected  InputStream _in
          The underlying input stream.
protected  com.jcraft.jorbis.Info _info
          The stream info.
protected  int[] _offsets
          The DSP offsets for each channel.
protected  com.jcraft.jogg.Packet _packet
          The output packet.
protected  com.jcraft.jogg.Page _page
          The output page.
protected  float[][][] _pcm
          Holds the decoded PCM data buffers.
protected  com.jcraft.jogg.StreamState _stream
          The stream state.
protected  com.jcraft.jogg.SyncState _sync
          The sync state.
protected static int BUFFER_SIZE
          The decode buffer size.
 
Fields inherited from class com.threerings.openal.StreamDecoder
_extensions
 
Constructor Summary
OggStreamDecoder()
           
 
Method Summary
 int getFormat()
          Returns the sound format (see Stream.getFormat()).
 int getFrequency()
          Returns the sound frequency (see Stream.getFrequency()).
 void init(InputStream in)
          Initializes the decoder with its input stream.
 int read(ByteBuffer buf)
          Reads as much data as will fit into the specified buffer.
protected  boolean readChunk()
          Reads in a chunk of data from the underlying input stream.
protected  boolean readPacket()
          Reads a packet.
protected  boolean readPage()
          Reads in a page.
protected  int readSamples()
          Reads a buffer's worth of samples.
 
Methods inherited from class com.threerings.openal.StreamDecoder
createInstance, createInstance, registerExtension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_in

protected InputStream _in
The underlying input stream.


_sync

protected com.jcraft.jogg.SyncState _sync
The sync state.


_stream

protected com.jcraft.jogg.StreamState _stream
The stream state.


_page

protected com.jcraft.jogg.Page _page
The output page.


_packet

protected com.jcraft.jogg.Packet _packet
The output packet.


_info

protected com.jcraft.jorbis.Info _info
The stream info.


_dsp

protected com.jcraft.jorbis.DspState _dsp
The DSP state.


_block

protected com.jcraft.jorbis.Block _block
The output block.


_pcm

protected float[][][] _pcm
Holds the decoded PCM data buffers.


_offsets

protected int[] _offsets
The DSP offsets for each channel.


_data

protected short[] _data
Intermediate storage for converted data.


BUFFER_SIZE

protected static final int BUFFER_SIZE
The decode buffer size.

See Also:
Constant Field Values
Constructor Detail

OggStreamDecoder

public OggStreamDecoder()
Method Detail

init

public void init(InputStream in)
          throws IOException
Description copied from class: StreamDecoder
Initializes the decoder with its input stream.

Specified by:
init in class StreamDecoder
Throws:
IOException

getFormat

public int getFormat()
Description copied from class: StreamDecoder
Returns the sound format (see Stream.getFormat()).

Specified by:
getFormat in class StreamDecoder

getFrequency

public int getFrequency()
Description copied from class: StreamDecoder
Returns the sound frequency (see Stream.getFrequency()).

Specified by:
getFrequency in class StreamDecoder

read

public int read(ByteBuffer buf)
         throws IOException
Description copied from class: StreamDecoder
Reads as much data as will fit into the specified buffer.

Specified by:
read in class StreamDecoder
Returns:
the number of bytes read. If less than or equal to zero, the decoder has reached the end of the stream.
Throws:
IOException

readSamples

protected int readSamples()
                   throws IOException
Reads a buffer's worth of samples.

Returns:
the number of samples read, or zero if we've reached the end of the stream.
Throws:
IOException

readPacket

protected boolean readPacket()
                      throws IOException
Reads a packet.

Returns:
true if a packet was read, false if we've reached the end of the stream.
Throws:
IOException

readPage

protected boolean readPage()
                    throws IOException
Reads in a page.

Returns:
true if a page was read, false if we've reached the end of the stream.
Throws:
IOException

readChunk

protected boolean readChunk()
                     throws IOException
Reads in a chunk of data from the underlying input stream.

Returns:
true if a chunk was read, false if we've reached the end of the stream.
Throws:
IOException