Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Apr 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ version = "0.17"

[dependencies.audiopus]
optional = true
version = "0.2"
version = "0.3.0-rc.0"

[dependencies.byteorder]
optional = true
Expand Down
4 changes: 2 additions & 2 deletions src/driver/tasks/mixer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down
18 changes: 12 additions & 6 deletions src/driver/tasks/udp_rx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use crate::{
use audiopus::{
coder::Decoder as OpusDecoder,
error::{Error as OpusError, ErrorCode},
packet::Packet as OpusPacket,
Channels,
};
use discortp::{
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand All @@ -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) => {
Expand Down
17 changes: 14 additions & 3 deletions src/input/cached/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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();
}

Expand All @@ -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();
}
}
6 changes: 3 additions & 3 deletions src/input/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ use error::{Error, Result};
use tokio::runtime::Handle;

use std::{
convert::TryFrom,
convert::{TryFrom, TryInto},
io::{
self,
Error as IoError,
Expand Down Expand Up @@ -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);
Expand Down