From c269b3ef9ef00d60c20d265641c932b65b41f475 Mon Sep 17 00:00:00 2001 From: Marc Pavot Date: Fri, 28 Nov 2008 00:40:43 +0100 Subject: [PATCH] New disconnect event A IDLE_DISCONNECT event is notified to client application if the connection is closed when the application is in idle mode. --- include/mpd/idle.h | 3 +++ src/idle.c | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/include/mpd/idle.h b/include/mpd/idle.h index 27b1675..bc6b413 100644 --- a/include/mpd/idle.h +++ b/include/mpd/idle.h @@ -58,6 +58,9 @@ enum { /** options have changed: crossfade, random, repeat, ... */ IDLE_OPTIONS = 0x40, + + /** MPD closed the connection or the connection was lost */ + IDLE_DISCONNECT = 0x80, }; typedef void (*mpd_NotificationCb) (struct mpd_connection *connection, unsigned flags, void *userdata); diff --git a/src/idle.c b/src/idle.c index 58db6b1..056f886 100644 --- a/src/idle.c +++ b/src/idle.c @@ -54,6 +54,11 @@ static void mpd_readChanges(struct mpd_connection *connection) if (!connection->returnElement) mpd_getNextReturnElement(connection); + if (connection->error == MPD_ERROR_CONNCLOSED) { + connection->notify_cb (connection, IDLE_DISCONNECT, connection->userdata); + return; + } + while (connection->returnElement) { re = connection->returnElement; if (re->name &&!strncmp (re->name, "changed", strlen ("changed"))) { -- 2.11.4.GIT