Skip to content

Commit

Permalink
fix oob error
Browse files Browse the repository at this point in the history
  • Loading branch information
Billy Messenger authored and Billy Messenger committed Aug 31, 2023
1 parent 1fbcedb commit 97d9531
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion decode_symphonia/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,12 @@ impl Decoder for SymphoniaDecoder {
}

let len = decoded.frames();
let capacity = decoded.capacity();

let decode_buffer: AudioBuffer<f32> = decoded.make_equivalent();
let mut decode_buffer: AudioBuffer<f32> =
AudioBuffer::new(capacity as u64, spec);

decoded.convert(&mut decode_buffer);

break (decode_buffer, len);
}
Expand Down Expand Up @@ -275,6 +279,13 @@ impl Decoder for SymphoniaDecoder {
match self.decoder.decode(&packet) {
Ok(decoded) => {
self.decode_buffer_len = decoded.frames();

let capacity = decoded.capacity();
if self.decode_buffer.capacity() < capacity {
self.decode_buffer =
AudioBuffer::new(capacity as u64, *decoded.spec());
}

decoded.convert(&mut self.decode_buffer);

self.curr_decode_buffer_frame = 0;
Expand Down

0 comments on commit 97d9531

Please sign in to comment.