From 7853f802698886991d1ba1e9c9ad0512186de97a Mon Sep 17 00:00:00 2001 From: chme Date: Thu, 30 May 2019 08:20:00 +0200 Subject: [PATCH 1/4] [conf] Readd old config options in mpd section as deprecated --- forked-daapd.conf.in | 4 ++-- src/conffile.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/forked-daapd.conf.in b/forked-daapd.conf.in index 329be07f..88029508 100644 --- a/forked-daapd.conf.in +++ b/forked-daapd.conf.in @@ -193,13 +193,13 @@ library { # rating_updates = false # Allows creating, deleting and modifying m3u playlists in the library directories. + # Only supported by the player web interface and some mpd clients # Defaults to being disabled. # allow_modifying_stored_playlists = false # A directory in one of the library directories that will be used as the default # playlist directory. forked-dapd creates new playlists in this directory if only - # a playlist name is provided by the mpd client (requires "allow_modify_stored_playlists" - # set to true). + # a playlist name is provided (requires "allow_modify_stored_playlists" set to true). # default_playlist_directory = "" } diff --git a/src/conffile.c b/src/conffile.c index 51210cee..00088293 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -180,6 +180,8 @@ static cfg_opt_t sec_mpd[] = CFG_INT("port", 6600, CFGF_NONE), CFG_INT("http_port", 0, CFGF_NONE), CFG_BOOL("clear_queue_on_stop_disable", cfg_false, CFGF_NONE), + CFG_BOOL("allow_modifying_stored_playlists", cfg_false, CFGF_NODEFAULT | CFGF_DEPRECATED), + CFG_STR("default_playlist_directory", NULL, CFGF_NODEFAULT | CFGF_DEPRECATED), CFG_END() }; From 9cc73815514fb64f4001fc2199bac3caafd6174d Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 15 Jun 2019 09:19:14 +0200 Subject: [PATCH 2/4] [configure] Require libconfuse >= 3.0.0 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 9ec5eb10..cc2f8374 100644 --- a/configure.ac +++ b/configure.ac @@ -112,7 +112,7 @@ FORK_FUNC_REQUIRE([COMMON], [GNU libunistring], [LIBUNISTRING], [unistring], [unistring], [u8_strconv_from_locale], [uniconv.h])]) FORK_MODULES_CHECK([FORKED], [ZLIB], [zlib], [deflate], [zlib.h]) -FORK_MODULES_CHECK([FORKED], [CONFUSE], [libconfuse], [cfg_init], [confuse.h]) +FORK_MODULES_CHECK([FORKED], [CONFUSE], [libconfuse >= 3.0.0], [cfg_init], [confuse.h]) FORK_MODULES_CHECK([FORKED], [MINIXML], [mxml], [mxmlNewElement], [mxml.h], [AC_CHECK_FUNCS([mxmlGetOpaque] [mxmlGetText] [mxmlGetType] [mxmlGetFirstChild])]) From 9351d905f24424fbd95efc4a8cead0c4c41f3299 Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 15 Jun 2019 09:19:41 +0200 Subject: [PATCH 3/4] [mpd] Handle deprecated config options gracefully --- src/mpd.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/mpd.c b/src/mpd.c index 5ac07544..97b59c0e 100644 --- a/src/mpd.c +++ b/src/mpd.c @@ -4848,6 +4848,21 @@ int mpd_init(void) if (pl_dir) default_pl_dir = safe_asprintf("/file:%s", pl_dir); + /* Handle deprecated config options */ + if (0 < cfg_opt_size(cfg_getopt(cfg_getsec(cfg, "mpd"), "allow_modifying_stored_playlists"))) + { + DPRINTF(E_LOG, L_MPD, "Found deprecated option 'allow_modifying_stored_playlists' in section 'mpd', please update configuration file (move option to section 'library').\n"); + allow_modifying_stored_playlists = cfg_getbool(cfg_getsec(cfg, "mpd"), "allow_modifying_stored_playlists"); + } + if (0 < cfg_opt_size(cfg_getopt(cfg_getsec(cfg, "mpd"), "default_playlist_directory"))) + { + DPRINTF(E_LOG, L_MPD, "Found deprecated option 'default_playlist_directory' in section 'mpd', please update configuration file (move option to section 'library').\n"); + free(default_pl_dir); + pl_dir = cfg_getstr(cfg_getsec(cfg, "mpd"), "default_playlist_directory"); + if (pl_dir) + default_pl_dir = safe_asprintf("/file:%s", pl_dir); + } + DPRINTF(E_INFO, L_MPD, "mpd thread init\n"); ret = pthread_create(&tid_mpd, NULL, mpd, NULL); From 94af51f19b1ae531751ebaca1b7b578f4049091f Mon Sep 17 00:00:00 2001 From: chme Date: Sat, 15 Jun 2019 12:08:56 +0200 Subject: [PATCH 4/4] [conf/logger] Log error message from libconfuse in forked-daapd log --- src/conffile.c | 15 +++++++++++++++ src/logger.c | 11 +++++++++++ src/logger.h | 3 +++ 3 files changed, 29 insertions(+) diff --git a/src/conffile.c b/src/conffile.c index 00088293..b67d9e65 100644 --- a/src/conffile.c +++ b/src/conffile.c @@ -206,6 +206,19 @@ uid_t runas_uid; gid_t runas_gid; +static void +logger_confuse(cfg_t *cfg, const char *format, va_list args) +{ + char fmt[80]; + + if (cfg && cfg->name && cfg->line) + snprintf(fmt, sizeof(fmt), "[%s:%d] %s\n", cfg->name, cfg->line, format); + else + snprintf(fmt, sizeof(fmt), "%s\n", format); + + DVPRINTF(E_LOG, L_CONF, fmt, args); +} + static int cb_loglevel(cfg_t *cfg, cfg_opt_t *opt, const char *value, void *result) { @@ -355,6 +368,8 @@ conffile_load(char *file) cfg = cfg_init(toplvl_cfg, CFGF_NONE); + cfg_set_error_function(cfg, logger_confuse); + ret = cfg_parse(cfg, file); if (ret == CFG_FILE_ERROR) diff --git a/src/logger.c b/src/logger.c index 34e47db1..e72bad99 100644 --- a/src/logger.c +++ b/src/logger.c @@ -174,6 +174,17 @@ DPRINTF(int severity, int domain, const char *fmt, ...) va_end(ap); } +void +DVPRINTF(int severity, int domain, const char *fmt, va_list ap) +{ + // If domain and severity do not match the current log configuration, return early to + // safe some unnecessary code execution (tiny performance gain) + if (logger_initialized && (!((1 << domain) & logdomains) || (severity > threshold))) + return; + + vlogger(severity, domain, fmt, ap); +} + void logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap) { diff --git a/src/logger.h b/src/logger.h index 0f94190d..2d7bd86d 100644 --- a/src/logger.h +++ b/src/logger.h @@ -52,6 +52,9 @@ void DPRINTF(int severity, int domain, const char *fmt, ...) __attribute__((format(printf, 3, 4))); +void +DVPRINTF(int severity, int domain, const char *fmt, va_list ap); + void logger_ffmpeg(void *ptr, int level, const char *fmt, va_list ap);