2 ==============================================================================
4 This file is part of the JUCE library - "Jules' Utility Class Extensions"
5 Copyright 2004-11 by Raw Material Software Ltd.
7 ------------------------------------------------------------------------------
9 JUCE can be redistributed and/or modified under the terms of the GNU General
10 Public License (Version 2), as published by the Free Software Foundation.
11 A copy of the license is included in the JUCE distribution, or can be found
12 online at www.gnu.org/licenses.
14 JUCE is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
16 A PARTICULAR PURPOSE. See the GNU General Public License for more details.
18 ------------------------------------------------------------------------------
20 To release a closed-source product which uses JUCE, commercial licenses are
21 available: visit www.rawmaterialsoftware.com/juce for more information.
23 ==============================================================================
26 #ifndef __JUCE_AUDIOTHUMBNAILCACHE_JUCEHEADER__
27 #define __JUCE_AUDIOTHUMBNAILCACHE_JUCEHEADER__
29 #include "juce_AudioThumbnail.h"
30 struct ThumbnailCacheEntry
;
33 //==============================================================================
35 An instance of this class is used to manage multiple AudioThumbnail objects.
37 The cache runs a single background thread that is shared by all the thumbnails
38 that need it, and it maintains a set of low-res previews in memory, to avoid
39 having to re-scan audio files too often.
43 class JUCE_API AudioThumbnailCache
: public TimeSliceThread
46 //==============================================================================
47 /** Creates a cache object.
49 The maxNumThumbsToStore parameter lets you specify how many previews should
50 be kept in memory at once.
52 explicit AudioThumbnailCache (int maxNumThumbsToStore
);
55 ~AudioThumbnailCache();
57 //==============================================================================
58 /** Clears out any stored thumbnails.
62 /** Reloads the specified thumb if this cache contains the appropriate stored
65 This is called automatically by the AudioThumbnail class, so you shouldn't
66 normally need to call it directly.
68 bool loadThumb (AudioThumbnail
& thumb
, int64 hashCode
);
70 /** Stores the cachable data from the specified thumb in this cache.
72 This is called automatically by the AudioThumbnail class, so you shouldn't
73 normally need to call it directly.
75 void storeThumb (const AudioThumbnail
& thumb
, int64 hashCode
);
79 //==============================================================================
80 OwnedArray
<ThumbnailCacheEntry
> thumbs
;
81 int maxNumThumbsToStore
;
83 ThumbnailCacheEntry
* findThumbFor (int64 hash
) const;
85 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (AudioThumbnailCache
);
89 #endif // __JUCE_AUDIOTHUMBNAILCACHE_JUCEHEADER__