From f042ac4f69790a6f2a4f8a50bd57f8b961b66f61 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 17 Mar 2017 18:01:38 +0100 Subject: [PATCH] main: remove the "idle" fallback code ncmpc has been requiring MPD 0.14+ for 7 years (commit e25d7523), and we really don't need the timer fallback. "idle" just has to be supported. --- src/main.c | 20 +++++--------------- src/mpdclient.c | 20 -------------------- 2 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/main.c b/src/main.c index 76fe235..53b3d89 100644 --- a/src/main.c +++ b/src/main.c @@ -191,9 +191,8 @@ static bool should_enable_update_timer(void) { return (mpdclient_is_connected(mpd) && - (mpd->source == NULL || /* "idle" not supported */ - (mpd->status != NULL && - mpd_status_get_state(mpd->status) == MPD_STATE_PLAY))) + mpd->status != NULL && + mpd_status_get_state(mpd->status) == MPD_STATE_PLAY) #ifndef NCMPC_MINI || options.display_time #endif @@ -216,7 +215,7 @@ static void do_mpd_update(void) { if (mpdclient_is_connected(mpd) && - (mpd->source == NULL || mpd->events != 0 || + (mpd->events != 0 || (mpd->status != NULL && mpd_status_get_state(mpd->status) == MPD_STATE_PLAY))) mpdclient_update(mpd); @@ -342,7 +341,8 @@ check_reconnect(void) * idle event (or when the connection dies). */ static void -idle_callback(enum mpd_error error, enum mpd_server_error server_error, +idle_callback(enum mpd_error error, + gcc_unused enum mpd_server_error server_error, const char *message, enum mpd_idle events, void *ctx) { @@ -353,16 +353,6 @@ idle_callback(enum mpd_error error, enum mpd_server_error server_error, assert(mpdclient_is_connected(c)); if (error != MPD_ERROR_SUCCESS) { - if (error == MPD_ERROR_SERVER && - server_error == MPD_SERVER_ERROR_UNKNOWN_CMD) { - /* the "idle" command is not supported - fall - back to timer based polling */ - mpd_glib_free(c->source); - c->source = NULL; - auto_update_timer(); - return; - } - char *allocated; if (error == MPD_ERROR_SERVER) message = allocated = utf8_to_locale(message); diff --git a/src/mpdclient.c b/src/mpdclient.c index 6826043..164a08d 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -177,11 +177,6 @@ mpdclient_update(struct mpdclient *c) if (connection == NULL) return false; - /* always announce these options as long as we don't have - "idle" support */ - if (c->source == NULL) - c->events |= MPD_IDLE_PLAYER|MPD_IDLE_OPTIONS; - /* free the old status */ if (c->status) mpd_status_free(c->status); @@ -191,29 +186,14 @@ mpdclient_update(struct mpdclient *c) if (c->status == NULL) return mpdclient_handle_error(c); - if (c->source == NULL && - c->update_id != mpd_status_get_update_id(c->status)) { - c->events |= MPD_IDLE_UPDATE; - - if (c->update_id > 0) - c->events |= MPD_IDLE_DATABASE; - } - c->update_id = mpd_status_get_update_id(c->status); - if (c->source == NULL && - c->volume != mpd_status_get_volume(c->status)) - c->events |= MPD_IDLE_MIXER; - c->volume = mpd_status_get_volume(c->status); /* check if the playlist needs an update */ if (c->playlist.version != mpd_status_get_queue_version(c->status)) { bool retval; - if (c->source == NULL) - c->events |= MPD_IDLE_QUEUE; - if (!playlist_is_empty(&c->playlist)) retval = mpdclient_playlist_update_changes(c); else -- 2.30.2