Commit a641f562 authored by Christopher Zimmerman's avatar Christopher Zimmerman Committed by Max Kellermann

playlist_state: save state when stopped

At the moment mpd doesn't store or restore the current track to/from its state file when the daemon is stopped/started while in 'stopped' state. I believe the preferred behaviour would be to store and restore the current track even when the daemon is in stopped state when shutting down. I made a small patch to adapt this behaviour. If you believe this is not the preferred behaviour, maybe this should be realized as a configuration option. I'm not sure how to do this, but made a small comment, where one would have to put the option.
parent fe96bdf7
...@@ -6,6 +6,7 @@ ver 0.16 (20??/??/??) ...@@ -6,6 +6,7 @@ ver 0.16 (20??/??/??)
* commands: * commands:
- added new "status" line with more precise "elapsed time" - added new "status" line with more precise "elapsed time"
* log unused/unknown block parameters * log unused/unknown block parameters
* save state when stopped
ver 0.15 (2009/06/23) ver 0.15 (2009/06/23)
......
...@@ -66,8 +66,12 @@ playlist_state_save(FILE *fp, const struct playlist *playlist) ...@@ -66,8 +66,12 @@ playlist_state_save(FILE *fp, const struct playlist *playlist)
playlist->current)); playlist->current));
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME, fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME,
getPlayerElapsedTime()); getPlayerElapsedTime());
} else } else {
fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP); fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP);
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_CURRENT,
queue_order_to_position(&playlist->queue,
playlist->current));
}
fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM, fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_RANDOM,
playlist->queue.random); playlist->queue.random);
...@@ -172,19 +176,19 @@ playlist_state_restore(FILE *fp, struct playlist *playlist) ...@@ -172,19 +176,19 @@ playlist_state_restore(FILE *fp, struct playlist *playlist)
(PLAYLIST_STATE_FILE_CURRENT)])); (PLAYLIST_STATE_FILE_CURRENT)]));
} else if (g_str_has_prefix(buffer, } else if (g_str_has_prefix(buffer,
PLAYLIST_STATE_FILE_PLAYLIST_BEGIN)) { PLAYLIST_STATE_FILE_PLAYLIST_BEGIN)) {
if (state == PLAYER_STATE_STOP)
current = -1;
playlist_state_load(fp, playlist, buffer); playlist_state_load(fp, playlist, buffer);
} }
} }
setPlaylistRandomStatus(playlist, random_mode); setPlaylistRandomStatus(playlist, random_mode);
if (state != PLAYER_STATE_STOP && !queue_is_empty(&playlist->queue)) { if (!queue_is_empty(&playlist->queue)) {
if (!queue_valid_position(&playlist->queue, current)) if (!queue_valid_position(&playlist->queue, current))
current = 0; current = 0;
if (seek_time == 0) if (state == PLAYER_STATE_STOP /* && config_option */)
playlist->current = current;
else if (seek_time == 0)
playPlaylist(playlist, current); playPlaylist(playlist, current);
else else
seekSongInPlaylist(playlist, current, seek_time); seekSongInPlaylist(playlist, current, seek_time);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment