From: Max Kellermann Date: Fri, 2 Oct 2009 07:19:09 +0000 (+0200) Subject: use mpdclient_is_connected() X-Git-Tag: release-0.16~218 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=fca2567482e65fe3bf3bc9f04015fab6ea27a692;p=ncmpc.git use mpdclient_is_connected() .. instead of accessing mpdclient.connection directly. --- diff --git a/src/mpdclient.c b/src/mpdclient.c index fd223d6..9a9154c 100644 --- a/src/mpdclient.c +++ b/src/mpdclient.c @@ -37,7 +37,7 @@ static bool MPD_ERROR(const struct mpdclient *client) { - return client->connection == NULL || + return !mpdclient_is_connected(client) || mpd_connection_get_error(client->connection) != MPD_ERROR_SUCCESS; } diff --git a/src/player_command.c b/src/player_command.c index 507e697..337d767 100644 --- a/src/player_command.c +++ b/src/player_command.c @@ -35,6 +35,11 @@ commit_seek(struct mpdclient *c) if (seek_id < 0) return; + if (!mpdclient_is_connected(c)) { + seek_id = -1; + return; + } + if (c->song != NULL && (unsigned)seek_id == mpd_song_get_id(c->song)) if (!mpd_run_seek_id(c->connection, seek_id, seek_target_time)) mpdclient_handle_error(c); @@ -78,7 +83,7 @@ handle_player_command(struct mpdclient *c, command_t cmd) { const struct mpd_song *song; - if (c->connection == NULL || c->status == NULL) + if (!mpdclient_is_connected(c) || c->status == NULL) return false; cancel_seek_timer(); diff --git a/src/screen_client.c b/src/screen_client.c index 2d39a29..9d60ed2 100644 --- a/src/screen_client.c +++ b/src/screen_client.c @@ -73,7 +73,7 @@ screen_database_update(struct mpdclient *c, const char *path) unsigned id; assert(c != NULL); - assert(c->connection != NULL); + assert(mpdclient_is_connected(c)); id = mpd_run_update(c->connection, path); if (id == 0) { diff --git a/src/screen_outputs.c b/src/screen_outputs.c index cd3a443..1d60bae 100644 --- a/src/screen_outputs.c +++ b/src/screen_outputs.c @@ -107,7 +107,7 @@ fill_outputs_list(struct mpdclient *c) assert(mpd_outputs != NULL); - if (c->connection == NULL) + if (!mpdclient_is_connected(c)) return; mpd_send_outputs(c->connection); diff --git a/src/screen_search.c b/src/screen_search.c index 5434738..3829f8d 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -300,7 +300,7 @@ search_advanced_query(char *query, struct mpdclient *c) static void search_new(struct mpdclient *c) { - if (c->connection == NULL) + if (!mpdclient_is_connected(c)) return; search_clear(true);