org.newdawn.slick.openal
Class OggInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.newdawn.slick.openal.OggInputStream
All Implemented Interfaces:
java.io.Closeable

public class OggInputStream
extends java.io.InputStream

An input stream that can extract ogg data. This class is a bit of an experiment with continuations so uses thread where possibly not required. It's just a test to see if continuations make sense in some cases.

Author:
kevin

Constructor Summary
OggInputStream(java.io.InputStream input)
          Create a new stream to decode OGG data
 
Method Summary
 boolean atEnd()
          Check if the stream is at the end, i.e.
 int available()
           
 void close()
          Close the stream
 int getChannels()
          Get the number of channels used by the audio
 int getLength()
          Get the number of bytes on the stream
 int getRate()
          The play back rate described in the underling audio file
 int read()
          Read a single byte from the stream
 int read(byte[] b)
          Read up to data.length bytes from the stream
 int read(byte[] b, int off, int len)
          Read up to len bytes from the stream
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OggInputStream

public OggInputStream(java.io.InputStream input)
               throws java.io.IOException
Create a new stream to decode OGG data

Parameters:
input - The input stream from which to read the OGG file
Throws:
java.io.IOException - Indicates a failure to read from the supplied stream
Method Detail

getLength

public int getLength()
Get the number of bytes on the stream

Returns:
The number of the bytes on the stream

getChannels

public int getChannels()
Get the number of channels used by the audio

Returns:
The number of channels used by the audio
See Also:
AudioInputStream.getChannels()

getRate

public int getRate()
The play back rate described in the underling audio file

Returns:
The playback rate
See Also:
AudioInputStream.getRate()

available

public int available()
Overrides:
available in class java.io.InputStream
See Also:
InputStream.available()

read

public int read()
         throws java.io.IOException
Read a single byte from the stream

Specified by:
read in class java.io.InputStream
Returns:
The single byte read
Throws:
java.io.IOException - Indicates a failure to read the underlying media
See Also:
InputStream.read()

atEnd

public boolean atEnd()
Check if the stream is at the end, i.e. end of file or URL

Returns:
True if the stream has no more data available
See Also:
AudioInputStream.atEnd()

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read up to len bytes from the stream

Overrides:
read in class java.io.InputStream
Parameters:
b - The array to read into
off - The offset into the array at which to start writing
len - The maximum number of bytes to read
Returns:
The number of bytes read or -1 to indicate no more bytes are available
Throws:
java.io.IOException - Indicates a failure to read the underlying media
See Also:
InputStream.read(byte[], int, int)

read

public int read(byte[] b)
         throws java.io.IOException
Read up to data.length bytes from the stream

Overrides:
read in class java.io.InputStream
Parameters:
b - The array to read into
Returns:
The number of bytes read or -1 to indicate no more bytes are available
Throws:
java.io.IOException - Indicates a failure to read the underlying media
See Also:
InputStream.read(byte[])

close

public void close()
           throws java.io.IOException
Close the stream

Specified by:
close in interface java.io.Closeable
Overrides:
close in class java.io.InputStream
Throws:
java.io.IOException - Indicates a failure to access the resource
See Also:
InputStream.close()


Copyright © 2006 New Dawn Software. All Rights Reserved.