diff options
author | Max Kellermann <max@duempel.org> | 2009-10-08 20:48:07 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-10-08 20:48:07 +0200 |
commit | 76953a9748e367442fe7c961845ee36b9a0e1596 (patch) | |
tree | 9aad3078411e170a56e11e31158a66f26734298a /src/playlist_state.c | |
parent | 128a5fa4a599b72e6cb9c9f3954aec62dd3b3181 (diff) | |
download | mpd-76953a9748e367442fe7c961845ee36b9a0e1596.tar.gz mpd-76953a9748e367442fe7c961845ee36b9a0e1596.tar.xz mpd-76953a9748e367442fe7c961845ee36b9a0e1596.zip |
player_control: bundle "get" functions in pc_get_status()
The new player_status struct replaces a bunch of playerGetX()
functions. When we add proper locking to the player_control struct,
we will only need to lock once for the "status" command.
Diffstat (limited to 'src/playlist_state.c')
-rw-r--r-- | src/playlist_state.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/playlist_state.c b/src/playlist_state.c index 5d18cc339..16b75efae 100644 --- a/src/playlist_state.c +++ b/src/playlist_state.c @@ -51,10 +51,14 @@ void playlist_state_save(FILE *fp, const struct playlist *playlist) { + struct player_status player_status; + + pc_get_status(&player_status); + fprintf(fp, "%s", PLAYLIST_STATE_FILE_STATE); if (playlist->playing) { - switch (getPlayerState()) { + switch (player_status.state) { case PLAYER_STATE_PAUSE: fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_PAUSE); break; @@ -65,7 +69,7 @@ playlist_state_save(FILE *fp, const struct playlist *playlist) queue_order_to_position(&playlist->queue, playlist->current)); fprintf(fp, "%s%i\n", PLAYLIST_STATE_FILE_TIME, - getPlayerElapsedTime()); + (int)player_status.elapsed_time); } else { fprintf(fp, "%s\n", PLAYLIST_STATE_FILE_STATE_STOP); @@ -204,14 +208,20 @@ playlist_state_restore(const char *line, FILE *fp, struct playlist *playlist) unsigned playlist_state_get_hash(const struct playlist *playlist) { + struct player_status player_status; + + pc_get_status(&player_status); + return playlist->queue.version ^ - (getPlayerElapsedTime() << 8) ^ + (player_status.state != PLAYER_STATE_STOP + ? ((int)player_status.elapsed_time << 8) + : 0) ^ (playlist->current >= 0 ? (queue_order_to_position(&playlist->queue, playlist->current) << 16) : 0) ^ ((int)getPlayerCrossFade() << 20) ^ - (getPlayerState() << 24) ^ + (player_status.state << 24) ^ (playlist->queue.random << 27) ^ (playlist->queue.repeat << 28) ^ (playlist->queue.single << 29) ^ |