Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

aflibMemCache Class Reference

Base class that implements audio data caching. More...

#include <aflibMemCache.h>

Inheritance diagram for aflibMemCache::

aflibAudio aflibAudioBWFilter aflibAudioConstantSrc aflibAudioEdit aflibAudioFile aflibAudioMemoryInput aflibAudioMixer aflibAudioRecorder aflibAudioSampleRateCvt aflibAudioSpectrum List of all members.

Public Methods

 aflibMemCache ()
 Constructor.

virtual ~aflibMemCache ()
 Destructor.

bool getCacheEnable ()
 Returns the current state of caching for this object. More...

void setCacheEnable (bool enable)
 Set the state of caching for this object.

long long getCacheMax () const
 Returns the maximum allowed size of the cache.

long long getCacheTotal () const
 Gets the total size of all caches added together.

long long getCacheLocal () const
 Gets the current size of the cache for this object only.

void clearCache ()
 Empties the cache for this object only.


Protected Methods

void lookupData (long long &position, int &num_samples)
void fillDataFromCache (aflibData &data, long long &position, int &num_samples, long long orig_position, int orig_num_samples)

Detailed Description

Base class that implements audio data caching.

The purpose of this class is to provide a memory caching mechanism to those classes who whould benefit from this. It will store audio data into a buffer that it controls so that when audio data is reread for what ever purpose it will come from this cache instead of from the original source. This is beneficial for three reasons. 1) Some sources may not support backing up for old data. For instance an http stream comming over an internet connection. Some derived aflibAudio objects need to back up over old data. For instance the sample rate converter class. It needs to operate on an old history of the data for best results. In order to save the complexity from each derived class we will implement caching here. 2) Reading audio data can be expensive from some sources. Reading from a disk can be slow and audio data from mp3s requires decoding. This will provide the capability to not have to reread again from the original source. 3) Some audio sources do not support random access. We can provide a limited random access capability for these sources by caching the audio data from the start of the file. Of course there are limitations with this.

Most derived classes by default have caching disabled. To enable or disable caching one would call setCacheEnable. The environment variable AFLIB_CACHE_SIZE can be set to set the maximum amount of cache to use. The default is 1MB.


Constructor & Destructor Documentation

aflibMemCache::aflibMemCache ( )
 

Constructor.

aflibMemCache::~aflibMemCache ( ) [virtual]
 

Destructor.


Member Function Documentation

void aflibMemCache::clearCache ( )
 

Empties the cache for this object only.

void aflibMemCache::fillDataFromCache ( aflibData & data,
long long & position,
int & num_samples,
long long orig_position,
int orig_num_samples ) [protected]
 

bool aflibMemCache::getCacheEnable ( )
 

Returns the current state of caching for this object.

Return the state of the cache. TRUE means caching is enabled.

long long aflibMemCache::getCacheLocal ( ) const
 

Gets the current size of the cache for this object only.

long long aflibMemCache::getCacheMax ( ) const
 

Returns the maximum allowed size of the cache.

long long aflibMemCache::getCacheTotal ( ) const
 

Gets the total size of all caches added together.

void aflibMemCache::lookupData ( long long & position,
int & num_samples ) [protected]
 

void aflibMemCache::setCacheEnable ( bool enable )
 

Set the state of caching for this object.


The documentation for this class was generated from the following files:
Generated at Tue Aug 7 22:18:07 2001 for Open Source Audio Library Project by doxygen1.2.6 written by Dimitri van Heesch, © 1997-2001