From 077d22429eeaa41876379b825bd7ed642c771d1c Mon Sep 17 00:00:00 2001 From: Hailey Somerville Date: Wed, 27 Dec 2023 16:49:07 +1100 Subject: [PATCH] tidy, set max bitrate --- bark-core/src/decode/opus.rs | 13 +++---------- bark-core/src/encode/opus.rs | 7 ++----- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/bark-core/src/decode/opus.rs b/bark-core/src/decode/opus.rs index b33441b..41dc647 100644 --- a/bark-core/src/decode/opus.rs +++ b/bark-core/src/decode/opus.rs @@ -28,17 +28,10 @@ impl Display for OpusDecoder { impl Decode for OpusDecoder { fn decode_packet(&mut self, bytes: Option<&[u8]>, out: &mut SampleBuffer) -> Result<(), DecodeError> { let expected = out.len() / 2; - let length; - match bytes { - Some(bytes) => { - length = self.opus.decode_float(bytes, out, false)?; - log::debug!("opus decode: bytes={} -> frames={}", bytes.len(), length); - } - None => { - length = self.opus.decode_float(&[], out, true)?; - log::debug!("opus decode: correcting packet loss! frames={}", length); - } + let length = match bytes { + Some(bytes) => self.opus.decode_float(bytes, out, false)?, + None => self.opus.decode_float(&[], out, true)?, }; if expected != length { diff --git a/bark-core/src/encode/opus.rs b/bark-core/src/encode/opus.rs index 992ef6e..9e5a919 100644 --- a/bark-core/src/encode/opus.rs +++ b/bark-core/src/encode/opus.rs @@ -18,6 +18,7 @@ impl OpusEncoder { opus.set_inband_fec(true)?; opus.set_packet_loss_perc(50)?; + opus.set_bitrate(opus::Bitrate::Max)?; Ok(OpusEncoder { opus }) } @@ -35,10 +36,6 @@ impl Encode for OpusEncoder { } fn encode_packet(&mut self, samples: &[f32], out: &mut [u8]) -> Result { - let len = self.opus.encode_float(samples, out)?; - - log::debug!("opus encode: frames={} -> bytes={}", samples.len() / 2, len); - - Ok(len) + Ok(self.opus.encode_float(samples, out)?) } }