mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Made AudioThumbnail::loadFrom return a bool.
This commit is contained in:
parent
9152fc8120
commit
460b047387
5 changed files with 18 additions and 12 deletions
|
|
@ -573,12 +573,12 @@ void AudioThumbnail::createChannels (const int length)
|
|||
}
|
||||
|
||||
//==============================================================================
|
||||
void AudioThumbnail::loadFrom (InputStream& rawInput)
|
||||
bool AudioThumbnail::loadFrom (InputStream& rawInput)
|
||||
{
|
||||
BufferedInputStream input (rawInput, 4096);
|
||||
|
||||
if (input.readByte() != 'j' || input.readByte() != 'a' || input.readByte() != 't' || input.readByte() != 'm')
|
||||
return;
|
||||
return false;
|
||||
|
||||
const ScopedLock sl (lock);
|
||||
clearChannelData();
|
||||
|
|
@ -596,6 +596,8 @@ void AudioThumbnail::loadFrom (InputStream& rawInput)
|
|||
for (int i = 0; i < numThumbnailSamples; ++i)
|
||||
for (int chan = 0; chan < numChannels; ++chan)
|
||||
channels.getUnchecked(chan)->getData(i)->read (input);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void AudioThumbnail::saveTo (OutputStream& output) const
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ public:
|
|||
previously have been created by the saveTo() method.
|
||||
@see saveTo
|
||||
*/
|
||||
void loadFrom (InputStream& input);
|
||||
bool loadFrom (InputStream& input);
|
||||
|
||||
/** Saves the low res thumbnail data to an output stream.
|
||||
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
previously have been created by the saveTo() method.
|
||||
@see saveTo
|
||||
*/
|
||||
virtual void loadFrom (InputStream& input) = 0;
|
||||
virtual bool loadFrom (InputStream& input) = 0;
|
||||
|
||||
/** Saves the low res thumbnail data to an output stream.
|
||||
|
||||
|
|
|
|||
|
|
@ -26,16 +26,16 @@
|
|||
class AudioThumbnailCache::ThumbnailCacheEntry
|
||||
{
|
||||
public:
|
||||
ThumbnailCacheEntry (const int64 hash_)
|
||||
: hash (hash_),
|
||||
ThumbnailCacheEntry (const int64 hashCode)
|
||||
: hash (hashCode),
|
||||
lastUsed (Time::getMillisecondCounter())
|
||||
{
|
||||
}
|
||||
|
||||
ThumbnailCacheEntry (InputStream& in)
|
||||
: lastUsed (0)
|
||||
: hash (in.readInt64()),
|
||||
lastUsed (0)
|
||||
{
|
||||
hash = in.readInt64();
|
||||
const int64 len = in.readInt64();
|
||||
in.readIntoMemoryBlock (data, (ssize_t) len);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,8 +54,7 @@ public:
|
|||
virtual ~AudioThumbnailCache();
|
||||
|
||||
//==============================================================================
|
||||
/** Clears out any stored thumbnails.
|
||||
*/
|
||||
/** Clears out any stored thumbnails. */
|
||||
void clear();
|
||||
|
||||
/** Reloads the specified thumb if this cache contains the appropriate stored
|
||||
|
|
@ -89,9 +88,14 @@ public:
|
|||
TimeSliceThread& getTimeSliceThread() noexcept { return thread; }
|
||||
|
||||
protected:
|
||||
/** */
|
||||
/** This can be overridden to provide a custom callback for saving thumbnails
|
||||
once they have finished being loaded.
|
||||
*/
|
||||
virtual void saveNewlyFinishedThumbnail (const 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 bool loadNewThumb (AudioThumbnailBase&, int64 hashCode);
|
||||
|
||||
private:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue