summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 839c91c)
raw | patch | inline | side by side (parent: 839c91c)
author | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:26:31 +0000 (22:26 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 29 Sep 2009 20:26:31 +0000 (22:26 +0200) |
.. and disable recovery with mpdclient_handle_error().
src/main.c | patch | blob | history | |
src/mpdclient.c | patch | blob | history | |
src/mpdclient.h | patch | blob | history |
diff --git a/src/main.c b/src/main.c
index 6010482a45a45dc58ac28a703ceac5036ef4a5a5..0cbe184bca87554ce95c9a114df8820bacf40698 100644 (file)
--- a/src/main.c
+++ b/src/main.c
static gboolean
timer_reconnect(G_GNUC_UNUSED gpointer data)
{
- int ret;
+ bool success;
assert(!mpdclient_is_connected(mpd));
doupdate();
mpdclient_disconnect(mpd);
- ret = mpdclient_connect(mpd,
- options.host, options.port,
- 1.5,
- options.password);
- if (ret != 0) {
+ success = mpdclient_connect(mpd,
+ options.host, options.port,
+ 1.5,
+ options.password);
+ if (!success) {
/* try again in 5 seconds */
g_timeout_add(5000, timer_reconnect, NULL);
return FALSE;
diff --git a/src/mpdclient.c b/src/mpdclient.c
index 58094a94741852fcfa1f3e7f0ee63b8da9f96004..179aecc2c5c8bd6b24b2c6f1819c01db9912993a 100644 (file)
--- a/src/mpdclient.c
+++ b/src/mpdclient.c
c->song = NULL;
}
-gint
+bool
mpdclient_connect(struct mpdclient *c,
const gchar *host,
gint port,
g_error("Out of memory");
if (mpd_connection_get_error(c->connection) != MPD_ERROR_SUCCESS) {
- retval = mpdclient_handle_error(c);
- if (retval != 0) {
- mpd_connection_free(c->connection);
- c->connection = NULL;
- }
-
- return retval;
+ mpdclient_handle_error(c);
+ mpdclient_disconnect(c);
+ return false;
}
/* send password */
retval = mpdclient_finish_command(c);
}
- return retval;
+ return true;
}
gint
diff --git a/src/mpdclient.h b/src/mpdclient.h
index d7fd555e808f78237f00cc969fb335b2242a6096..fa2f1b61dae81096377a5442dcb84cf2d378716d 100644 (file)
--- a/src/mpdclient.h
+++ b/src/mpdclient.h
return c->connection != NULL;
}
-gint mpdclient_connect(struct mpdclient *c, const gchar *host, gint port,
- gfloat timeout_, const gchar *password);
+bool
+mpdclient_connect(struct mpdclient *c, const gchar *host, gint port,
+ gfloat timeout_, const gchar *password);
void
mpdclient_disconnect(struct mpdclient *c);