JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::AudioThumbnailCache Class Reference

An instance of this class is used to manage multiple AudioThumbnail objects. More...

#include <juce_AudioThumbnailCache.h>

Collaboration diagram for juce::AudioThumbnailCache:

Public Member Functions

 AudioThumbnailCache (int maxNumThumbsToStore)
 Creates a cache object.
 
virtual ~AudioThumbnailCache ()
 Destructor.
 
void clear ()
 Clears out any stored thumbnails.
 
TimeSliceThreadgetTimeSliceThread () noexcept
 Returns the thread that client thumbnails can use.
 
bool loadThumb (AudioThumbnailBase &thumb, int64 hashCode)
 Reloads the specified thumb if this cache contains the appropriate stored data.
 
bool readFromStream (InputStream &source)
 Attempts to re-load a saved cache of thumbnails from a stream.
 
void removeThumb (int64 hashCode)
 Tells the cache to forget about the thumb with the given hashcode.
 
void storeThumb (const AudioThumbnailBase &thumb, int64 hashCode)
 Stores the cacheable data from the specified thumb in this cache.
 
void writeToStream (OutputStream &stream)
 Writes all currently-loaded cache data to a stream.
 

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.
 
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.
 

Private Member Functions

int findOldestThumb () const
 
ThumbnailCacheEntry * findThumbFor (int64 hash) const
 

Private Attributes

CriticalSection lock
 
int maxNumThumbsToStore
 
TimeSliceThread thread
 
OwnedArray< ThumbnailCacheEntry > thumbs
 

Detailed Description

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.

See also
AudioThumbnail

@tags{Audio}

Constructor & Destructor Documentation

◆ AudioThumbnailCache()

juce::AudioThumbnailCache::AudioThumbnailCache ( int  maxNumThumbsToStore)
explicit

Creates a cache object.

The maxNumThumbsToStore parameter lets you specify how many previews should be kept in memory at once.

◆ ~AudioThumbnailCache()

virtual juce::AudioThumbnailCache::~AudioThumbnailCache ( )
virtual

Destructor.

Member Function Documentation

◆ clear()

void juce::AudioThumbnailCache::clear ( )

Clears out any stored thumbnails.

◆ findOldestThumb()

int juce::AudioThumbnailCache::findOldestThumb ( ) const
private

◆ findThumbFor()

ThumbnailCacheEntry * juce::AudioThumbnailCache::findThumbFor ( int64  hash) const
private

◆ getTimeSliceThread()

TimeSliceThread & juce::AudioThumbnailCache::getTimeSliceThread ( )
inlinenoexcept

Returns the thread that client thumbnails can use.

◆ loadNewThumb()

virtual bool juce::AudioThumbnailCache::loadNewThumb ( AudioThumbnailBase ,
int64  hashCode 
)
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.

◆ loadThumb()

bool juce::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.

◆ readFromStream()

bool juce::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.

◆ removeThumb()

void juce::AudioThumbnailCache::removeThumb ( int64  hashCode)

Tells the cache to forget about the thumb with the given hashcode.

◆ saveNewlyFinishedThumbnail()

virtual void juce::AudioThumbnailCache::saveNewlyFinishedThumbnail ( const AudioThumbnailBase ,
int64  hashCode 
)
protectedvirtual

This can be overridden to provide a custom callback for saving thumbnails once they have finished being loaded.

◆ storeThumb()

void juce::AudioThumbnailCache::storeThumb ( const AudioThumbnailBase thumb,
int64  hashCode 
)

Stores the cacheable 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.

◆ writeToStream()

void juce::AudioThumbnailCache::writeToStream ( OutputStream stream)

Writes all currently-loaded cache data to a stream.

The resulting data can be re-loaded with readFromStream().

Member Data Documentation

◆ lock

CriticalSection juce::AudioThumbnailCache::lock
private

◆ maxNumThumbsToStore

int juce::AudioThumbnailCache::maxNumThumbsToStore
private

◆ thread

TimeSliceThread juce::AudioThumbnailCache::thread
private

◆ thumbs

OwnedArray<ThumbnailCacheEntry> juce::AudioThumbnailCache::thumbs
private

The documentation for this class was generated from the following file: