mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-22 07:15:47 +00:00
9058abd340
Track is the app's normalized song model and QueueItemRef its thin queue identity -- consumed app-wide (queue, cover, context menus, sharing, lucky-mix, library browse), not a playback-internal detail. They lived in features/playback/store/playerStoreTypes, forcing ~115 core/feature files to reach into the playback feature for the central media type. Move the two interfaces to lib/media/trackTypes; playerStoreTypes keeps PlayerState and now imports them from lib. 115 importers repointed (mixed 'PlayerState, Track' lines split so PlayerState stays). Pure type move (erased at runtime). tsc 0, lint 0.
28 lines
1.3 KiB
TypeScript
28 lines
1.3 KiB
TypeScript
import type { QueueItemRef } from '@/lib/media/trackTypes';
|
|
import { useAuthStore } from '@/store/authStore';
|
|
import { collectLoudnessBackfillWindowTrackIds } from '@/features/playback/store/loudnessBackfillWindow';
|
|
import { refreshLoudnessForTrack } from '@/features/playback/store/loudnessRefresh';
|
|
import { usePlayerStore } from '@/features/playback/store/playerStore';
|
|
/**
|
|
* After a bulk enqueue (queue replace, append-many, lucky-mix) warm the
|
|
* loudness cache for the current track + the next N entries so the
|
|
* gapless `audio_chain_preload` payload sees a real cached gain instead
|
|
* of the startup trim. No-op when normalization isn't on `loudness` —
|
|
* other engines don't need the cache populated proactively.
|
|
*
|
|
* Calls don't sync the playing engine (`syncPlayingEngine: false`) — the
|
|
* already-playing track is unaffected; we're only filling the cache for
|
|
* the upcoming ones.
|
|
*/
|
|
export function prefetchLoudnessForEnqueuedTracks(
|
|
mergedQueue: QueueItemRef[],
|
|
queueIndex: number,
|
|
): void {
|
|
if (useAuthStore.getState().normalizationEngine !== 'loudness') return;
|
|
const currentTrack = usePlayerStore.getState().currentTrack;
|
|
const ids = collectLoudnessBackfillWindowTrackIds(mergedQueue, queueIndex, currentTrack);
|
|
for (const id of ids) {
|
|
void refreshLoudnessForTrack(id, { syncPlayingEngine: false });
|
|
}
|
|
}
|