From: Max Kellermann Date: Sat, 17 Oct 2009 23:34:21 +0000 (+0200) Subject: mpdclient: don't update the status in mpdclient_cmd_crop() X-Git-Tag: release-0.16~89 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=4e3fd05dbae8d3d47b08dc0044b1789c2b9d5908;p=ncmpc.git mpdclient: don't update the status in mpdclient_cmd_crop() This is kind of redundant, because it doesn't solve the theoretical race condition, and doesn't improve too much to justify the latency. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index 04c1435..554e564 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -264,28 +264,24 @@ mpdclient_put_connection(struct mpdclient *c) bool mpdclient_cmd_crop(struct mpdclient *c) { - struct mpd_connection *connection = mpdclient_get_connection(c); - struct mpd_status *status; - bool playing; + struct mpd_connection *connection; int length, current; - if (connection == NULL) + if (c->status == NULL) return false; - status = mpd_run_status(connection); - if (status == NULL) - return mpdclient_handle_error(c); - - playing = mpd_status_get_state(status) == MPD_STATE_PLAY || - mpd_status_get_state(status) == MPD_STATE_PAUSE; - length = mpd_status_get_queue_length(status); - current = mpd_status_get_song_pos(status); - - mpd_status_free(status); - - if (!playing || length < 2) + length = mpd_status_get_queue_length(c->status); + current = mpd_status_get_song_pos(c->status); + if (current < 0 || + (mpd_status_get_state(c->status) != MPD_STATE_PLAY && + mpd_status_get_state(c->status) != MPD_STATE_PAUSE) || + mpd_status_get_queue_length(c->status) < 2) return true; + connection = mpdclient_get_connection(c); + if (connection == NULL) + return false; + mpd_command_list_begin(connection, false); while (--length >= 0)