diff --git a/Cargo.toml b/Cargo.toml index 63a31a1de..d13623706 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -32,7 +32,7 @@ version = "0.17" [dependencies.audiopus] optional = true -version = "0.2" +version = "0.3.0-rc.0" [dependencies.byteorder] optional = true diff --git a/src/driver/tasks/mixer.rs b/src/driver/tasks/mixer.rs index b359775d4..47653df59 100644 --- a/src/driver/tasks/mixer.rs +++ b/src/driver/tasks/mixer.rs @@ -17,7 +17,7 @@ use discortp::{ }; use flume::{Receiver, Sender, TryRecvError}; use rand::random; -use std::time::Instant; +use std::{convert::TryInto, time::Instant}; use tokio::runtime::Handle; use tracing::{debug, error, instrument}; use xsalsa20poly1305::TAG_SIZE; @@ -426,7 +426,7 @@ impl Mixer { ) }; - self.soft_clip.apply(&mut mix_buffer[..])?; + self.soft_clip.apply((&mut mix_buffer[..]).try_into()?)?; if self.muted { mix_len = MixType::MixedPcm(0); diff --git a/src/driver/tasks/udp_rx.rs b/src/driver/tasks/udp_rx.rs index c6b688e59..76f5aaad3 100644 --- a/src/driver/tasks/udp_rx.rs +++ b/src/driver/tasks/udp_rx.rs @@ -11,6 +11,7 @@ use crate::{ use audiopus::{ coder::Decoder as OpusDecoder, error::{Error as OpusError, ErrorCode}, + packet::Packet as OpusPacket, Channels, }; use discortp::{ @@ -21,7 +22,7 @@ use discortp::{ PacketSize, }; use flume::Receiver; -use std::{collections::HashMap, sync::Arc}; +use std::{collections::HashMap, convert::TryInto, sync::Arc}; use tokio::{net::UdpSocket, select}; use tracing::{error, instrument, trace, warn}; use xsalsa20poly1305::XSalsa20Poly1305 as Cipher; @@ -180,8 +181,11 @@ impl SsrcState { let mut out = vec![0; self.decode_size.len()]; for _ in 0..missed_packets { - let missing_frame: Option<&[u8]> = None; - if let Err(e) = self.decoder.decode(missing_frame, &mut out[..], false) { + let missing_frame: Option = None; + let dest_samples = (&mut out[..]) + .try_into() + .expect("Decode logic will cap decode buffer size at i32::MAX."); + if let Err(e) = self.decoder.decode(missing_frame, dest_samples, false) { warn!("Issue while decoding for missed packet: {:?}.", e); } } @@ -193,9 +197,11 @@ impl SsrcState { // This should scan up to find the "correct" size that a source is using, // and then remember that. loop { - let tried_audio_len = - self.decoder - .decode(Some(&data[start..]), &mut out[..], false); + let tried_audio_len = self.decoder.decode( + Some((&data[start..]).try_into()?), + (&mut out[..]).try_into()?, + false, + ); match tried_audio_len { Ok(audio_len) => { diff --git a/src/input/cached/tests.rs b/src/input/cached/tests.rs index 49aeef5aa..7e69a86fb 100644 --- a/src/input/cached/tests.rs +++ b/src/input/cached/tests.rs @@ -6,7 +6,10 @@ use crate::{ }; use audiopus::{coder::Decoder, Bitrate, Channels, SampleRate}; use byteorder::{LittleEndian, ReadBytesExt}; -use std::io::{Cursor, Read}; +use std::{ + convert::TryInto, + io::{Cursor, Read}, +}; #[tokio::test] async fn streamcatcher_preserves_file() { @@ -51,7 +54,11 @@ fn compressed_triggers_valid_passthrough() { let mut decoder = Decoder::new(SampleRate::Hz48000, Channels::Stereo).unwrap(); decoder - .decode(Some(&opus_buf[..opus_len]), &mut signal_buf[..], false) + .decode( + Some((&opus_buf[..opus_len]).try_into().unwrap()), + (&mut signal_buf[..]).try_into().unwrap(), + false, + ) .unwrap(); } @@ -73,7 +80,11 @@ fn run_through_dca(mut src: impl Read) { let pkt_len = src.read(&mut pkt_space[..frame_len as usize]).unwrap(); decoder - .decode(Some(&pkt_space[..pkt_len]), &mut signals[..], false) + .decode( + Some((&pkt_space[..pkt_len]).try_into().unwrap()), + (&mut signals[..]).try_into().unwrap(), + false, + ) .unwrap(); } } diff --git a/src/input/mod.rs b/src/input/mod.rs index 6a32b48d1..af3e4c5a9 100644 --- a/src/input/mod.rs +++ b/src/input/mod.rs @@ -61,7 +61,7 @@ use error::{Error, Result}; use tokio::runtime::Handle; use std::{ - convert::TryFrom, + convert::{TryFrom, TryInto}, io::{ self, Error as IoError, @@ -233,8 +233,8 @@ impl Input { let samples = decoder .decode_float( - Some(&opus_data_buffer[..seen]), - &mut decoder_state.current_frame[..], + Some((&opus_data_buffer[..seen]).try_into().unwrap()), + (&mut decoder_state.current_frame[..]).try_into().unwrap(), false, ) .unwrap_or(0);