The JUCE cross-platform C++ framework, with DISTRHO/KXStudio specific changes
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

90 lines
3.2KB

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