Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player restart - fix unexpected playback start on reconnects #797

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions Changelog8.html
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ <h2><a name="v8.3.0" id="v8.3.0"></a>Version 8.3.0</h2>
<li>Prevent a server crash while re-building the fulltext search index with huge collections.</li>
<li>Don't show online only artists when a virtual library view tells us to do so.</li>
<li>Fix IO::Socket::SSL initialization in the scanner's sync http lookup code.</li>
<li><a href="https://github.com/Logitech/slimserver/pull/797">#797</a> - Fix Power off/Power on behaviour - Player would resume playback of stale track when reconnecting, although nothing to be resumed.</li>
</ul>
<br />

Expand Down
12 changes: 11 additions & 1 deletion Slim/Networking/Slimproto.pm
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ sub slimproto_close {
# may change firmware versions before coming back
$client->_needsUpgrade(undef);

# Save client playback state, as if the player is turned off.
# This must be done *_now_*, before the client reconnects, otherwise
# the client->reconnect method may act on stale data. In that case,
# the player may start playback when it absolutely should not.
persistPlaybackStateForPowerOff($client);

# set timer to forget client
if ( $forget_disconnected_time ) {
main::INFOLOG && $log->is_info && $log->info("setting timer to forget client in $forget_disconnected_time secs");
Expand All @@ -295,7 +301,7 @@ sub slimproto_close {
delete($sock2client{$clientsock});
}

sub forget_disconnected_client {
sub persistPlaybackStateForPowerOff {
my $client = shift;
my $cprefs = preferences('server')->client($client);

Expand All @@ -311,6 +317,10 @@ sub forget_disconnected_client {
$cprefs->set('positionAtDisconnect', $position);
mherger marked this conversation as resolved.
Show resolved Hide resolved
main::INFOLOG && $log->is_info && $log->info("disconnected player position $position secs");
}
}

sub forget_disconnected_client {
my $client = shift;

main::INFOLOG && $log->info("forgetting disconnected client");

Expand Down