Speed up ALAC playback by using streaming decoder

Removed special case that forced ALAC to use symphonia fallback which
decoded the entire file (~30MB) before playback, causing 6+ second delays.

Now ALAC uses rodio's Decoder first (supports ALAC via symphonia-all
feature) which streams instead of decoding everything upfront.

Fallback chain is now:
1. Rodio Decoder (streaming) - instant
2. MP4 fallback (streaming) - instant
3. Symphonia (full decode) - slow, last resort

This brings ALAC playback start time from ~6 seconds to instant,
matching FLAC and other formats.
This commit is contained in:
vicrodh committed 2026-01-19 20:41:57 -06:00
1 parent cdaf02bf3a
commit 20eac2f578
1 file changed
+2 -8
+2 -8
View File
@@ -235,14 +235,8 @@ fn extract_audio_metadata(data: &[u8]) -> Result<(u32, u16), String> {
fn decode_with_fallback(
data: &[u8],
) -> Result<Box<dyn Source<Item = i16> + Send>, String> {
if is_isomp4(data) {
return decode_with_symphonia(data)
.map(|specs| {
log::info!("Decoded audio using symphonia fallback (isomp4)");
Box::new(specs.samples) as Box<dyn Source<Item = i16> + Send>
});
}
// Try rodio's Decoder first (supports ALAC via symphonia-all feature)
// This streams instead of decoding everything upfront
let primary = panic::catch_unwind(AssertUnwindSafe(|| {
Decoder::new(BufReader::new(Cursor::new(data.to_vec())))
}));