63 : thread (
"thumb cache"),
66 jassert (maxNumThumbsToStore > 0);
76 for (
int i = thumbs.size(); --i >= 0;)
77 if (thumbs.getUnchecked (i)->hash == hash)
78 return thumbs.getUnchecked (i);
83int AudioThumbnailCache::findOldestThumb()
const
88 for (
int i = thumbs.size(); --i >= 0;)
90 const ThumbnailCacheEntry*
const te = thumbs.getUnchecked (i);
119 const int64 hashCode)
128 if (thumbs.size() < maxNumThumbsToStore)
131 thumbs.set (findOldestThumb(),
te);
152 for (
int i = thumbs.size(); --i >= 0;)
153 if (thumbs.getUnchecked (i)->hash == hashCode)
157static int getThumbnailCacheFileMagicHeader() noexcept
164 if (source.
readInt() != getThumbnailCacheFileMagicHeader())
181 out.
writeInt (getThumbnailCacheFileMagicHeader());
184 for (
int i = 0; i < thumbs.size(); ++i)
185 thumbs.getUnchecked (i)->write (out);
Provides a base for classes that can store and draw scaled views of an audio waveform.
virtual ~AudioThumbnailCache()
Destructor.
bool readFromStream(InputStream &source)
Attempts to re-load a saved cache of thumbnails from a stream.
virtual void saveNewlyFinishedThumbnail(const AudioThumbnailBase &, int64 hashCode)
This can be overridden to provide a custom callback for saving thumbnails once they have finished bei...
AudioThumbnailCache(int maxNumThumbsToStore)
Creates a cache object.
void clear()
Clears out any stored thumbnails.
void storeThumb(const AudioThumbnailBase &thumb, int64 hashCode)
Stores the cacheable data from the specified thumb in this cache.
void removeThumb(int64 hashCode)
Tells the cache to forget about the thumb with the given hashcode.
bool loadThumb(AudioThumbnailBase &thumb, int64 hashCode)
Reloads the specified thumb if this cache contains the appropriate stored data.
virtual bool loadNewThumb(AudioThumbnailBase &, int64 hashCode)
This can be overridden to provide a custom callback for loading thumbnails from pre-saved files to sa...
void writeToStream(OutputStream &stream)
Writes all currently-loaded cache data to a stream.
static constexpr uint32 littleEndianInt(const void *bytes) noexcept
Turns 4 bytes into a little-endian integer.
Automatically locks and unlocks a mutex object.
A class to hold a resizable block of raw data.
size_t getSize() const noexcept
Returns the block's current allocated size, in bytes.
Writes data to an internal memory buffer, which grows as required.
The base class for streams that write data to some kind of destination.
virtual bool writeInt64(int64 value)
Writes a 64-bit integer to the stream in a little-endian byte order.
virtual bool writeInt(int value)
Writes a 32-bit integer to the stream in a little-endian byte order.
bool startThread()
Attempts to start a new thread with default ('Priority::normal') priority.
@ low
Uses efficiency cores when possible.
static uint32 getMillisecondCounter() noexcept
Returns the number of millisecs since a fixed event (usually system startup).
#define JUCE_LEAK_DETECTOR(OwnerClass)
This macro lets you embed a leak-detecting object inside a class.
constexpr Type jmin(Type a, Type b)
Returns the smaller of two values.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
unsigned int uint32
A platform-independent 32-bit unsigned integer type.
long long int64
A platform-independent 64-bit integer type.