[Pkg-mpd-commits] [mpdscribble] 01/02: lmc: require MPD 0.16

Andrey Rahmatullin wrar-guest at moszumanska.debian.org
Wed Feb 12 21:45:40 UTC 2014


This is an automated email from the git hooks/post-receive script.

wrar-guest pushed a commit to branch upstream
in repository mpdscribble.

commit f5d0684bc2a1acc2d3bfffdb9267ec0506b34314
Author: Max Kellermann <max at duempel.org>
Date:   Fri Dec 13 11:14:52 2013 +0100

    lmc: require MPD 0.16
    
    Eliminate the "polling" mode and remove the deprecated "sleep"
    setting.
---
 NEWS       |  1 +
 src/file.c |  4 ----
 src/file.h |  1 -
 src/lmc.c  | 53 ++++++++++++++++++-----------------------------------
 4 files changed, 19 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 7802263..dd8073b 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,7 @@
 mpdscribble 0.23 - not yet released
   * fix build failure with GLib < 2.16
   * soup: always send the User-Agent request header
+  * require MPD 0.16
 
 
 mpdscribble 0.22 - 2011-07-09
diff --git a/src/file.c b/src/file.c
index e939411..06f1dd2 100644
--- a/src/file.c
+++ b/src/file.c
@@ -48,7 +48,6 @@
 
 struct config file_config = {
 	.port = 0,
-	.sleep = -1,
 	.journal_interval = 600,
 	.verbose = -1,
 	.loc = file_unknown,
@@ -293,7 +292,6 @@ load_config_file(const char *path)
 	load_string(file, "host", &file_config.host);
 	load_unsigned(file, "port", &file_config.port);
 	load_string(file, "proxy", &file_config.proxy);
-	load_integer(file, "sleep", &file_config.sleep);
 	if (!load_unsigned(file, "journal_interval",
 			   &file_config.journal_interval))
 		load_unsigned(file, "cache_interval",
@@ -336,8 +334,6 @@ int file_read_config(void)
 
 	if (!file_config.proxy)
 		file_config.proxy = getenv("http_proxy");
-	if (file_config.sleep <= 0)
-		file_config.sleep = 1;
 	if (file_config.verbose == -1)
 		file_config.verbose = 1;
 
diff --git a/src/file.h b/src/file.h
index d660475..c4a999e 100644
--- a/src/file.h
+++ b/src/file.h
@@ -37,7 +37,6 @@ struct config {
 	char *host;
 	char *proxy;
 	unsigned port;
-	int sleep;
 
 	/**
 	 * The interval in seconds after which the journal is saved to
diff --git a/src/lmc.c b/src/lmc.c
index a85d186..0a6407c 100644
--- a/src/lmc.c
+++ b/src/lmc.c
@@ -36,7 +36,7 @@
 #include <unistd.h>
 
 static struct mpd_connection *g_mpd;
-static bool idle_supported, idle_notified;
+static bool idle_notified;
 static unsigned last_id = -1;
 static struct mpd_song *current_song;
 static bool was_paused;
@@ -116,17 +116,23 @@ connection_settings_name(const struct mpd_connection *connection)
 static gboolean
 lmc_reconnect(G_GNUC_UNUSED gpointer data)
 {
-	const unsigned *version;
-
 	g_mpd = mpd_connection_new(g_host, g_port, 0);
 	if (mpd_connection_get_error(g_mpd) != MPD_ERROR_SUCCESS) {
 		lmc_failure();
 		return true;
 	}
 
-	idle_supported = mpd_connection_cmp_server_version(g_mpd, 0, 14, 0) >= 0;
+	const unsigned *version = mpd_connection_get_server_version(g_mpd);
+
+	if (mpd_connection_cmp_server_version(g_mpd, 0, 16, 0) < 0) {
+		g_warning("Error: MPD version %d.%d.%d is too old (%s needed)",
+			  version[0], version[1], version[2],
+			  "0.16.0");
+		mpd_connection_free(g_mpd);
+		g_mpd = NULL;
+		return true;
+	}
 
-	version = mpd_connection_get_server_version(g_mpd);
 	char *name = connection_settings_name(g_mpd);
 	g_message("connected to mpd %i.%i.%i at %s\n",
 		  version[0], version[1], version[2],
@@ -265,13 +271,9 @@ lmc_update(G_GNUC_UNUSED gpointer data)
 			song_paused();
 		was_paused = true;
 
-		if (idle_supported) {
-			lmc_schedule_idle();
-			update_source_id = 0;
-			return false;
-		}
-
-		return true;
+		lmc_schedule_idle();
+		update_source_id = 0;
+		return false;
 	} else if (state != MPD_STATE_PLAY) {
 		current_song = NULL;
 		last_id = -1;
@@ -325,13 +327,9 @@ lmc_update(G_GNUC_UNUSED gpointer data)
 		return false;
 	}
 
-	if (idle_supported) {
-		lmc_schedule_idle();
-		update_source_id = 0;
-		return false;
-	}
-
-	return true;
+	lmc_schedule_idle();
+	update_source_id = 0;
+	return false;
 }
 
 static void
@@ -339,8 +337,7 @@ lmc_schedule_update(void)
 {
 	assert(update_source_id == 0);
 
-	update_source_id = g_timeout_add_seconds(idle_supported ? 0 : file_config.sleep,
-						 lmc_update, NULL);
+	update_source_id = g_timeout_add_seconds(0, lmc_update, NULL);
 }
 
 #if LIBMPDCLIENT_CHECK_VERSION(2,5,0)
@@ -387,20 +384,6 @@ lmc_idle(G_GNUC_UNUSED GIOChannel *source,
 	idle = mpd_recv_idle(g_mpd, false);
 	success = mpd_response_finish(g_mpd);
 
-	if (!success && mpd_connection_get_error(g_mpd) == MPD_ERROR_SERVER &&
-	    mpd_connection_get_server_error(g_mpd) == MPD_SERVER_ERROR_UNKNOWN_CMD &&
-	    mpd_connection_clear_error(g_mpd)) {
-		/* MPD does not recognize the "idle" command - disable
-		   it for this connection */
-
-		g_message("MPD does not support the 'idle' command - "
-			  "falling back to polling\n");
-
-		idle_supported = false;
-		lmc_schedule_update();
-		return false;
-	}
-
 	if (!success) {
 		lmc_failure();
 		lmc_schedule_reconnect();

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-mpd/mpdscribble.git



More information about the Pkg-mpd-commits mailing list