aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/audio.rs
diff options
context:
space:
mode:
authorGustav Sörnäs <gustav@sornas.net>2020-10-14 19:42:28 +0200
committerGustav Sörnäs <gustav@sornas.net>2020-10-14 19:42:28 +0200
commitafd537e085ddf2c92fb1f1879a72d290010fa570 (patch)
treed789c98a4748cc391e91794737399056977223fc /mumd/src/audio.rs
parent8f32d34f1cf31cfd10d07e623842dd3f7fc86e8e (diff)
downloadmum-afd537e085ddf2c92fb1f1879a72d290010fa570.tar.gz
cargo clippy
Diffstat (limited to 'mumd/src/audio.rs')
-rw-r--r--mumd/src/audio.rs20
1 files changed, 10 insertions, 10 deletions
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs
index 58424b6..d8a37a8 100644
--- a/mumd/src/audio.rs
+++ b/mumd/src/audio.rs
@@ -107,7 +107,7 @@ impl Audio {
input_encoder,
input_sender,
input_config.sample_rate.0,
- 10.0,
+ 4, // 10 ms
),
err_fn,
),
@@ -117,7 +117,7 @@ impl Audio {
input_encoder,
input_sender,
input_config.sample_rate.0,
- 10.0,
+ 4, // 10 ms
),
err_fn,
),
@@ -127,7 +127,7 @@ impl Audio {
input_encoder,
input_sender,
input_config.sample_rate.0,
- 10.0,
+ 4, // 10 ms
),
err_fn,
),
@@ -276,16 +276,16 @@ fn input_callback<T: Sample>(
mut opus_encoder: opus::Encoder,
mut input_sender: Sender<VoicePacketPayload>,
sample_rate: u32,
- opus_frame_size_ms: f32,
+ opus_frame_size_blocks: u32, // blocks of 2.5ms
) -> impl FnMut(&[T], &InputCallbackInfo) + Send + 'static {
- if !(opus_frame_size_ms == 2.5
- || opus_frame_size_ms == 5.0
- || opus_frame_size_ms == 10.0
- || opus_frame_size_ms == 20.0)
+ if !(opus_frame_size_blocks == 1
+ || opus_frame_size_blocks == 2
+ || opus_frame_size_blocks == 4
+ || opus_frame_size_blocks == 8)
{
- panic!("Unsupported opus frame size {}", opus_frame_size_ms);
+ panic!("Unsupported amount of opus frame blocks {}", opus_frame_size_blocks);
}
- let opus_frame_size = (opus_frame_size_ms * sample_rate as f32) as u32 / 1000;
+ let opus_frame_size = opus_frame_size_blocks * sample_rate / 400;
let buf = Arc::new(Mutex::new(VecDeque::new()));
move |data: &[T], _info: &InputCallbackInfo| {