2 Commits
Author SHA1 Message Date
zarzet a4605cbdfc fix(usb): fetch a network song whole before it plays, so it keeps the USB output
The USB output opens whole local files only. A network song (NAS, server or
a computer through Link) without a copy in the prefetch cache streamed, and
a stream plays through Android's mixer: no exclusive access, and at whatever
level the DAC was left on. The cache only holds the next two songs and starts
after three seconds of play, so a tapped or skipped-to song, and any large
song still downloading when its turn came, lost the output. A tester's log
shows exactly that: "USB output not used: this song streams" after each
skip, on songs of every sample rate.

With USB bit-perfect on and its output connected, such a song now downloads
ahead of its neighbours and starts from the copy. It streams as before when
the copy cannot be kept (too large, no file extension), the download fails,
60 seconds pass, or no output is connected, which the new outputPresent
query answers so playing without a DAC does not wait. A newer play request
ends the wait at once. Waits of half a second or more, and every fallback,
are logged.
2026-11-19 17:33:57 +07:00
zarzet e90f5e8927 feat(network): prefetch upcoming NAS songs to a local cache
While a network song plays, download the whole files of the next two
queue songs and then the current one, one at a time, into a bounded
app cache (1 GB, 32 files, 256 MB per file, least recently used first,
never a wanted or just played copy). Downloads write to a temporary
name and are renamed once complete, start a few seconds into a song and
stop when a song leaves the wanted set.

Playback opens a complete copy as a local file on every engine and
streams from the server until then; saved offline copies keep priority.
Gapless preparation waits for a copy still downloading until 10 seconds
before the end. Copies are checked against the server's size and
modification time or entity tag, and in-app edits, deletions and
removed connections drop them. Mornye Link virtual hosts are skipped.
2026-11-04 04:04:18 +07:00