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.
This commit is contained in:
Claude
2025-11-05 06:40:51 +00:00
parent 77469d5ee8
commit 1817d1becc

View File

@@ -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<TypeRequirement> {
// 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())
}
}