com.frinika.audio.io
Class BufferedRandomAccessFile

java.lang.Object
  extended by com.frinika.audio.io.BufferedRandomAccessFile
All Implemented Interfaces:
RandomAccessFileIF

public class BufferedRandomAccessFile
extends java.lang.Object
implements RandomAccessFileIF

Provides an implementation of RandomAccessFileIF that uses a cyclic cache. Collaborates with a BufferedRandomAccessFileManager. This should be used to prefetch data and avoid disk seek glitches File relative pointers ptr1 -> (ptr2-1) files sample in buffer endPtr end of file samples (+1) ptr being read from the cache.

Author:
pjl

Constructor Summary
BufferedRandomAccessFile(java.io.RandomAccessFile in, int buffSize, BufferedRandomAccessFileManager manager)
           
 
Method Summary
 int availableInCache()
           
 void close()
           
 long getFilePointer()
           
 java.io.RandomAccessFile getRandomAccesFile()
           
 java.io.RandomAccessFile getRandomAccessFile()
           
 boolean isFull()
           
 long length()
           
 int read(byte[] byteBuffer, int offSet, int n, boolean realTime)
          read the next n bytes
 void seek(long l, boolean realTime)
          if (!realTime) may block.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BufferedRandomAccessFile

public BufferedRandomAccessFile(java.io.RandomAccessFile in,
                                int buffSize,
                                BufferedRandomAccessFileManager manager)
Method Detail

isFull

public final boolean isFull()

getRandomAccesFile

public java.io.RandomAccessFile getRandomAccesFile()

availableInCache

public final int availableInCache()

read

public int read(byte[] byteBuffer,
                int offSet,
                int n,
                boolean realTime)
         throws java.io.IOException
read the next n bytes

Specified by:
read in interface RandomAccessFileIF
Parameters:
byteBuffer -
offSet -
n -
Returns:
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()

length

public long length()
            throws java.io.IOException
Specified by:
length in interface RandomAccessFileIF
Throws:
java.io.IOException

seek

public void seek(long l,
                 boolean realTime)
          throws java.io.IOException
if (!realTime) may block. the buffer is filled else seek for processAudio thread. only sets the pointer (avoid synchronisation issues)

Specified by:
seek in interface RandomAccessFileIF
Parameters:
l - new file position
Throws:
java.io.IOException

close

public void close()

getRandomAccessFile

public java.io.RandomAccessFile getRandomAccessFile()
Specified by:
getRandomAccessFile in interface RandomAccessFileIF