Skip to content

Commit 1736e7c

Browse files
authored
Merge pull request #905 from roderickvd/fix-exit-on-decoder-error
Skip track on decoding error
2 parents 1cd5f9e + 8f23c34 commit 1736e7c

1 file changed

Lines changed: 24 additions & 8 deletions

File tree

playback/src/player.rs

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,14 @@ impl PlayerTrackLoader {
737737
}
738738
};
739739

740-
assert!(audio.duration >= 0);
740+
if audio.duration < 0 {
741+
error!(
742+
"Track duration for <{}> cannot be {}",
743+
spotify_id.to_uri(),
744+
audio.duration
745+
);
746+
return None;
747+
}
741748
let duration_ms = audio.duration as u32;
742749

743750
// (Most) podcasts seem to support only 96 bit Vorbis, so fall back to it
@@ -943,9 +950,12 @@ impl Future for PlayerInternal {
943950
exit(1);
944951
}
945952
}
946-
Poll::Ready(Err(_)) => {
947-
warn!("Unable to load <{:?}>\nSkipping to next track", track_id);
948-
assert!(self.state.is_loading());
953+
Poll::Ready(Err(e)) => {
954+
warn!(
955+
"Skipping to next track, unable to load track <{:?}>: {:?}",
956+
track_id, e
957+
);
958+
debug_assert!(self.state.is_loading());
949959
self.send_event(PlayerEvent::EndOfTrack {
950960
track_id,
951961
play_request_id,
@@ -1045,8 +1055,11 @@ impl Future for PlayerInternal {
10451055
}
10461056
}
10471057
Err(e) => {
1048-
error!("PlayerInternal poll: {}", e);
1049-
exit(1);
1058+
warn!("Skipping to next track, unable to decode samples for track <{:?}>: {:?}", track_id, e);
1059+
self.send_event(PlayerEvent::EndOfTrack {
1060+
track_id,
1061+
play_request_id,
1062+
})
10501063
}
10511064
}
10521065
}
@@ -1058,8 +1071,11 @@ impl Future for PlayerInternal {
10581071
self.handle_packet(packet, normalisation_factor);
10591072
}
10601073
Err(e) => {
1061-
error!("PlayerInternal poll: {}", e);
1062-
exit(1);
1074+
warn!("Skipping to next track, unable to get next packet for track <{:?}>: {:?}", track_id, e);
1075+
self.send_event(PlayerEvent::EndOfTrack {
1076+
track_id,
1077+
play_request_id,
1078+
})
10631079
}
10641080
}
10651081
} else {

0 commit comments

Comments
 (0)