summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 445a3a0)
raw | patch | inline | side by side (parent: 445a3a0)
author | Max Kellermann <max.kellermann@gmail.com> | |
Fri, 17 Mar 2017 22:15:56 +0000 (23:15 +0100) | ||
committer | Max Kellermann <max.kellermann@gmail.com> | |
Fri, 17 Mar 2017 22:30:43 +0000 (23:30 +0100) |
Prepare for asynchronous connect.
src/main.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 177f1b529be07e0506fe8d245bf82b5d78c94ceb..ec051f4a8c83de04a54b1e9983910a3847614662 100644 (file)
--- a/src/main.c
+++ b/src/main.c
static gboolean
timer_reconnect(gcc_unused gpointer data)
{
- assert(!mpdclient_is_connected(mpd));
+ assert(mpdclient_is_dead(mpd));
reconnect_source_id = 0;
static void
check_reconnect(void)
{
- if (!mpdclient_is_connected(mpd) && reconnect_source_id == 0)
+ if (mpdclient_is_dead(mpd) && reconnect_source_id == 0)
/* reconnect when the connection is lost */
reconnect_source_id = g_timeout_add(1000, timer_reconnect,
NULL);
diff --git a/src/mpdclient.h b/src/mpdclient.h
index 7756710173a368116e2165f161bf346919bde78f..84878466d22e7a08bc40f42330502745f4f048e9 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
return c->connection != NULL;
}
+/**
+ * Is this object "dead"? i.e. not connected and not currently doing
+ * anything to connect.
+ */
+gcc_pure
+static inline bool
+mpdclient_is_dead(const struct mpdclient *c)
+{
+ return c->connection == NULL;
+}
+
gcc_pure
static inline bool
mpdclient_is_playing(const struct mpdclient *c)