From fa76b6380cf1ed4618d16381af71ff20b69a9c6a Mon Sep 17 00:00:00 2001 From: Wolfgang Scherer Date: Thu, 16 Nov 2017 23:23:53 +0100 Subject: [PATCH] [mpd] correct handling of `noidle` command --- src/mpd.c | 42 +++++++++--------------------------------- 1 file changed, 9 insertions(+), 33 deletions(-) diff --git a/src/mpd.c b/src/mpd.c index 620b40f1..25200946 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -632,6 +632,7 @@ mpd_command_currentsong(struct evbuffer *evbuf, int argc, char **argv, char **er static int mpd_notify_idle_client(struct mpd_client_ctx *client_ctx, short events); + /* * Example input: * idle "database" "mixer" "options" "output" "player" "playlist" "sticker" "update" @@ -679,41 +680,16 @@ mpd_command_idle(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, s return 0; } -//static void -//mpd_remove_client(struct evbuffer *evbuf) -//{ -// struct idle_client *client; -// struct idle_client *prev; -// -// client = idle_clients; -// prev = NULL; -// -// while (client) -// { -// if (client->evbuffer == evbuf) -// { -// DPRINTF(E_DBG, L_MPD, "Removing idle client for evbuffer\n"); -// -// if (prev) -// prev->next = client->next; -// else -// idle_clients = client->next; -// -// free(client); -// break; -// } -// -// prev = client; -// client = client->next; -// } -//} - static int mpd_command_noidle(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, struct mpd_client_ctx *ctx) { - ctx->is_idle = false; - ctx->idle_events = 0; - return 0; + /* + * The protocol specifies: "The idle command can be canceled by + * sending the command noidle (no other commands are allowed). MPD + * will then leave idle mode and print results immediately; might be + * empty at this time." + */ + return mpd_notify_idle_client(ctx, 0); } /* @@ -859,7 +835,7 @@ mpd_command_stats(struct evbuffer *evbuf, int argc, char **argv, char **errmsg, "songs: %d\n" "uptime: %d\n" //in seceonds "db_playtime: %" PRIi64 "\n" - "db_update: %ld\n" + "db_update: %" PRIi64 "\n" "playtime: %d\n", artists, albums,