config: allow configuring partitions

This just allows creating empty partitions.  More features to come.
This commit is contained in:
Max Kellermann 2022-07-12 20:50:46 +02:00
parent 64f84d5468
commit 199037c682
5 changed files with 44 additions and 0 deletions

1
NEWS
View File

@ -15,6 +15,7 @@ ver 0.24 (not yet released)
- new tag "Mood"
* switch to C++20
- GCC 10 or clang 11 (or newer) recommended
* static partition configuration
* remove Haiku support
ver 0.23.9 (not yet released)

View File

@ -297,6 +297,38 @@ configure this plugin, add a :code:`database` block to
More information can be found in the :ref:`database_plugins`
reference.
Configuring Partitions
----------------------
:program:`MPD` can have multiple "partitions", that is, multiple
independent players, each with their own queue and outputs. All
partitions share one database. By default, there is only one
partition called "default". Additional partitions can be created in
the configuration file with ``partition`` blocks or at runtime with
the :ref:`newpartition <command_newpartition>` command.
Example for specifying an additional partition in the configuration
file:
.. code-block:: none
partition {
name "foo"
}
The following options are available in ``partition`` blocks:
.. list-table::
:widths: 20 80
:header-rows: 1
* - Name
- Description
* - **name**
- The name of the partition.
Configuring neighbor plugins
----------------------------

View File

@ -410,6 +410,15 @@ MainConfigured(const CommandLineOptions &options,
partition.UpdateEffectiveReplayGainMode();
}
raw_config.WithEach(ConfigBlockOption::PARTITION, [&](const auto &block){
const char *name = block.GetBlockValue("name");
if (name == nullptr)
throw std::runtime_error("Missing 'name'");
instance.partitions.emplace_back(instance, name,
partition_config);
});
client_manager_init(raw_config);
const ScopeInputPluginsInit input_plugins_init(raw_config,
instance.io_thread.GetEventLoop());

View File

@ -97,6 +97,7 @@ enum class ConfigBlockOption {
AUDIO_FILTER,
DATABASE,
NEIGHBORS,
PARTITION,
MAX
};

View File

@ -96,6 +96,7 @@ const ConfigTemplate config_block_templates[] = {
{ "filter", true },
{ "database" },
{ "neighbors", true },
{ "partition", true },
};
static constexpr unsigned n_config_block_templates =