From 8f32d34f1cf31cfd10d07e623842dd3f7fc86e8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Wed, 14 Oct 2020 19:29:34 +0200 Subject: cargo fmt --- mumd/src/audio.rs | 49 ++++++++++++++++++++++++++++--------------------- 1 file changed, 28 insertions(+), 21 deletions(-) (limited to 'mumd/src/audio.rs') diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs index aa06a9d..58424b6 100644 --- a/mumd/src/audio.rs +++ b/mumd/src/audio.rs @@ -103,26 +103,32 @@ impl Audio { let input_stream = match input_supported_sample_format { SampleFormat::F32 => input_device.build_input_stream( &input_config, - input_callback::(input_encoder, - input_sender, - input_config.sample_rate.0, - 10.0), + input_callback::( + input_encoder, + input_sender, + input_config.sample_rate.0, + 10.0, + ), err_fn, ), SampleFormat::I16 => input_device.build_input_stream( &input_config, - input_callback::(input_encoder, - input_sender, - input_config.sample_rate.0, - 10.0), + input_callback::( + input_encoder, + input_sender, + input_config.sample_rate.0, + 10.0, + ), err_fn, ), SampleFormat::U16 => input_device.build_input_stream( &input_config, - input_callback::(input_encoder, - input_sender, - input_config.sample_rate.0, - 10.0), + input_callback::( + input_encoder, + input_sender, + input_config.sample_rate.0, + 10.0, + ), err_fn, ), } @@ -207,7 +213,8 @@ impl ClientStream { match payload { VoicePacketPayload::Opus(bytes, _eot) => { let mut out: Vec = vec![0.0; 720 * channels * 4]; //720 is because that is the max size of packet we can get that we want to decode - let parsed = self.opus_decoder + let parsed = self + .opus_decoder .decode_float(&bytes, &mut out, false) .expect("Error decoding"); out.truncate(parsed); @@ -271,15 +278,15 @@ fn input_callback( sample_rate: u32, opus_frame_size_ms: f32, ) -> 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_ms == 2.5 + || opus_frame_size_ms == 5.0 + || opus_frame_size_ms == 10.0 + || opus_frame_size_ms == 20.0) + { panic!("Unsupported opus frame size {}", opus_frame_size_ms); } let opus_frame_size = (opus_frame_size_ms * sample_rate as f32) as u32 / 1000; - let buf = Arc::new(Mutex::new(VecDeque::new())); move |data: &[T], _info: &InputCallbackInfo| { let mut buf = buf.lock().unwrap(); @@ -293,9 +300,9 @@ fn input_callback( .unwrap(); opus_buf.truncate(result); let bytes = Bytes::copy_from_slice(&opus_buf); - match input_sender - .try_send(VoicePacketPayload::Opus(bytes, false)) { //TODO handle full buffer / disconnect - Ok(_) => {}, + match input_sender.try_send(VoicePacketPayload::Opus(bytes, false)) { + //TODO handle full buffer / disconnect + Ok(_) => {} Err(_e) => { //warn!("Error sending audio packet: {:?}", e); } -- cgit v1.2.1