diff --git a/doc/config b/doc/config index be9fd00d..c6255fe0 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 0b75e95a..cee0a40e 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 44f4b447..aef39c37 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 4cda1e7b..25d1f4dd 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 1a7325e8..cca961d5 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 80a7abee..7e5cb443 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 5b447b6a..9baaea8f 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;