mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
fix(audio): stabilize loudness normalization and streaming startup behavior
Improve normalization consistency by separating cache refresh for non-playing tracks, hardening track-id cache lookups, and keeping UI gain state aligned with actual playback. Also reduce startup stalls by preferring non-seekable streaming when format hints are missing and by tuning ALSA/analysis paths to avoid underrun-prone churn.
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
export type AnalysisStorageChangedReason =
|
||||
| 'offline-delete'
|
||||
| 'hotcache-delete'
|
||||
| 'hotcache-purge';
|
||||
|
||||
export type AnalysisStorageChangedDetail = {
|
||||
trackId?: string | null;
|
||||
reason: AnalysisStorageChangedReason;
|
||||
};
|
||||
|
||||
const EVENT_NAME = 'psysonic:analysis-storage-changed';
|
||||
|
||||
export function emitAnalysisStorageChanged(detail: AnalysisStorageChangedDetail): void {
|
||||
if (typeof window === 'undefined') return;
|
||||
window.dispatchEvent(new CustomEvent<AnalysisStorageChangedDetail>(EVENT_NAME, { detail }));
|
||||
}
|
||||
|
||||
export function onAnalysisStorageChanged(
|
||||
listener: (detail: AnalysisStorageChangedDetail) => void,
|
||||
): () => void {
|
||||
if (typeof window === 'undefined') return () => {};
|
||||
const wrapped = (evt: Event) => {
|
||||
const ce = evt as CustomEvent<AnalysisStorageChangedDetail>;
|
||||
if (!ce?.detail) return;
|
||||
listener(ce.detail);
|
||||
};
|
||||
window.addEventListener(EVENT_NAME, wrapped as EventListener);
|
||||
return () => window.removeEventListener(EVENT_NAME, wrapped as EventListener);
|
||||
}
|
||||
Reference in New Issue
Block a user