mirror of
https://github.com/RustAudio/rodio
synced 2024-11-10 06:04:16 +00:00
refactor(decoder/symphonia) logic reorderd
This commit is contained in:
parent
f846cdf38d
commit
a52a41bd86
1 changed files with 12 additions and 16 deletions
|
@ -195,23 +195,19 @@ impl Iterator for SymphoniaDecoder {
|
|||
if self.current_frame_offset == self.buffer.len() {
|
||||
let mut decode_errors: usize = 0;
|
||||
let decoded = loop {
|
||||
match self.format.next_packet() {
|
||||
Ok(packet) => match self.decoder.decode(&packet) {
|
||||
Ok(decoded) => break decoded,
|
||||
Err(e) => match e {
|
||||
Error::DecodeError(_) => {
|
||||
decode_errors += 1;
|
||||
if decode_errors > MAX_DECODE_ERRORS {
|
||||
return None;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
_ => return None,
|
||||
},
|
||||
},
|
||||
let packet = self.format.next_packet().ok()?;
|
||||
match self.decoder.decode(&packet) {
|
||||
Ok(decoded) => break decoded,
|
||||
Err(Error::DecodeError(_)) => {
|
||||
decode_errors += 1;
|
||||
if decode_errors > MAX_DECODE_ERRORS {
|
||||
return None;
|
||||
} else {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Err(_) => return None,
|
||||
}
|
||||
};
|
||||
};
|
||||
self.spec = decoded.spec().to_owned();
|
||||
self.buffer = SymphoniaDecoder::get_buffer(decoded, &self.spec);
|
||||
|
|
Loading…
Reference in a new issue