From a9460dca13350288e2c627e255fa6a76ac7088be Mon Sep 17 00:00:00 2001 From: Aron Heinecke Date: Thu, 5 Aug 2021 16:50:28 +0200 Subject: [PATCH] Cleanup Signed-off-by: Aron Heinecke --- src/discord.rs | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/discord.rs b/src/discord.rs index 1d2450c..4481474 100644 --- a/src/discord.rs +++ b/src/discord.rs @@ -406,20 +406,14 @@ impl VoiceEventHandler for Receiver { let opus_slice = &data[start..]; let dur; { - let mut lock_decoder = self.decoder.lock().await; - let mut decoded: [i16; 48000 *2 ] = [0; 48000 * 2]; - if let Err(e) = lock_decoder.decode(Some(opus_slice), &mut decoded[..], false) { - eprintln!("Failed to handle Discord voice packet: {:?}",e); - } else { - let time = std::time::Instant::now(); - let mut lock = self.sink.lock().await; - dur = time.elapsed(); - if let Err(e) = lock.handle_packet(packet.ssrc, packet.sequence.0.0, opus_slice.to_vec()) { - eprintln!("Failed to handle Discord voice packet: {}",e); - } - if dur.as_millis() > 1 { - eprintln!("Acquiring lock took {}ms",dur.as_millis()); - } + let time = std::time::Instant::now(); + let mut lock = self.sink.lock().await; + dur = time.elapsed(); + if let Err(e) = lock.handle_packet(packet.ssrc, packet.sequence.0.0, opus_slice.to_vec()) { + eprintln!("Failed to handle Discord voice packet: {}",e); + } + if dur.as_millis() > 1 { + eprintln!("Acquiring lock took {}ms",dur.as_millis()); } }