Fix FLAC pk collision by skipping header for pk calculation
Problem: All FLAC files with the same format (44.1kHz, stereo, 16-bit) had identical headers and thus the same pk (071c5713d5cf485ca688832207bef0f9). This caused the cache to think all tracks were the same file, regardless of channel selection or actual content. Solution: Skip the FLAC header (first 512 bytes) and calculate the pk from bytes 512-1024 (actual audio content) instead. This ensures each track gets a unique pk based on its actual audio data, not just its format header. Changes: - Modified add_from_reader_with_pk() to read 1024 bytes instead of 512 - Use bytes 512-1024 for pk calculation when explicit_pk is None - This works even with poor metadata (empty artist/title) - Maintains backward compatibility with explicit_pk parameter Fixes the issue where changing radio channel played the same song.
This commit is contained in:
@@ -135,6 +135,8 @@ impl NodeLogic for FlacCacheSinkLogic {
|
||||
// Ingérer le FLAC progressivement dans le cache
|
||||
// add_from_reader lance l'ingestion en arrière-plan et retourne dès que
|
||||
// le prebuffer (512 KB) est atteint, permettant un streaming progressif
|
||||
// Le cache skip automatiquement le header FLAC (512 octets) pour calculer le pk
|
||||
// à partir du contenu audio, évitant les collisions entre morceaux au même format
|
||||
let collection_ref = self.collection.as_deref();
|
||||
let cache_future = self.cache.add_from_reader(
|
||||
None,
|
||||
|
||||
Reference in New Issue
Block a user