Deps: Update to Audiopus v0.3.0-rc.0 (#125)

Tested using `cargo make ready`.

Co-authored-by: André Vennberg <andre.vennberg@gmail.com>
This commit is contained in:
Kyle Simpson
2022-04-24 11:55:56 +01:00
parent d3a40fe691
commit 4eb95d4b59
5 changed files with 32 additions and 15 deletions

View File

@@ -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);

View File

@@ -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<OpusPacket> = 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) => {

View File

@@ -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();
}
}

View File

@@ -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);