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