Class NativeVorbisFile

java.lang.Object
com.jme3.audio.plugins.NativeVorbisFile

public class NativeVorbisFile extends Object
Represents the android implementation for the native vorbis file decoder. This decoder initializes an OggVorbis_File from an already opened file designated by the fd.
Code by Kirill Vainer.
Modified by pavl_g.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
     
    int
     
    float
     
    int
     
     
    int
     
    boolean
     
    int
     
  • Constructor Summary

    Constructors
    Constructor
    Description
    NativeVorbisFile(int fd, long offset, long length)
    Initializes an ogg vorbis native file from a file descriptor [fd] of an already opened file.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Clears the native resources and destroys the buffer ovf reference.
    int
    readIntoArray(byte[] buffer, int offset, int length)
    Reads the vorbis file into a primitive byte buffer [buf] with an [offset] indicating the start byte and a [length] indicating the end byte on the output buffer.
    void
    Reads the vorbis file into a direct ByteBuffer, starting from offset [0] till the buffer end on the output buffer.
    void
    seekTime(double time)
    Seeks to a playback time relative to the decompressed pcm (Pulse-code modulation) stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fd

      public int fd
    • ovf

      public ByteBuffer ovf
    • seekable

      public boolean seekable
    • channels

      public int channels
    • sampleRate

      public int sampleRate
    • bitRate

      public int bitRate
    • totalBytes

      public int totalBytes
    • duration

      public float duration
  • Constructor Details

    • NativeVorbisFile

      public NativeVorbisFile(int fd, long offset, long length) throws IOException
      Initializes an ogg vorbis native file from a file descriptor [fd] of an already opened file.
      Parameters:
      fd - an integer representing the file descriptor
      offset - an integer indicating the start of the buffer
      length - an integer indicating the end of the buffer
      Throws:
      IOException - in cases of a failure to initialize the vorbis file
  • Method Details

    • seekTime

      public void seekTime(double time) throws IOException
      Seeks to a playback time relative to the decompressed pcm (Pulse-code modulation) stream.
      Parameters:
      time - the playback seek time
      Throws:
      IOException - if the seek is not successful
    • readIntoArray

      public int readIntoArray(byte[] buffer, int offset, int length) throws IOException
      Reads the vorbis file into a primitive byte buffer [buf] with an [offset] indicating the start byte and a [length] indicating the end byte on the output buffer.
      Parameters:
      buffer - a primitive byte buffer to read the data into it
      offset - an integer representing the offset or the start byte on the output buffer
      length - an integer representing the end byte on the output buffer
      Returns:
      the number of the read bytes, (-1) if the reading has failed indicating an EOF, returns (0) if the reading has failed or the primitive [buffer] passed is null
      Throws:
      IOException - if the library has failed to read the file into the [out] buffer or if the java primitive byte array [buffer] is inaccessible
    • readIntoBuffer

      public void readIntoBuffer(ByteBuffer out) throws IOException
      Reads the vorbis file into a direct ByteBuffer, starting from offset [0] till the buffer end on the output buffer.
      Parameters:
      out - a reference to the output direct buffer
      Throws:
      IOException - if a premature EOF is encountered before reaching the end of the buffer or if the library has failed to read the file into the [out] buffer
    • clearResources

      public void clearResources()
      Clears the native resources and destroys the buffer ovf reference.