Skip to content

Commit

Permalink
Update StreamingController.pm
Browse files Browse the repository at this point in the history
Updated based on feedback from @michaelherger and @philippe44.
  • Loading branch information
kwarklabs authored May 6, 2022
1 parent ada52a5 commit cf6ee16
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions Slim/Player/StreamingController.pm
Original file line number Diff line number Diff line change
Expand Up @@ -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.")};
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit cf6ee16

Please sign in to comment.