From 2fb20fd572e8979722fb6e49d9858591dd06be0b Mon Sep 17 00:00:00 2001 From: Andrzej Rybczak Date: Wed, 23 Dec 2009 16:21:11 +0100 Subject: [PATCH] add config options for communication mode with mpd (polling for default) idle support in ncmpcpp is marked experimental since its support in mpd is not ready for general use in full featured clients (see bug 2612) --- doc/config | 2 ++ doc/ncmpcpp.1 | 3 +++ src/mpdpp.cpp | 2 +- src/mpdpp.h | 2 ++ src/ncmpcpp.cpp | 1 + src/settings.cpp | 5 +++++ src/settings.h | 1 + 7 files changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/config b/doc/config index be9fd00..c6255fe 100644 --- a/doc/config +++ b/doc/config @@ -17,6 +17,8 @@ # #mpd_crossfade_time = "5" # +#mpd_communication_mode = "polling" (polling/notifications) +# ##### music visualizer ##### ## ## Note: In order to make music visualizer work you'll diff --git a/doc/ncmpcpp.1 b/doc/ncmpcpp.1 index 0b75e95..cee0a40 100644 --- a/doc/ncmpcpp.1 +++ b/doc/ncmpcpp.1 @@ -69,6 +69,9 @@ Set connection timeout to MPD to given value. .B mpd_crossfade_time = SECONDS Default number of seconds to crossfade, if enabled by ncmpcpp. .TP +.B mpd_communication_mode = MODE +If set to 'polling', ncmpcpp will constantly poll mpd for its status. If set to 'notifications', ncmppcp will make use of 'idle' command and wait for events. This is more efficient and responsive, but kinda experimental. If you decide to use it, you may want to run the latest mpd version available. +.TP .B visualizer_fifo_path = PATH Path to mpd fifo output. This is needed to make music visualizer work (note that output sound format of this fifo has to be 44100:16:1) .TP diff --git a/src/mpdpp.cpp b/src/mpdpp.cpp index 44f4b44..aef39c3 100644 --- a/src/mpdpp.cpp +++ b/src/mpdpp.cpp @@ -72,7 +72,7 @@ bool Connection::Connect() if (!itsPassword.empty()) SendPassword(); itsFD = mpd_connection_get_fd(itsConnection); - supportsIdle = Version() > 13; + supportsIdle = isIdleEnabled && Version() > 13; // in UpdateStatus() we compare it to itsElapsedTimer[0], // and for the first time it has always evaluate to true // so we need it to be zero at this point diff --git a/src/mpdpp.h b/src/mpdpp.h index 4cda1e7..25d1f4d 100644 --- a/src/mpdpp.h +++ b/src/mpdpp.h @@ -94,6 +94,7 @@ namespace MPD float Version() const; + void SetIdleEnabled(bool val) { isIdleEnabled = val; } bool SupportsIdle() const { return supportsIdle; } void OrderDataFetching() { hasData = 1; } int GetFD() const { return itsFD; } @@ -223,6 +224,7 @@ namespace MPD int itsFD; bool isIdle; + bool isIdleEnabled; bool supportsIdle; bool hasData; diff --git a/src/ncmpcpp.cpp b/src/ncmpcpp.cpp index 1a7325e..cca961d 100644 --- a/src/ncmpcpp.cpp +++ b/src/ncmpcpp.cpp @@ -241,6 +241,7 @@ int main(int argc, char *argv[]) Mpd.SetPort(Config.mpd_port); Mpd.SetTimeout(Config.mpd_connection_timeout); + Mpd.SetIdleEnabled(Config.enable_idle_notifications); if (argc > 1) ParseArgv(argc, argv); diff --git a/src/settings.cpp b/src/settings.cpp index 80a7abe..7e5cb44 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -284,6 +284,7 @@ void DefaultConfiguration(ncmpcpp_config &conf) conf.window_border = brGreen; conf.active_window_border = brRed; conf.media_lib_primary_tag = MPD_TAG_ARTIST; + conf.enable_idle_notifications = false; conf.colors_enabled = true; conf.fancy_scrolling = true; conf.playlist_show_remaining_time = false; @@ -715,6 +716,10 @@ void ReadConfiguration(ncmpcpp_config &conf) if (!v.empty()) conf.color2 = IntoColor(v); } + else if (cl.find("mpd_communication_mode") != std::string::npos) + { + conf.enable_idle_notifications = v == "notifications"; + } else if (cl.find("colors_enabled") != std::string::npos) { conf.colors_enabled = v == "yes"; diff --git a/src/settings.h b/src/settings.h index 5b447b6..9baaea8 100644 --- a/src/settings.h +++ b/src/settings.h @@ -176,6 +176,7 @@ struct ncmpcpp_config mpd_tag_type media_lib_primary_tag; + bool enable_idle_notifications; bool colors_enabled; bool fancy_scrolling; bool playlist_show_remaining_time; -- 2.11.4.GIT