2023-03-06 14:42:04 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
// Copyright The Music Player Daemon Project
|
2009-07-03 01:02:53 +02:00
|
|
|
|
2018-01-02 23:06:53 +01:00
|
|
|
#include "LoadOne.hxx"
|
2013-02-01 17:47:09 +01:00
|
|
|
#include "FilterPlugin.hxx"
|
2019-08-26 20:54:52 +02:00
|
|
|
#include "Registry.hxx"
|
2018-01-01 18:48:34 +01:00
|
|
|
#include "Prepared.hxx"
|
2015-01-21 22:13:44 +01:00
|
|
|
#include "config/Block.hxx"
|
2022-11-28 21:58:21 +01:00
|
|
|
#include "lib/fmt/RuntimeError.hxx"
|
2009-07-03 01:02:53 +02:00
|
|
|
|
2017-12-27 09:17:15 +01:00
|
|
|
std::unique_ptr<PreparedFilter>
|
2016-09-04 20:07:05 +02:00
|
|
|
filter_configured_new(const ConfigBlock &block)
|
2009-07-03 01:02:53 +02:00
|
|
|
{
|
2015-01-21 22:13:44 +01:00
|
|
|
const char *plugin_name = block.GetBlockValue("plugin");
|
2016-09-04 20:07:05 +02:00
|
|
|
if (plugin_name == nullptr)
|
|
|
|
throw std::runtime_error("No filter plugin specified");
|
2009-07-03 01:02:53 +02:00
|
|
|
|
2016-11-23 17:43:50 +01:00
|
|
|
const auto *plugin = filter_plugin_by_name(plugin_name);
|
2016-09-04 20:07:05 +02:00
|
|
|
if (plugin == nullptr)
|
2022-11-28 21:58:21 +01:00
|
|
|
throw FmtRuntimeError("No such filter plugin: {}",
|
|
|
|
plugin_name);
|
2009-07-03 01:02:53 +02:00
|
|
|
|
2018-01-02 23:00:16 +01:00
|
|
|
return plugin->init(block);
|
2009-07-03 01:02:53 +02:00
|
|
|
}
|