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);
|
BufferedInputStream input (rawInput, 4096);
|
||||||
|
|
||||||
if (input.readByte() != 'j' || input.readByte() != 'a' || input.readByte() != 't' || input.readByte() != 'm')
|
if (input.readByte() != 'j' || input.readByte() != 'a' || input.readByte() != 't' || input.readByte() != 'm')
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
const ScopedLock sl (lock);
|
const ScopedLock sl (lock);
|
||||||
clearChannelData();
|
clearChannelData();
|
||||||
|
|
@ -596,6 +596,8 @@ void AudioThumbnail::loadFrom (InputStream& rawInput)
|
||||||
for (int i = 0; i < numThumbnailSamples; ++i)
|
for (int i = 0; i < numThumbnailSamples; ++i)
|
||||||
for (int chan = 0; chan < numChannels; ++chan)
|
for (int chan = 0; chan < numChannels; ++chan)
|
||||||
channels.getUnchecked(chan)->getData(i)->read (input);
|
channels.getUnchecked(chan)->getData(i)->read (input);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void AudioThumbnail::saveTo (OutputStream& output) const
|
void AudioThumbnail::saveTo (OutputStream& output) const
|
||||||
|
|
|
||||||
|
|
@ -119,7 +119,7 @@ public:
|
||||||
previously have been created by the saveTo() method.
|
previously have been created by the saveTo() method.
|
||||||
@see saveTo
|
@see saveTo
|
||||||
*/
|
*/
|
||||||
void loadFrom (InputStream& input);
|
bool loadFrom (InputStream& input);
|
||||||
|
|
||||||
/** Saves the low res thumbnail data to an output stream.
|
/** Saves the low res thumbnail data to an output stream.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -83,7 +83,7 @@ public:
|
||||||
previously have been created by the saveTo() method.
|
previously have been created by the saveTo() method.
|
||||||
@see saveTo
|
@see saveTo
|
||||||
*/
|
*/
|
||||||
virtual void loadFrom (InputStream& input) = 0;
|
virtual bool loadFrom (InputStream& input) = 0;
|
||||||
|
|
||||||
/** Saves the low res thumbnail data to an output stream.
|
/** Saves the low res thumbnail data to an output stream.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -26,16 +26,16 @@
|
||||||
class AudioThumbnailCache::ThumbnailCacheEntry
|
class AudioThumbnailCache::ThumbnailCacheEntry
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ThumbnailCacheEntry (const int64 hash_)
|
ThumbnailCacheEntry (const int64 hashCode)
|
||||||
: hash (hash_),
|
: hash (hashCode),
|
||||||
lastUsed (Time::getMillisecondCounter())
|
lastUsed (Time::getMillisecondCounter())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ThumbnailCacheEntry (InputStream& in)
|
ThumbnailCacheEntry (InputStream& in)
|
||||||
: lastUsed (0)
|
: hash (in.readInt64()),
|
||||||
|
lastUsed (0)
|
||||||
{
|
{
|
||||||
hash = in.readInt64();
|
|
||||||
const int64 len = in.readInt64();
|
const int64 len = in.readInt64();
|
||||||
in.readIntoMemoryBlock (data, (ssize_t) len);
|
in.readIntoMemoryBlock (data, (ssize_t) len);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,8 +54,7 @@ public:
|
||||||
virtual ~AudioThumbnailCache();
|
virtual ~AudioThumbnailCache();
|
||||||
|
|
||||||
//==============================================================================
|
//==============================================================================
|
||||||
/** Clears out any stored thumbnails.
|
/** Clears out any stored thumbnails. */
|
||||||
*/
|
|
||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/** Reloads the specified thumb if this cache contains the appropriate stored
|
/** Reloads the specified thumb if this cache contains the appropriate stored
|
||||||
|
|
@ -89,9 +88,14 @@ public:
|
||||||
TimeSliceThread& getTimeSliceThread() noexcept { return thread; }
|
TimeSliceThread& getTimeSliceThread() noexcept { return thread; }
|
||||||
|
|
||||||
protected:
|
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);
|
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);
|
virtual bool loadNewThumb (AudioThumbnailBase&, int64 hashCode);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue