summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 649df7c)
raw | patch | inline | side by side (parent: 649df7c)
author | Jon Sailor <jsailor@jesnetplus.com> | |
Thu, 22 Dec 2011 11:08:00 +0000 (12:08 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 22 Dec 2011 11:08:00 +0000 (12:08 +0100) |
NEWS | patch | blob | history | |
doc/ncmpc.1 | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/defaults.h | patch | blob | history | |
src/main.c | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history |
index 4e0180bdc9d7e08645f3f0341d6bea732898605d..068baf26619a2c278d559262f057597d8caee559 100644 (file)
--- a/NEWS
+++ b/NEWS
range
* add a doxygen configuration file. Documentation will be generated if the
configure script is called with --enable-documentation
+* configurable timeout for MPD connections
ncmpc 0.19 - (07/23/2011)
diff --git a/doc/ncmpc.1 b/doc/ncmpc.1
index 6f48734ba32c828d827fd80480cba1b44a08fa6f..78c082eaa9bd7582c6466ce30faabdfa93a73385 100644 (file)
--- a/doc/ncmpc.1
+++ b/doc/ncmpc.1
.TP
.B password = PASSWORD
Connect to mpd using the specified password.
+.TP
+.B timeout = TIMEOUT
+Attempt to reconnect to mpd if a response to a command is not received within
+TIMEOUT seconds. Specifying a value in the configuration file overrides the
+"MPD_TIMEOUT" environment variable. If no timeout is specified in the
+configuration file or in the environment, the default is 1.5 seconds.
.SS Interface
.TP
.B enable\-mouse = yes|no
diff --git a/src/conf.c b/src/conf.c
index 9d1f8828d8d28d59dab74bbc71cf8bed4fe54801..9754fbd4b31df78615ccc28c539e9e7d835fabc2 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_HOST "host"
#define CONF_PORT "port"
#define CONF_PASSWORD "password"
+#define CONF_TIMEOUT "timeout"
#define CONF_LYRICS_TIMEOUT "lyrics-timeout"
#define CONF_SCROLL "scroll"
#define CONF_SCROLL_SEP "scroll-sep"
options.port = atoi(get_format(value));
else if (!strcasecmp(CONF_PASSWORD, name))
options.password = get_format(value);
+ else if (!strcasecmp(CONF_TIMEOUT, name))
+ options.timeout_ms = atoi(get_format(value))
+ * 1000 /* seconds -> milliseconds */;
else if (!strcasecmp(CONF_LYRICS_TIMEOUT, name))
#ifdef ENABLE_LYRICS_SCREEN
options.lyrics_timeout = atoi(get_format(value));
diff --git a/src/defaults.h b/src/defaults.h
index fac784d2eaa64012f61cc481e2c9f83f18f659f4..b8bc81ad518bf65ab5abea71c8800834e9f8f4e7 100644 (file)
--- a/src/defaults.h
+++ b/src/defaults.h
#define DEFAULT_TEXT_EDITOR "editor"
+#define DEFAULT_MPD_TIMEOUT 5000 /* 5 seconds */
+
#define DEFAULT_SCROLL TRUE
#define DEFAULT_SCROLL_SEP " *** "
diff --git a/src/main.c b/src/main.c
index 7e3e3df114055dabaa6087c172e6dbf462bc1010..1581e78875658f50fd487015c2cc566fd248d435 100644 (file)
--- a/src/main.c
+++ b/src/main.c
mpdclient_disconnect(mpd);
success = mpdclient_connect(mpd,
options.host, options.port,
- 5000,
+ options.timeout_ms,
options.password);
if (!success) {
/* try again in 5 seconds */
diff --git a/src/options.c b/src/options.c
index 47fc3b9715e72829758d811642b426bac4d7012b..1b3e9af09cbfb31e7edf7e79ef41d39094214c92 100644 (file)
--- a/src/options.c
+++ b/src/options.c
.audible_bell = true,
.bell_on_wrap = true,
.status_message_time = 3,
+ .timeout_ms = DEFAULT_MPD_TIMEOUT,
#ifndef NCMPC_MINI
.scroll = DEFAULT_SCROLL,
.welcome_screen_list = true,
#ifndef NCMPC_MINI
options.scroll_sep = g_strdup(DEFAULT_SCROLL_SEP);
#endif
+ if (getenv("MPD_TIMEOUT") != NULL)
+ /* let libmpdclient parse the environment variable */
+ options.timeout_ms = 0;
}
void
diff --git a/src/options.h b/src/options.h
index fc9f7a1e1c99682f4f7099568b3fe94dc2d2f883..6b1da8bfcc3f110b6925687056cd60369bc65704 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char **screen_list;
bool display_remaining_time;
int port;
+ int timeout_ms;
int crossfade_time;
int search_mode;
int hide_cursor;