#include <aflibMemCache.h>
Inheritance diagram for aflibMemCache::
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) |
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.
|
|
Empties the cache for this object only.
|
|
|
|
Returns the current state of caching for this object. Return the state of the cache. TRUE means caching is enabled. |
|
Gets the current size of the cache for this object only.
|
|
Returns the maximum allowed size of the cache.
|
|
Gets the total size of all caches added together.
|
|
|
|
Set the state of caching for this object.
|