]> git.nihav.org Git - nihav-player.git/commitdiff
sndplay: support playing AAC with SBR
authorKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 30 Jun 2023 16:22:40 +0000 (18:22 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Fri, 30 Jun 2023 16:22:40 +0000 (18:22 +0200)
sndplay/src/main.rs

index c368651a6815e68e3e87e8370d9972eabdc4c3c1..4741853702fc81cedb211964d4b4993eade3d25c 100644 (file)
@@ -303,8 +303,16 @@ impl Player {
         }
         let (dsupp, decoder) = dec.unwrap();
 
-        let ainfo = ainfo.unwrap().get_properties().get_audio_info().unwrap();
-        let arate = if ainfo.sample_rate > 0 { ainfo.sample_rate } else { 44100 };
+        let info = ainfo.unwrap();
+        let ainfo = info.get_properties().get_audio_info().unwrap();
+        let sbr_hack = info.get_name() == "aac" && ainfo.sample_rate < 32000;
+        let arate = if ainfo.sample_rate > 0 {
+                if !sbr_hack {
+                    ainfo.sample_rate
+                } else {
+                    ainfo.sample_rate * 2
+                }
+            } else { 44100 };
         let ch    = ainfo.channels;
 
         println!("Playing {} [{}Hz {}ch]", name, arate, ch);