From 086e754e211faf06404b9e4042e38decf31de5d1 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Sun, 13 Oct 2024 18:16:01 +0200 Subject: [PATCH] mpa: generate correct audio info --- nihav-mpeg/src/codecs/mpegaudio/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/nihav-mpeg/src/codecs/mpegaudio/mod.rs b/nihav-mpeg/src/codecs/mpegaudio/mod.rs index e883df8..714047a 100644 --- a/nihav-mpeg/src/codecs/mpegaudio/mod.rs +++ b/nihav-mpeg/src/codecs/mpegaudio/mod.rs @@ -133,8 +133,12 @@ fn apply_ms(ch0: &mut [f32], ch1: &mut [f32]) { impl NADecoder for MPADecoder { fn init(&mut self, _supp: &mut NADecoderSupport, info: NACodecInfoRef) -> DecoderResult<()> { - if let NACodecTypeInfo::Audio(_ainfo) = info.get_properties() { - self.info = info.clone(); + if let NACodecTypeInfo::Audio(ainfo) = info.get_properties() { + let ainfo = NAAudioInfo::new(ainfo.get_sample_rate(), + ainfo.get_channels(), + SND_F32P_FORMAT, + if ainfo.get_sample_rate() >= 32000 { SAMPLES } else { SAMPLES / 2 }); + self.info = info.replace_info(NACodecTypeInfo::Audio(ainfo)); Ok(()) } else { Err(DecoderError::InvalidData) -- 2.39.5