@@ -253,20 +253,17 @@ String AudioPeakProfileCache::generateCacheKey (const File& audioFile)
253253
254254String AudioPeakProfileCache::generateCacheKey (const AudioBuffer<float >& buffer, double sampleRate)
255255{
256- int64 hash = buffer.getNumSamples ();
257- hash = hash * 31 + buffer.getNumChannels ();
258- hash = hash * 31 + static_cast <int64 > (sampleRate * 1000.0 );
256+ uint64 hash = static_cast <uint64> ( buffer.getNumSamples () );
257+ hash = hash * 31 + static_cast <uint64> ( buffer.getNumChannels () );
258+ hash = hash * 31 + static_cast <uint64 > (std::abs ( sampleRate) * 1000.0 );
259259
260- // Sample buffer content at intervals for unique identification
261260 for (int channel = 0 ; channel < buffer.getNumChannels (); ++channel)
262261 {
263262 const float * data = buffer.getReadPointer (channel);
264263 const int numSamples = buffer.getNumSamples ();
265264
266265 for (int i = 0 ; i < jmin (1000 , numSamples); i += 100 )
267- {
268- hash = hash * 31 + static_cast <int64> (data[i] * 1000000 .0f );
269- }
266+ hash = hash * 31 + static_cast <uint64> (std::abs (data[i]) * 1000000 .0f );
270267 }
271268
272269 return String::toHexString (hash);
@@ -279,9 +276,7 @@ int64 AudioPeakProfileCache::getDiskCacheSize() const
279276
280277 int64 totalSize = 0 ;
281278 for (const auto & entry : RangedDirectoryIterator (cacheDirectory, false , " *.yuppeaks" ))
282- {
283279 totalSize += entry.getFile ().getSize ();
284- }
285280
286281 return totalSize;
287282}
@@ -341,7 +336,6 @@ void AudioPeakProfileCache::notifyProfileReady (const String& cacheKey, std::sha
341336 });
342337 };
343338
344- #if YUP_MODAL_LOOPS_PERMITTED
345339 if (auto * mm = MessageManager::getInstanceWithoutCreating ())
346340 {
347341 if (mm->isThisTheMessageThread ())
@@ -350,13 +344,10 @@ void AudioPeakProfileCache::notifyProfileReady (const String& cacheKey, std::sha
350344 return ;
351345 }
352346
353- // Always use callAsync when not on message thread - don't fall back to synchronous call
354347 MessageManager::callAsync (notify);
355348 return ;
356349 }
357- #endif
358350
359- // Fallback for when message manager is not available
360351 notify ();
361352}
362353
@@ -370,7 +361,6 @@ void AudioPeakProfileCache::notifyProfileProgress (const String& cacheKey, doubl
370361 });
371362 };
372363
373- #if YUP_MODAL_LOOPS_PERMITTED
374364 if (auto * mm = MessageManager::getInstanceWithoutCreating ())
375365 {
376366 if (mm->isThisTheMessageThread ())
@@ -379,13 +369,10 @@ void AudioPeakProfileCache::notifyProfileProgress (const String& cacheKey, doubl
379369 return ;
380370 }
381371
382- // Always use callAsync when not on message thread - don't fall back to synchronous call
383372 MessageManager::callAsync (notify);
384373 return ;
385374 }
386- #endif
387375
388- // Fallback for when message manager is not available
389376 notify ();
390377}
391378
0 commit comments