From 7b7b426d726457b8cd48baefb6242cbda0fd7f01 Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 30 Jun 2023 18:22:40 +0200 Subject: [PATCH] sndplay: support playing AAC with SBR --- sndplay/src/main.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index c368651..4741853 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -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); -- 2.39.5