Signed-off-by: Aron Heinecke <aron.heinecke@t-online.de>
This commit is contained in:
Aron Heinecke 2021-08-05 16:50:28 +02:00
parent 7c77c2cd52
commit a9460dca13

View file

@ -406,20 +406,14 @@ impl VoiceEventHandler for Receiver {
let opus_slice = &data[start..]; let opus_slice = &data[start..];
let dur; let dur;
{ {
let mut lock_decoder = self.decoder.lock().await; let time = std::time::Instant::now();
let mut decoded: [i16; 48000 *2 ] = [0; 48000 * 2]; let mut lock = self.sink.lock().await;
if let Err(e) = lock_decoder.decode(Some(opus_slice), &mut decoded[..], false) { dur = time.elapsed();
eprintln!("Failed to handle Discord voice packet: {:?}",e); if let Err(e) = lock.handle_packet(packet.ssrc, packet.sequence.0.0, opus_slice.to_vec()) {
} else { eprintln!("Failed to handle Discord voice packet: {}",e);
let time = std::time::Instant::now(); }
let mut lock = self.sink.lock().await; if dur.as_millis() > 1 {
dur = time.elapsed(); eprintln!("Acquiring lock took {}ms",dur.as_millis());
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());
}
} }
} }