X-Git-Url: https://git.nihav.org/?a=blobdiff_plain;f=sndplay%2Fsrc%2Fmain.rs;h=97ed3499590c079d81a385e5ee679a1549273f39;hb=HEAD;hp=c368651a6815e68e3e87e8370d9972eabdc4c3c1;hpb=f8b39df7616777fbac588b4e7b1578ae5dba8ee0;p=nihav-player.git diff --git a/sndplay/src/main.rs b/sndplay/src/main.rs index c368651..97ed349 100644 --- a/sndplay/src/main.rs +++ b/sndplay/src/main.rs @@ -118,7 +118,7 @@ fn output_vol_i16(device: &AudioDevice, tmp: &mut Vec, src: &[i16], mute: b tmp.clear(); tmp.resize(src.len(), 0); } - device.queue(&tmp); + device.queue(tmp); } fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec, src: &[u8], mute: bool, volume: u8) { @@ -135,7 +135,7 @@ fn output_vol_u8(device: &AudioDevice, tmp: &mut Vec, src: &[u8], mute: boo tmp.clear(); tmp.resize(src.len() / 2, 0); } - device.queue(&tmp); + device.queue(tmp); } impl<'a> Decoder<'a> { @@ -160,17 +160,17 @@ impl<'a> Decoder<'a> { match out_buf { NABufferType::AudioI16(abuf) => { if !self.mute && self.volume == 100 { - device.queue(&abuf.get_data()); + device.queue(abuf.get_data()); } else { - output_vol_i16(device, self.buf, &abuf.get_data(), self.mute, self.volume); + output_vol_i16(device, self.buf, abuf.get_data(), self.mute, self.volume); } self.samplepos += abuf.get_length() as u64; }, NABufferType::AudioPacked(abuf) => { if !self.mute && self.volume == 100 { - device.queue_bytes(&abuf.get_data()); + device.queue_bytes(abuf.get_data()); } else { - output_vol_u8(device, self.buf, &abuf.get_data(), self.mute, self.volume); + output_vol_u8(device, self.buf, abuf.get_data(), self.mute, self.volume); } self.samplepos += abuf.get_length() as u64; }, @@ -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);