From cf6ee1652ab6d962fd93b89d0e5c2ac9928eff54 Mon Sep 17 00:00:00 2001 From: kwarklabs <96121168+kwarklabs@users.noreply.github.com> Date: Fri, 6 May 2022 15:27:59 +0100 Subject: [PATCH] Update StreamingController.pm Updated based on feedback from @michaelherger and @philippe44. --- Slim/Player/StreamingController.pm | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Slim/Player/StreamingController.pm b/Slim/Player/StreamingController.pm index cb001f69b3b..eba340a8d5e 100644 --- a/Slim/Player/StreamingController.pm +++ b/Slim/Player/StreamingController.pm @@ -922,9 +922,11 @@ sub _RetryOrNext { # -> Idle; IF [shouldretry && canretry] THEN continue _Stream($self, $event, {song => $song}); return; } else { - if ($song->duration() - $elapsed < 10) # check we have more than 10 seconds left to play. + $log->debug("Elapsed: " . $elapsed); + $log->debug("Duration: " . $song->duration()); + if (!$elapsed || !$song->duration() || $song->duration() < $elapsed || $song->duration() - $elapsed < 10) # check we have more than 10 seconds left to play. { - if ( main::DEBUGLOG && $log->is_debug ) {$log->debug("Will not retry - track is within 10 seconds of end.")}; + if ( main::DEBUGLOG && $log->is_debug ) {$log->debug("Will not retry - no player sync or track is within 10 seconds of end.")}; } else { # get seek data from protocol handler. if ( main::DEBUGLOG && $log->is_debug ) {$log->debug("Getting seek data from protocol handler.")}; @@ -1426,8 +1428,10 @@ sub _willRetry { # Have we managed to play at least 10 seconds of a track and retried fewer times than there are intervals? my $elapsed = $self->playingSongElapsed(); + $log->debug("Elapsed: " . $elapsed); + $log->debug("Duration: " . $song->duration()); if ($song->retryData->{'count'} > scalar @retryIntervals || !$elapsed || $elapsed < 10 || - !$song->duration() || ($song->duration() - $elapsed < 10)) { + !$song->duration() || $song->duration() < $elapsed || ($song->duration() - $elapsed < 10)) { if ( main::DEBUGLOG && $log->is_debug ) {$log->debug("Will not retry - no player sync, too many retries or track within 10 seconds of start or end.")}; return 0; }