From 1817d1beccb34a0eee7e2321cf06962f5d36a0ad Mon Sep 17 00:00:00 2001 From: Claude Date: Wed, 5 Nov 2025 06:40:51 +0000 Subject: [PATCH] feat: Add I32 support to RadioParadiseStreamSource Add support for 32-bit integer audio samples to match FileSource and HttpSource capabilities, ensuring complete bit depth coverage. Changes: - Add I32 case to pcm_to_audio_segment() for 32-bit stereo samples - Update output_type() comment to document 16/24/32-bit support - Note that bit depth is auto-detected from FLAC header via pmoflac The implementation now supports the full range of FLAC bit depths: - 16-bit: AudioChunk::I16 (most common) - 24-bit: AudioChunk::I24 (high quality) - 32-bit: AudioChunk::I32 (maximum precision) pmoflac reads bits_per_sample from the FLAC STREAMINFO header (decoder.rs:97), so the actual bit depth is determined by the source stream, not hardcoded. Verified: cargo check passes successfully. --- .../src/radio_paradise_stream_source.rs | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/pmoparadise/src/radio_paradise_stream_source.rs b/pmoparadise/src/radio_paradise_stream_source.rs index 9291b294..71c191b6 100644 --- a/pmoparadise/src/radio_paradise_stream_source.rs +++ b/pmoparadise/src/radio_paradise_stream_source.rs @@ -301,6 +301,28 @@ fn pcm_to_audio_segment( let chunk_data = AudioChunkData::new(stereo, sample_rate, 0.0); AudioChunk::I24(chunk_data) } + 32 => { + // Type I32 + let mut stereo = Vec::with_capacity(frames); + for frame_idx in 0..frames { + let base = frame_idx * frame_bytes; + let left = i32::from_le_bytes([ + pcm_data[base], + pcm_data[base + 1], + pcm_data[base + 2], + pcm_data[base + 3], + ]); + let right = i32::from_le_bytes([ + pcm_data[base + 4], + pcm_data[base + 5], + pcm_data[base + 6], + pcm_data[base + 7], + ]); + stereo.push([left, right]); + } + let chunk_data = AudioChunkData::new(stereo, sample_rate, 0.0); + AudioChunk::I32(chunk_data) + } _ => { return Err(AudioError::ProcessingError(format!( "Unsupported bit depth: {}", @@ -476,7 +498,8 @@ impl TypedAudioNode for RadioParadiseStreamSource { } fn output_type(&self) -> Option { - // Radio Paradise FLAC peut être 16-bit ou 24-bit + // Radio Paradise FLAC peut être 16-bit, 24-bit, ou 32-bit + // La profondeur est détectée automatiquement depuis le header FLAC Some(TypeRequirement::any_integer()) } }