An instance of this class is used to manage multiple AudioThumbnail objects. More...
#include <juce_AudioThumbnailCache.h>
Public Member Functions | |
AudioThumbnailCache (int maxNumThumbsToStore) | |
Creates a cache object. More... | |
virtual | ~AudioThumbnailCache () |
Destructor. More... | |
void | clear () |
Clears out any stored thumbnails. More... | |
TimeSliceThread & | getTimeSliceThread () noexcept |
Returns the thread that client thumbnails can use. More... | |
bool | loadThumb (AudioThumbnailBase &thumb, int64 hashCode) |
Reloads the specified thumb if this cache contains the appropriate stored data. More... | |
bool | readFromStream (InputStream &source) |
Attempts to re-load a saved cache of thumbnails from a stream. More... | |
void | removeThumb (int64 hashCode) |
Tells the cache to forget about the thumb with the given hashcode. More... | |
void | storeThumb (const AudioThumbnailBase &thumb, int64 hashCode) |
Stores the cachable data from the specified thumb in this cache. More... | |
void | writeToStream (OutputStream &stream) |
Writes all currently-loaded cache data to a stream. More... | |
Protected Member Functions | |
virtual bool | loadNewThumb (AudioThumbnailBase &, int64 hashCode) |
This can be overridden to provide a custom callback for loading thumbnails from pre-saved files to save the cache the trouble of having to create them. More... | |
virtual void | saveNewlyFinishedThumbnail (const AudioThumbnailBase &, int64 hashCode) |
This can be overridden to provide a custom callback for saving thumbnails once they have finished being loaded. More... | |
Private Member Functions | |
int | findOldestThumb () const |
ThumbnailCacheEntry * | findThumbFor (int64 hash) const |
Private Attributes | |
CriticalSection | lock |
int | maxNumThumbsToStore |
TimeSliceThread | thread |
OwnedArray< ThumbnailCacheEntry > | thumbs |
Friends | |
struct | ContainerDeletePolicy< ThumbnailCacheEntry > |
An instance of this class is used to manage multiple AudioThumbnail objects.
The cache runs a single background thread that is shared by all the thumbnails that need it, and it maintains a set of low-res previews in memory, to avoid having to re-scan audio files too often.
|
explicit |
Creates a cache object.
The maxNumThumbsToStore parameter lets you specify how many previews should be kept in memory at once.
|
virtual |
Destructor.
void AudioThumbnailCache::clear | ( | ) |
Clears out any stored thumbnails.
|
private |
|
private |
|
inlinenoexcept |
Returns the thread that client thumbnails can use.
|
protectedvirtual |
This can be overridden to provide a custom callback for loading thumbnails from pre-saved files to save the cache the trouble of having to create them.
bool AudioThumbnailCache::loadThumb | ( | AudioThumbnailBase & | thumb, |
int64 | hashCode | ||
) |
Reloads the specified thumb if this cache contains the appropriate stored data.
This is called automatically by the AudioThumbnail class, so you shouldn't normally need to call it directly.
bool AudioThumbnailCache::readFromStream | ( | InputStream & | source | ) |
Attempts to re-load a saved cache of thumbnails from a stream.
The cache data must have been written by the writeToStream() method. This will replace all currently-loaded thumbnails with the new data.
void AudioThumbnailCache::removeThumb | ( | int64 | hashCode | ) |
Tells the cache to forget about the thumb with the given hashcode.
|
protectedvirtual |
This can be overridden to provide a custom callback for saving thumbnails once they have finished being loaded.
void AudioThumbnailCache::storeThumb | ( | const AudioThumbnailBase & | thumb, |
int64 | hashCode | ||
) |
Stores the cachable data from the specified thumb in this cache.
This is called automatically by the AudioThumbnail class, so you shouldn't normally need to call it directly.
void AudioThumbnailCache::writeToStream | ( | OutputStream & | stream | ) |
Writes all currently-loaded cache data to a stream.
The resulting data can be re-loaded with readFromStream().
|
friend |
|
private |
|
private |
|
private |
|
private |