From: Kostya Shishkov Date: Sun, 13 Oct 2024 16:16:01 +0000 (+0200) Subject: mpa: generate correct audio info X-Git-Url: https://git.nihav.org/?a=commitdiff_plain;h=086e754e211faf06404b9e4042e38decf31de5d1;p=nihav.git mpa: generate correct audio info --- 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)