From ca9795c30a9c94fb6b9dd3391546f3332f65b4f2 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 8 Aug 2012 08:34:59 +0200 Subject: conf: add a "database" block The new block overrides the "db_file" setting, and allows configuring any database plugin. --- doc/user.xml | 119 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/conf.c | 1 + src/main.c | 24 +++++++++--- 3 files changed, 138 insertions(+), 6 deletions(-) diff --git a/doc/user.xml b/doc/user.xml index fdfbc4419..942e5c767 100644 --- a/doc/user.xml +++ b/doc/user.xml @@ -164,6 +164,53 @@ systemctl start mpd.socket +
+ Configuring database plugins + + + If a music directory is configured, one database plugin is + used. To configure this plugin, add a + database block to + mpd.conf: + + + database { + plugin "simple" + path "/var/lib/mpd/db" +} + + + + The following table lists the database + options valid for all plugins: + + + + + + + + Name + + + Description + + + + + + + plugin + + + The name of the plugin. + + + + + +
+
Configuring input plugins @@ -617,6 +664,78 @@ systemctl start mpd.socket Plugin reference +
+ Database plugins + +
+ <varname>simple</varname> + + + The default plugin. Stores a copy of the database in + memory. A file is used for permanent storage. + + + + + + + Setting + Description + + + + + + path + + + The path of the database file. + + + + + +
+ +
+ <varname>proxy</varname> + + + Provides access to the database of another MPD instance + using libmpdclient. Experimental! + + + + + + + Setting + Description + + + + + + host + + + The host name of the "master" MPD instance. + + + + + port + + + The port number of the "master" MPD instance. + + + + + +
+
+
Input plugins diff --git a/src/conf.c b/src/conf.c index 167f2da92..5f12d84d9 100644 --- a/src/conf.c +++ b/src/conf.c @@ -102,6 +102,7 @@ static struct config_entry config_entries[] = { { .name = CONF_DESPOTIFY_PASSWORD, false, false}, { .name = CONF_DESPOTIFY_HIGH_BITRATE, false, false }, { .name = "filter", true, true }, + { .name = "database", false, true }, }; static bool diff --git a/src/main.c b/src/main.c index 00bbf7202..8b34bdad4 100644 --- a/src/main.c +++ b/src/main.c @@ -154,35 +154,47 @@ glue_mapper_init(GError **error_r) static bool glue_db_init_and_load(void) { + const struct config_param *param = config_get_param("database"); const struct config_param *path = config_get_param(CONF_DB_FILE); + if (param != NULL && path != NULL) + g_message("Found both 'database' and '" CONF_DB_FILE + "' setting - ignoring the latter"); + GError *error = NULL; bool ret; if (!mapper_has_music_directory()) { + if (param != NULL) + g_message("Found database setting without " + CONF_MUSIC_DIR " - disabling database"); if (path != NULL) g_message("Found " CONF_DB_FILE " setting without " CONF_MUSIC_DIR " - disabling database"); return true; } - if (path == NULL) - MPD_ERROR(CONF_DB_FILE " setting missing"); + struct config_param *allocated = NULL; - struct config_param *param = config_new_param("database", path->line); - config_add_block_param(param, "path", path->value, path->line); + if (param == NULL && path != NULL) { + allocated = config_new_param("database", path->line); + config_add_block_param(allocated, "path", + path->value, path->line); + param = allocated; + } if (!db_init(param, &error)) MPD_ERROR("%s", error->message); - config_param_free(param); + if (allocated != NULL) + config_param_free(allocated); ret = db_load(&error); if (!ret) MPD_ERROR("%s", error->message); /* run database update after daemonization? */ - return db_exists(); + return !db_is_simple() || db_exists(); } /** -- cgit v1.2.3