From ecb118f1edab572a904890eddafd3b11c0a79a79 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 8 Oct 2009 15:22:39 +0200 Subject: state_file: save only if something has changed If nothing has changed since the last save, don't save the state file. Saving will spin up the hard drive, which is undesirable on hosts where MPD is idling in background. --- src/playlist_state.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/playlist_state.c') diff --git a/src/playlist_state.c b/src/playlist_state.c index f288a5738..5d18cc339 100644 --- a/src/playlist_state.c +++ b/src/playlist_state.c @@ -200,3 +200,21 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist) return true; } + +unsigned +playlist_state_get_hash(const struct playlist *playlist) +{ + return playlist->queue.version ^ + (getPlayerElapsedTime() << 8) ^ + (playlist->current >= 0 + ? (queue_order_to_position(&playlist->queue, + playlist->current) << 16) + : 0) ^ + ((int)getPlayerCrossFade() << 20) ^ + (getPlayerState() << 24) ^ + (playlist->queue.random << 27) ^ + (playlist->queue.repeat << 28) ^ + (playlist->queue.single << 29) ^ + (playlist->queue.consume << 30) ^ + (playlist->queue.random << 31); +} -- cgit v1.2.3