Skip track on decoding error

This commit is contained in:
Roderick van Domburg 2021-12-11 21:32:34 +01:00
parent 4370258716
commit 79c4040a53
No known key found for this signature in database
GPG key ID: A9EF5222A26F0451

View file

@ -737,7 +737,14 @@ impl PlayerTrackLoader {
} }
}; };
assert!(audio.duration >= 0); if audio.duration < 0 {
error!(
"Track duration for <{}> cannot be {}",
spotify_id.to_uri(),
audio.duration
);
return None;
}
let duration_ms = audio.duration as u32; let duration_ms = audio.duration as u32;
// (Most) podcasts seem to support only 96 bit Vorbis, so fall back to it // (Most) podcasts seem to support only 96 bit Vorbis, so fall back to it
@ -945,7 +952,7 @@ impl Future for PlayerInternal {
} }
Poll::Ready(Err(_)) => { Poll::Ready(Err(_)) => {
warn!("Unable to load <{:?}>\nSkipping to next track", track_id); warn!("Unable to load <{:?}>\nSkipping to next track", track_id);
assert!(self.state.is_loading()); debug_assert!(self.state.is_loading());
self.send_event(PlayerEvent::EndOfTrack { self.send_event(PlayerEvent::EndOfTrack {
track_id, track_id,
play_request_id, play_request_id,
@ -1045,8 +1052,11 @@ impl Future for PlayerInternal {
} }
} }
Err(e) => { Err(e) => {
error!("PlayerInternal poll: {}", e); warn!("Unable to decode samples for track <{:?}: {:?}>\nSkipping to next track", track_id, e);
exit(1); self.send_event(PlayerEvent::EndOfTrack {
track_id,
play_request_id,
})
} }
} }
} }
@ -1058,8 +1068,15 @@ impl Future for PlayerInternal {
self.handle_packet(packet, normalisation_factor); self.handle_packet(packet, normalisation_factor);
} }
Err(e) => { Err(e) => {
error!("PlayerInternal poll: {}", e); warn!(
exit(1); "Unable to get packet for track <{:?}: {:?}>\nSkipping to next track",
e,
track_id
);
self.send_event(PlayerEvent::EndOfTrack {
track_id,
play_request_id,
})
} }
} }
} else { } else {