Audio-thumbnail cache


Here’s a file that could use some comments explaining the strategy. I need to understand it as we need a fancier one :slight_smile:

One small coding style point:

   if (numSamples == numSamplesCached
         && numChannelsCached == numChans
         && startTime == cachedStart
         && timePerPixel == cachedTimePerPixel
         && ! cacheNeedsRefilling)
        return ! cacheNeedsRefilling;

Just ‘return false’ might do?

But my substantial question is:

    if (refillCache (area.getWidth(), startTime, endTime, rate,
                     numChans, sampsPerThumbSample, levelData, chans)
         && isPositiveAndBelow (channelNum, numChannelsCached))
             // draw stuff

Is returning false an error condition because it just draws nothing in this case?


Er, no, that’s ‘return true’ - my coffee hasn’t kicked in yet.

That makes a little more sense now.

So what it’s doing is invalidating the cache and not painting if any of hte values are ridiculous, and returning true if it rebuilt the cache OR if the cache was still valid.