]> git.nihav.org Git - nihav.git/commitdiff
mpa: generate correct audio info
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 13 Oct 2024 16:16:01 +0000 (18:16 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Mon, 14 Oct 2024 16:18:49 +0000 (18:18 +0200)
nihav-mpeg/src/codecs/mpegaudio/mod.rs

index e883df80a66c21caae6820c946ff645849c23f2a..714047ab0e9ca54f94e700aafc861b961465c40e 100644 (file)
@@ -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)