Code

use mpdclient_is_connected()
authorMax Kellermann <max@duempel.org>
Fri, 2 Oct 2009 07:19:09 +0000 (09:19 +0200)
committerMax Kellermann <max@duempel.org>
Fri, 2 Oct 2009 07:19:09 +0000 (09:19 +0200)
.. instead of accessing mpdclient.connection directly.

src/mpdclient.c
src/player_command.c
src/screen_client.c
src/screen_outputs.c
src/screen_search.c

index fd223d6f80ea5b9a5834bfd58277cf0f368f9111..9a9154caafb4f57de45d462dc7db54218a140af2 100644 (file)
@@ -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;
 }
 
index 507e697b82ffab61e1884639bb7b505696d57a76..337d7677d6d7334fc4453be4bf05b691614f9457 100644 (file)
@@ -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();
index 2d39a29a591f29d47b1b5c9d0f133223604f7050..9d60ed2cd6943cbd018653fdcc0bc4338d53ffc9 100644 (file)
@@ -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) {
index cd3a4435a9148aa664534a5ea7cb37504c7bf63b..1d60bae6feedf2cc66213315d1879018f5b0a884 100644 (file)
@@ -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);
index 5434738660830b3ddd6e29221cb71b95c53c8ed3..3829f8dfa1bcbbd3d037265db62906c4058cd6f7 100644 (file)
@@ -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);