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)
This commit is contained in:
Andrzej Rybczak
2009-12-23 16:21:11 +01:00
parent c005b7b303
commit 2fb20fd572
7 changed files with 15 additions and 1 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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);

View File

@@ -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";

View File

@@ -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;