refactor(decoder/symphonia) logic reorderd

This commit is contained in:
dvdsk 2024-04-04 23:47:47 +02:00
parent f846cdf38d
commit a52a41bd86
No known key found for this signature in database
GPG key ID: 6CF9D20C5709A836

View file

@ -195,11 +195,10 @@ impl Iterator for SymphoniaDecoder {
if self.current_frame_offset == self.buffer.len() { if self.current_frame_offset == self.buffer.len() {
let mut decode_errors: usize = 0; let mut decode_errors: usize = 0;
let decoded = loop { let decoded = loop {
match self.format.next_packet() { let packet = self.format.next_packet().ok()?;
Ok(packet) => match self.decoder.decode(&packet) { match self.decoder.decode(&packet) {
Ok(decoded) => break decoded, Ok(decoded) => break decoded,
Err(e) => match e { Err(Error::DecodeError(_)) => {
Error::DecodeError(_) => {
decode_errors += 1; decode_errors += 1;
if decode_errors > MAX_DECODE_ERRORS { if decode_errors > MAX_DECODE_ERRORS {
return None; return None;
@ -207,11 +206,8 @@ impl Iterator for SymphoniaDecoder {
continue; continue;
} }
} }
_ => return None,
},
},
Err(_) => return None, Err(_) => return None,
} };
}; };
self.spec = decoded.spec().to_owned(); self.spec = decoded.spec().to_owned();
self.buffer = SymphoniaDecoder::get_buffer(decoded, &self.spec); self.buffer = SymphoniaDecoder::get_buffer(decoded, &self.spec);