archive/List: add option to disable archive plugins in mpd.conf
Closes https://github.com/MusicPlayerDaemon/MPD/issues/1384
This commit is contained in:
parent
d3db0400b0
commit
fdc0329e64
2
NEWS
2
NEWS
|
@ -2,6 +2,8 @@ ver 0.24 (not yet released)
|
||||||
* protocol
|
* protocol
|
||||||
- "playlistfind"/"playlistsearch" have "sort" and "window" parameters
|
- "playlistfind"/"playlistsearch" have "sort" and "window" parameters
|
||||||
- filter "prio" (for "playlistfind"/"playlistsearch")
|
- filter "prio" (for "playlistfind"/"playlistsearch")
|
||||||
|
* archive
|
||||||
|
- add option to disable archive plugins in mpd.conf
|
||||||
* player
|
* player
|
||||||
- add option "mixramp_analyzer" to scan MixRamp tags on-the-fly
|
- add option "mixramp_analyzer" to scan MixRamp tags on-the-fly
|
||||||
* tags
|
* tags
|
||||||
|
|
|
@ -1395,6 +1395,8 @@ xspf
|
||||||
Reads XSPF playlist files.
|
Reads XSPF playlist files.
|
||||||
|
|
||||||
|
|
||||||
|
.. _archive_plugins:
|
||||||
|
|
||||||
Archive plugins
|
Archive plugins
|
||||||
===============
|
===============
|
||||||
|
|
||||||
|
|
29
doc/user.rst
29
doc/user.rst
|
@ -341,6 +341,35 @@ The following table lists the input options valid for all plugins:
|
||||||
|
|
||||||
More information can be found in the :ref:`input_plugins` reference.
|
More information can be found in the :ref:`input_plugins` reference.
|
||||||
|
|
||||||
|
Configuring archive plugins
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
To configure an archive plugin, add an :code:`archive_plugin` block to
|
||||||
|
:file:`mpd.conf`:
|
||||||
|
|
||||||
|
.. code-block:: none
|
||||||
|
|
||||||
|
archive_plugin {
|
||||||
|
name "zzip"
|
||||||
|
enabled "no"
|
||||||
|
}
|
||||||
|
|
||||||
|
The following table lists the input options valid for all plugins:
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:widths: 20 80
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
* - Name
|
||||||
|
- Description
|
||||||
|
* - **name**
|
||||||
|
- The name of the plugin
|
||||||
|
* - **enabled yes|no**
|
||||||
|
- Allows you to disable a plugin without recompiling. By
|
||||||
|
default, all plugins are enabled.
|
||||||
|
|
||||||
|
More information can be found in the :ref:`archive_plugins` reference.
|
||||||
|
|
||||||
.. _input_cache:
|
.. _input_cache:
|
||||||
|
|
||||||
Configuring the Input Cache
|
Configuring the Input Cache
|
||||||
|
|
|
@ -385,7 +385,7 @@ MainConfigured(const CommandLineOptions &options,
|
||||||
initPermissions(raw_config);
|
initPermissions(raw_config);
|
||||||
spl_global_init(raw_config);
|
spl_global_init(raw_config);
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
const ScopeArchivePluginsInit archive_plugins_init;
|
const ScopeArchivePluginsInit archive_plugins_init{raw_config};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
pcm_convert_global_init(raw_config);
|
pcm_convert_global_init(raw_config);
|
||||||
|
|
|
@ -20,6 +20,8 @@
|
||||||
#include "ArchiveList.hxx"
|
#include "ArchiveList.hxx"
|
||||||
#include "ArchivePlugin.hxx"
|
#include "ArchivePlugin.hxx"
|
||||||
#include "archive/Features.h"
|
#include "archive/Features.h"
|
||||||
|
#include "config/Data.hxx"
|
||||||
|
#include "config/Block.hxx"
|
||||||
#include "util/StringUtil.hxx"
|
#include "util/StringUtil.hxx"
|
||||||
#include "plugins/Bzip2ArchivePlugin.hxx"
|
#include "plugins/Bzip2ArchivePlugin.hxx"
|
||||||
#include "plugins/Iso9660ArchivePlugin.hxx"
|
#include "plugins/Iso9660ArchivePlugin.hxx"
|
||||||
|
@ -74,10 +76,21 @@ archive_plugin_from_name(const char *name) noexcept
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void archive_plugin_init_all()
|
void
|
||||||
|
archive_plugin_init_all(const ConfigData &config)
|
||||||
{
|
{
|
||||||
|
ConfigBlock empty;
|
||||||
|
|
||||||
for (unsigned i = 0; archive_plugins[i] != nullptr; ++i) {
|
for (unsigned i = 0; archive_plugins[i] != nullptr; ++i) {
|
||||||
const auto &plugin = *archive_plugins[i];
|
const auto &plugin = *archive_plugins[i];
|
||||||
|
|
||||||
|
const auto *param =
|
||||||
|
config.FindBlock(ConfigBlockOption::ARCHIVE_PLUGIN,
|
||||||
|
"name", plugin.name);
|
||||||
|
if (param != nullptr && !param->GetBlockValue("enabled", true))
|
||||||
|
/* the plugin is disabled in mpd.conf */
|
||||||
|
continue;
|
||||||
|
|
||||||
if (plugin.init == nullptr || plugin.init())
|
if (plugin.init == nullptr || plugin.init())
|
||||||
archive_plugins_enabled[i] = true;
|
archive_plugins_enabled[i] = true;
|
||||||
}
|
}
|
||||||
|
@ -86,8 +99,9 @@ void archive_plugin_init_all()
|
||||||
void
|
void
|
||||||
archive_plugin_deinit_all() noexcept
|
archive_plugin_deinit_all() noexcept
|
||||||
{
|
{
|
||||||
|
unsigned i = 0;
|
||||||
archive_plugins_for_each_enabled(plugin)
|
archive_plugins_for_each_enabled(plugin)
|
||||||
if (plugin->finish != nullptr)
|
if (archive_plugins_enabled[i++] && plugin->finish != nullptr)
|
||||||
plugin->finish();
|
plugin->finish();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
|
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
struct ConfigData;
|
||||||
struct ArchivePlugin;
|
struct ArchivePlugin;
|
||||||
|
|
||||||
extern const ArchivePlugin *const archive_plugins[];
|
extern const ArchivePlugin *const archive_plugins[];
|
||||||
|
@ -42,7 +43,7 @@ archive_plugin_from_name(const char *name) noexcept;
|
||||||
|
|
||||||
/* this is where we "load" all the "plugins" ;-) */
|
/* this is where we "load" all the "plugins" ;-) */
|
||||||
void
|
void
|
||||||
archive_plugin_init_all();
|
archive_plugin_init_all(const ConfigData &config);
|
||||||
|
|
||||||
/* this is where we "unload" all the "plugins" */
|
/* this is where we "unload" all the "plugins" */
|
||||||
void
|
void
|
||||||
|
@ -50,8 +51,8 @@ archive_plugin_deinit_all() noexcept;
|
||||||
|
|
||||||
class ScopeArchivePluginsInit {
|
class ScopeArchivePluginsInit {
|
||||||
public:
|
public:
|
||||||
ScopeArchivePluginsInit() {
|
explicit ScopeArchivePluginsInit(const ConfigData &config) {
|
||||||
archive_plugin_init_all();
|
archive_plugin_init_all(config);
|
||||||
}
|
}
|
||||||
|
|
||||||
~ScopeArchivePluginsInit() noexcept {
|
~ScopeArchivePluginsInit() noexcept {
|
||||||
|
|
|
@ -91,6 +91,7 @@ enum class ConfigBlockOption {
|
||||||
DECODER,
|
DECODER,
|
||||||
INPUT,
|
INPUT,
|
||||||
INPUT_CACHE,
|
INPUT_CACHE,
|
||||||
|
ARCHIVE_PLUGIN,
|
||||||
PLAYLIST_PLUGIN,
|
PLAYLIST_PLUGIN,
|
||||||
RESAMPLER,
|
RESAMPLER,
|
||||||
AUDIO_FILTER,
|
AUDIO_FILTER,
|
||||||
|
|
|
@ -90,6 +90,7 @@ const ConfigTemplate config_block_templates[] = {
|
||||||
{ "decoder", true },
|
{ "decoder", true },
|
||||||
{ "input", true },
|
{ "input", true },
|
||||||
{ "input_cache" },
|
{ "input_cache" },
|
||||||
|
{ "archive_plugin", true },
|
||||||
{ "playlist_plugin", true },
|
{ "playlist_plugin", true },
|
||||||
{ "resampler" },
|
{ "resampler" },
|
||||||
{ "filter", true },
|
{ "filter", true },
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GlobalInit {
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
const ScopeArchivePluginsInit archive_plugins_init;
|
const ScopeArchivePluginsInit archive_plugins_init{config};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
||||||
|
|
|
@ -137,7 +137,7 @@ class GlobalInit {
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
const ScopeArchivePluginsInit archive_plugins_init;
|
const ScopeArchivePluginsInit archive_plugins_init{config};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
||||||
|
|
|
@ -41,7 +41,7 @@ class GlobalInit {
|
||||||
EventThread io_thread;
|
EventThread io_thread;
|
||||||
|
|
||||||
#ifdef ENABLE_ARCHIVE
|
#ifdef ENABLE_ARCHIVE
|
||||||
const ScopeArchivePluginsInit archive_plugins_init;
|
const ScopeArchivePluginsInit archive_plugins_init{config};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
const ScopeInputPluginsInit input_plugins_init{config, io_thread.GetEventLoop()};
|
||||||
|
|
Loading…
Reference in New Issue