fix(cache): don't discard 24-bit cache for sample rate mismatch

A track mastered at 44.1kHz/24bit IS the maximum quality available.
Re-downloading won't produce a higher sample rate. Only check bit
depth for UltraHiRes/HiRes quality matching — if cache has 24-bit,
use it regardless of sample rate.

Previously, requesting UltraHiRes with a 44.1kHz/24bit cache would
discard the cache and re-download, getting the exact same data.

cc
This commit is contained in:
vicrodh committed 2026-04-06 14:55:26 -06:00
1 parent 63120010d9
commit 49fc2ae41e
1 file changed
+4 -4
+4 -4
View File
@@ -318,10 +318,10 @@ fn cached_quality_below_requested(data: &[u8], requested: Quality) -> bool {
};
let dominated = match requested {
// Hi-Res+: expect 24-bit AND >96kHz
Quality::UltraHiRes => bit_depth < 24 || sample_rate <= 96000,
// Hi-Res: expect 24-bit
Quality::HiRes => bit_depth < 24,
// Hi-Res+ / Hi-Res: expect 24-bit. Don't check sample rate — a track
// mastered at 44.1kHz/24bit IS the maximum quality, re-downloading
// won't produce a higher sample rate.
Quality::UltraHiRes | Quality::HiRes => bit_depth < 24,
// Lossless / Mp3: any FLAC is fine
_ => false,
};