aboutsummaryrefslogtreecommitdiffstats
path: root/mumd/src/audio.rs
diff options
context:
space:
mode:
authorEskil Queseth <eskilq@kth.se>2020-10-11 22:59:54 +0200
committerEskil Queseth <eskilq@kth.se>2020-10-11 22:59:54 +0200
commit7273cccdb97cad8ab5b57278dc9020c276c50f20 (patch)
tree5aa326767fe5cce76c289ba272246f876454e174 /mumd/src/audio.rs
parent5b2bc17a053674fe57f85a99e5dc61d031a553af (diff)
downloadmum-7273cccdb97cad8ab5b57278dc9020c276c50f20.tar.gz
Fixed client sometimes crashing when receiving compressed packages
Diffstat (limited to 'mumd/src/audio.rs')
-rw-r--r--mumd/src/audio.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/mumd/src/audio.rs b/mumd/src/audio.rs
index c52de85..eeae4da 100644
--- a/mumd/src/audio.rs
+++ b/mumd/src/audio.rs
@@ -204,13 +204,10 @@ impl ClientStream {
fn decode_packet(&mut self, payload: VoicePacketPayload, channels: usize) {
match payload {
VoicePacketPayload::Opus(bytes, _eot) => {
- let mut out: Vec<f32> = vec![0.0; bytes.len() * channels * 4 + 1000];
- if bytes.len() != 120 {
- println!("{}", bytes.len());
- }
+ let mut out: Vec<f32> = 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
- .decode_float(&bytes, &mut out, true)
- .expect("error decoding"); //FIXME sometimes panics here
+ .decode_float(&bytes, &mut out, false)
+ .expect("error decoding");
out.truncate(parsed);
self.buffer.extend(out);
}