From cdaf02bf3a213c766f0c87090ba06f7a9d292d2f Mon Sep 17 00:00:00 2001 From: vicrodh <103399283+vicrodh@users.noreply.github.com> Date: Mon, 19 Jan 2026 20:38:38 -0600 Subject: [PATCH] Fix ALAC playback by defaulting to stereo when channel info missing ALAC files (and some other formats) don't include channel information in the initial codec params, causing playback to fail with error: 'No channel info in codec params' Changed to use .unwrap_or(2) instead of .ok_or_else() to default to stereo (2 channels) which is the most common case and matches the behavior in metadata extraction. Fixes playback of ALAC (.m4a) files in Local Library. --- src-tauri/src/player/mod.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src-tauri/src/player/mod.rs b/src-tauri/src/player/mod.rs index 15894efac..e2256a245 100644 --- a/src-tauri/src/player/mod.rs +++ b/src-tauri/src/player/mod.rs @@ -222,9 +222,12 @@ fn extract_audio_metadata(data: &[u8]) -> Result<(u32, u16), String> { let sample_rate = track.codec_params.sample_rate .ok_or_else(|| "No sample rate in codec params".to_string())?; + + // ALAC and some other formats don't include channel info in initial codec params + // Default to stereo (2 channels) which is the most common case let channels = track.codec_params.channels .map(|c| c.count() as u16) - .ok_or_else(|| "No channel info in codec params".to_string())?; + .unwrap_or(2); Ok((sample_rate, channels)) }