config/Param: split block-specific attributes to new struct ConfigBlock
The old struct config_param remains only for top-level string options.
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
#include "filter/plugins/ChainFilterPlugin.hxx"
|
||||
#include "config/ConfigError.hxx"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "config/Block.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "Log.hxx"
|
||||
|
||||
@@ -95,15 +96,15 @@ audio_output_detect(Error &error)
|
||||
*/
|
||||
gcc_pure
|
||||
static MixerType
|
||||
audio_output_mixer_type(const config_param ¶m)
|
||||
audio_output_mixer_type(const ConfigBlock &block)
|
||||
{
|
||||
/* read the local "mixer_type" setting */
|
||||
const char *p = param.GetBlockValue("mixer_type");
|
||||
const char *p = block.GetBlockValue("mixer_type");
|
||||
if (p != nullptr)
|
||||
return mixer_type_parse(p);
|
||||
|
||||
/* try the local "mixer_enabled" setting next (deprecated) */
|
||||
if (!param.GetBlockValue("mixer_enabled", true))
|
||||
if (!block.GetBlockValue("mixer_enabled", true))
|
||||
return MixerType::NONE;
|
||||
|
||||
/* fall back to the global "mixer_type" setting (also
|
||||
@@ -114,7 +115,7 @@ audio_output_mixer_type(const config_param ¶m)
|
||||
|
||||
static Mixer *
|
||||
audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
|
||||
const config_param ¶m,
|
||||
const ConfigBlock &block,
|
||||
const MixerPlugin *plugin,
|
||||
Filter &filter_chain,
|
||||
MixerListener &listener,
|
||||
@@ -122,26 +123,26 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
|
||||
{
|
||||
Mixer *mixer;
|
||||
|
||||
switch (audio_output_mixer_type(param)) {
|
||||
switch (audio_output_mixer_type(block)) {
|
||||
case MixerType::NONE:
|
||||
case MixerType::UNKNOWN:
|
||||
return nullptr;
|
||||
|
||||
case MixerType::NULL_:
|
||||
return mixer_new(event_loop, null_mixer_plugin, ao, listener,
|
||||
param, error);
|
||||
block, error);
|
||||
|
||||
case MixerType::HARDWARE:
|
||||
if (plugin == nullptr)
|
||||
return nullptr;
|
||||
|
||||
return mixer_new(event_loop, *plugin, ao, listener,
|
||||
param, error);
|
||||
block, error);
|
||||
|
||||
case MixerType::SOFTWARE:
|
||||
mixer = mixer_new(event_loop, software_mixer_plugin, ao,
|
||||
listener,
|
||||
config_param(),
|
||||
ConfigBlock(),
|
||||
IgnoreError());
|
||||
assert(mixer != nullptr);
|
||||
|
||||
@@ -155,17 +156,17 @@ audio_output_load_mixer(EventLoop &event_loop, AudioOutput &ao,
|
||||
}
|
||||
|
||||
bool
|
||||
AudioOutput::Configure(const config_param ¶m, Error &error)
|
||||
AudioOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!param.IsNull()) {
|
||||
name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
||||
if (!block.IsNull()) {
|
||||
name = block.GetBlockValue(AUDIO_OUTPUT_NAME);
|
||||
if (name == nullptr) {
|
||||
error.Set(config_domain,
|
||||
"Missing \"name\" configuration");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *p = param.GetBlockValue(AUDIO_OUTPUT_FORMAT);
|
||||
const char *p = block.GetBlockValue(AUDIO_OUTPUT_FORMAT);
|
||||
if (p != nullptr) {
|
||||
bool success =
|
||||
audio_format_parse(config_audio_format,
|
||||
@@ -180,9 +181,9 @@ AudioOutput::Configure(const config_param ¶m, Error &error)
|
||||
config_audio_format.Clear();
|
||||
}
|
||||
|
||||
tags = param.GetBlockValue("tags", true);
|
||||
always_on = param.GetBlockValue("always_on", false);
|
||||
enabled = param.GetBlockValue("enabled", true);
|
||||
tags = block.GetBlockValue("tags", true);
|
||||
always_on = block.GetBlockValue("always_on", false);
|
||||
enabled = block.GetBlockValue("enabled", true);
|
||||
|
||||
/* set up the filter chain */
|
||||
|
||||
@@ -193,7 +194,7 @@ AudioOutput::Configure(const config_param ¶m, Error &error)
|
||||
|
||||
if (config_get_bool(ConfigOption::VOLUME_NORMALIZATION, false)) {
|
||||
Filter *normalize_filter =
|
||||
filter_new(&normalize_filter_plugin, config_param(),
|
||||
filter_new(&normalize_filter_plugin, ConfigBlock(),
|
||||
IgnoreError());
|
||||
assert(normalize_filter != nullptr);
|
||||
|
||||
@@ -203,7 +204,7 @@ AudioOutput::Configure(const config_param ¶m, Error &error)
|
||||
|
||||
Error filter_error;
|
||||
filter_chain_parse(*filter,
|
||||
param.GetBlockValue(AUDIO_FILTERS, ""),
|
||||
block.GetBlockValue(AUDIO_FILTERS, ""),
|
||||
filter_error);
|
||||
|
||||
// It's not really fatal - Part of the filter chain has been set up already
|
||||
@@ -221,24 +222,24 @@ AudioOutput::Configure(const config_param ¶m, Error &error)
|
||||
static bool
|
||||
audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
|
||||
MixerListener &mixer_listener,
|
||||
const config_param ¶m,
|
||||
const ConfigBlock &block,
|
||||
Error &error)
|
||||
{
|
||||
|
||||
/* create the replay_gain filter */
|
||||
|
||||
const char *replay_gain_handler =
|
||||
param.GetBlockValue("replay_gain_handler", "software");
|
||||
block.GetBlockValue("replay_gain_handler", "software");
|
||||
|
||||
if (strcmp(replay_gain_handler, "none") != 0) {
|
||||
ao.replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||
param, IgnoreError());
|
||||
block, IgnoreError());
|
||||
assert(ao.replay_gain_filter != nullptr);
|
||||
|
||||
ao.replay_gain_serial = 0;
|
||||
|
||||
ao.other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||
param,
|
||||
block,
|
||||
IgnoreError());
|
||||
assert(ao.other_replay_gain_filter != nullptr);
|
||||
|
||||
@@ -251,7 +252,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
|
||||
/* set up the mixer */
|
||||
|
||||
Error mixer_error;
|
||||
ao.mixer = audio_output_load_mixer(event_loop, ao, param,
|
||||
ao.mixer = audio_output_load_mixer(event_loop, ao, block,
|
||||
ao.plugin.mixer_plugin,
|
||||
*ao.filter,
|
||||
mixer_listener,
|
||||
@@ -279,7 +280,7 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
|
||||
|
||||
/* the "convert" filter must be the last one in the chain */
|
||||
|
||||
ao.convert_filter = filter_new(&convert_filter_plugin, config_param(),
|
||||
ao.convert_filter = filter_new(&convert_filter_plugin, ConfigBlock(),
|
||||
IgnoreError());
|
||||
assert(ao.convert_filter != nullptr);
|
||||
|
||||
@@ -289,17 +290,17 @@ audio_output_setup(EventLoop &event_loop, AudioOutput &ao,
|
||||
}
|
||||
|
||||
AudioOutput *
|
||||
audio_output_new(EventLoop &event_loop, const config_param ¶m,
|
||||
audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
|
||||
MixerListener &mixer_listener,
|
||||
PlayerControl &pc,
|
||||
Error &error)
|
||||
{
|
||||
const AudioOutputPlugin *plugin;
|
||||
|
||||
if (!param.IsNull()) {
|
||||
if (!block.IsNull()) {
|
||||
const char *p;
|
||||
|
||||
p = param.GetBlockValue(AUDIO_OUTPUT_TYPE);
|
||||
p = block.GetBlockValue(AUDIO_OUTPUT_TYPE);
|
||||
if (p == nullptr) {
|
||||
error.Set(config_domain,
|
||||
"Missing \"type\" configuration");
|
||||
@@ -325,12 +326,12 @@ audio_output_new(EventLoop &event_loop, const config_param ¶m,
|
||||
plugin->name);
|
||||
}
|
||||
|
||||
AudioOutput *ao = ao_plugin_init(plugin, param, error);
|
||||
AudioOutput *ao = ao_plugin_init(plugin, block, error);
|
||||
if (ao == nullptr)
|
||||
return nullptr;
|
||||
|
||||
if (!audio_output_setup(event_loop, *ao, mixer_listener,
|
||||
param, error)) {
|
||||
block, error)) {
|
||||
ao_plugin_finish(ao);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ class EventLoop;
|
||||
class Mixer;
|
||||
class MixerListener;
|
||||
struct MusicChunk;
|
||||
struct config_param;
|
||||
struct ConfigBlock;
|
||||
struct PlayerControl;
|
||||
struct AudioOutputPlugin;
|
||||
|
||||
@@ -272,7 +272,7 @@ struct AudioOutput {
|
||||
AudioOutput(const AudioOutputPlugin &_plugin);
|
||||
~AudioOutput();
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
void StartThread();
|
||||
void StopThread();
|
||||
@@ -430,7 +430,7 @@ private:
|
||||
extern struct notify audio_output_client_notify;
|
||||
|
||||
AudioOutput *
|
||||
audio_output_new(EventLoop &event_loop, const config_param ¶m,
|
||||
audio_output_new(EventLoop &event_loop, const ConfigBlock &block,
|
||||
MixerListener &mixer_listener,
|
||||
PlayerControl &pc,
|
||||
Error &error);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "MusicChunk.hxx"
|
||||
#include "system/FatalError.hxx"
|
||||
#include "util/Error.hxx"
|
||||
#include "config/Param.hxx"
|
||||
#include "config/Block.hxx"
|
||||
#include "config/ConfigGlobal.hxx"
|
||||
#include "config/ConfigOption.hxx"
|
||||
#include "notify.hxx"
|
||||
@@ -53,16 +53,16 @@ MultipleOutputs::~MultipleOutputs()
|
||||
|
||||
static AudioOutput *
|
||||
LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
|
||||
PlayerControl &pc, const config_param ¶m)
|
||||
PlayerControl &pc, const ConfigBlock &block)
|
||||
{
|
||||
Error error;
|
||||
AudioOutput *output = audio_output_new(event_loop, param,
|
||||
AudioOutput *output = audio_output_new(event_loop, block,
|
||||
mixer_listener,
|
||||
pc, error);
|
||||
if (output == nullptr) {
|
||||
if (param.line > 0)
|
||||
if (block.line > 0)
|
||||
FormatFatalError("line %i: %s",
|
||||
param.line,
|
||||
block.line,
|
||||
error.GetMessage());
|
||||
else
|
||||
FatalError(error);
|
||||
@@ -74,7 +74,7 @@ LoadOutput(EventLoop &event_loop, MixerListener &mixer_listener,
|
||||
void
|
||||
MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
|
||||
{
|
||||
for (const auto *param = config_get_param(ConfigOption::AUDIO_OUTPUT);
|
||||
for (const auto *param = config_get_block(ConfigBlockOption::AUDIO_OUTPUT);
|
||||
param != nullptr; param = param->next) {
|
||||
auto output = LoadOutput(event_loop, mixer_listener,
|
||||
pc, *param);
|
||||
@@ -87,7 +87,7 @@ MultipleOutputs::Configure(EventLoop &event_loop, PlayerControl &pc)
|
||||
|
||||
if (outputs.empty()) {
|
||||
/* auto-detect device */
|
||||
const config_param empty;
|
||||
const ConfigBlock empty;
|
||||
auto output = LoadOutput(event_loop, mixer_listener,
|
||||
pc, empty);
|
||||
outputs.push_back(output);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include "Internal.hxx"
|
||||
#include "AudioFormat.hxx"
|
||||
#include "tag/Tag.hxx"
|
||||
#include "config/Param.hxx"
|
||||
#include "config/Block.hxx"
|
||||
|
||||
// IWYU pragma: end_exports
|
||||
|
||||
|
||||
@@ -23,13 +23,13 @@
|
||||
|
||||
AudioOutput *
|
||||
ao_plugin_init(const AudioOutputPlugin *plugin,
|
||||
const config_param ¶m,
|
||||
const ConfigBlock &block,
|
||||
Error &error)
|
||||
{
|
||||
assert(plugin != nullptr);
|
||||
assert(plugin->init != nullptr);
|
||||
|
||||
return plugin->init(param, error);
|
||||
return plugin->init(block, error);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
|
||||
struct config_param;
|
||||
struct ConfigBlock;
|
||||
struct AudioFormat;
|
||||
struct Tag;
|
||||
struct AudioOutput;
|
||||
@@ -55,8 +55,7 @@ struct AudioOutputPlugin {
|
||||
* @return nullptr on error, or an opaque pointer to the plugin's
|
||||
* data
|
||||
*/
|
||||
AudioOutput *(*init)(const config_param ¶m,
|
||||
Error &error);
|
||||
AudioOutput *(*init)(const ConfigBlock &block, Error &error);
|
||||
|
||||
/**
|
||||
* Free resources allocated by this device.
|
||||
@@ -162,7 +161,7 @@ ao_plugin_test_default_device(const AudioOutputPlugin *plugin)
|
||||
gcc_malloc
|
||||
AudioOutput *
|
||||
ao_plugin_init(const AudioOutputPlugin *plugin,
|
||||
const config_param ¶m,
|
||||
const ConfigBlock &block,
|
||||
Error &error);
|
||||
|
||||
void
|
||||
|
||||
@@ -22,14 +22,16 @@
|
||||
|
||||
#include "util/Cast.hxx"
|
||||
|
||||
struct ConfigBlock;
|
||||
|
||||
template<class T>
|
||||
struct AudioOutputWrapper {
|
||||
static T &Cast(AudioOutput &ao) {
|
||||
return ContainerCast(ao, &T::base);
|
||||
}
|
||||
|
||||
static AudioOutput *Init(const config_param ¶m, Error &error) {
|
||||
T *t = T::Create(param, error);
|
||||
static AudioOutput *Init(const ConfigBlock &block, Error &error) {
|
||||
T *t = T::Create(block, error);
|
||||
return t != nullptr
|
||||
? &t->base
|
||||
: nullptr;
|
||||
|
||||
@@ -142,8 +142,8 @@ struct AlsaOutput {
|
||||
return device.empty() ? default_device : device.c_str();
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
static AlsaOutput *Create(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
static AlsaOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Enable(Error &error);
|
||||
void Disable();
|
||||
@@ -175,35 +175,35 @@ private:
|
||||
static constexpr Domain alsa_output_domain("alsa_output");
|
||||
|
||||
inline bool
|
||||
AlsaOutput::Configure(const config_param ¶m, Error &error)
|
||||
AlsaOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!base.Configure(param, error))
|
||||
if (!base.Configure(block, error))
|
||||
return false;
|
||||
|
||||
device = param.GetBlockValue("device", "");
|
||||
device = block.GetBlockValue("device", "");
|
||||
|
||||
use_mmap = param.GetBlockValue("use_mmap", false);
|
||||
use_mmap = block.GetBlockValue("use_mmap", false);
|
||||
|
||||
dop = param.GetBlockValue("dop", false) ||
|
||||
dop = block.GetBlockValue("dop", false) ||
|
||||
/* legacy name from MPD 0.18 and older: */
|
||||
param.GetBlockValue("dsd_usb", false);
|
||||
block.GetBlockValue("dsd_usb", false);
|
||||
|
||||
buffer_time = param.GetBlockValue("buffer_time",
|
||||
buffer_time = block.GetBlockValue("buffer_time",
|
||||
MPD_ALSA_BUFFER_TIME_US);
|
||||
period_time = param.GetBlockValue("period_time", 0u);
|
||||
period_time = block.GetBlockValue("period_time", 0u);
|
||||
|
||||
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
||||
if (!param.GetBlockValue("auto_resample", true))
|
||||
if (!block.GetBlockValue("auto_resample", true))
|
||||
mode |= SND_PCM_NO_AUTO_RESAMPLE;
|
||||
#endif
|
||||
|
||||
#ifdef SND_PCM_NO_AUTO_CHANNELS
|
||||
if (!param.GetBlockValue("auto_channels", true))
|
||||
if (!block.GetBlockValue("auto_channels", true))
|
||||
mode |= SND_PCM_NO_AUTO_CHANNELS;
|
||||
#endif
|
||||
|
||||
#ifdef SND_PCM_NO_AUTO_FORMAT
|
||||
if (!param.GetBlockValue("auto_format", true))
|
||||
if (!block.GetBlockValue("auto_format", true))
|
||||
mode |= SND_PCM_NO_AUTO_FORMAT;
|
||||
#endif
|
||||
|
||||
@@ -211,11 +211,11 @@ AlsaOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
inline AlsaOutput *
|
||||
AlsaOutput::Create(const config_param ¶m, Error &error)
|
||||
AlsaOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
AlsaOutput *ad = new AlsaOutput();
|
||||
|
||||
if (!ad->Configure(param, error)) {
|
||||
if (!ad->Configure(block, error)) {
|
||||
delete ad;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -46,11 +46,11 @@ struct AoOutput {
|
||||
AoOutput()
|
||||
:base(ao_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
};
|
||||
|
||||
static constexpr Domain ao_output_domain("ao_output");
|
||||
@@ -90,20 +90,20 @@ ao_output_error(Error &error_r)
|
||||
}
|
||||
|
||||
inline bool
|
||||
AoOutput::Configure(const config_param ¶m, Error &error)
|
||||
AoOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
const char *value;
|
||||
|
||||
options = nullptr;
|
||||
|
||||
write_size = param.GetBlockValue("write_size", 1024u);
|
||||
write_size = block.GetBlockValue("write_size", 1024u);
|
||||
|
||||
if (ao_output_ref == 0) {
|
||||
ao_initialize();
|
||||
}
|
||||
ao_output_ref++;
|
||||
|
||||
value = param.GetBlockValue("driver", "default");
|
||||
value = block.GetBlockValue("driver", "default");
|
||||
if (0 == strcmp(value, "default"))
|
||||
driver = ao_default_driver_id();
|
||||
else
|
||||
@@ -123,9 +123,9 @@ AoOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
FormatDebug(ao_output_domain, "using ao driver \"%s\" for \"%s\"\n",
|
||||
ai->short_name, param.GetBlockValue("name", nullptr));
|
||||
ai->short_name, block.GetBlockValue("name", nullptr));
|
||||
|
||||
value = param.GetBlockValue("options", nullptr);
|
||||
value = block.GetBlockValue("options", nullptr);
|
||||
if (value != nullptr) {
|
||||
for (const auto &i : SplitString(value, ';')) {
|
||||
const DivideString ss(i.c_str(), '=', true);
|
||||
@@ -145,16 +145,16 @@ AoOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
ao_output_init(const config_param ¶m, Error &error)
|
||||
ao_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
AoOutput *ad = new AoOutput();
|
||||
|
||||
if (!ad->Initialize(param, error)) {
|
||||
if (!ad->Initialize(block, error)) {
|
||||
delete ad;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!ad->Configure(param, error)) {
|
||||
if (!ad->Configure(block, error)) {
|
||||
delete ad;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -51,8 +51,8 @@ struct FifoOutput {
|
||||
path(AllocatedPath::Null()), input(-1), output(-1),
|
||||
created(false) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
bool Create(Error &error);
|
||||
@@ -169,11 +169,11 @@ fifo_open(FifoOutput *fd, Error &error)
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
fifo_output_init(const config_param ¶m, Error &error)
|
||||
fifo_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
FifoOutput *fd = new FifoOutput();
|
||||
|
||||
fd->path = param.GetBlockPath("path", error);
|
||||
fd->path = block.GetBlockPath("path", error);
|
||||
if (fd->path.IsNull()) {
|
||||
delete fd;
|
||||
|
||||
@@ -185,7 +185,7 @@ fifo_output_init(const config_param ¶m, Error &error)
|
||||
|
||||
fd->path_utf8 = fd->path.ToUTF8();
|
||||
|
||||
if (!fd->Initialize(param, error)) {
|
||||
if (!fd->Initialize(block, error)) {
|
||||
delete fd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ struct JackOutput {
|
||||
JackOutput()
|
||||
:base(jack_output_plugin) {}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Connect(Error &error);
|
||||
|
||||
@@ -376,14 +376,14 @@ parse_port_list(const char *source, std::string dest[], Error &error)
|
||||
}
|
||||
|
||||
bool
|
||||
JackOutput::Configure(const config_param ¶m, Error &error)
|
||||
JackOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!base.Configure(param, error))
|
||||
if (!base.Configure(block, error))
|
||||
return false;
|
||||
|
||||
options = JackNullOption;
|
||||
|
||||
name = param.GetBlockValue("client_name", nullptr);
|
||||
name = block.GetBlockValue("client_name", nullptr);
|
||||
if (name != nullptr)
|
||||
options = jack_options_t(options | JackUseExactName);
|
||||
else
|
||||
@@ -391,30 +391,30 @@ JackOutput::Configure(const config_param ¶m, Error &error)
|
||||
care about the JackUseExactName option */
|
||||
name = "Music Player Daemon";
|
||||
|
||||
server_name = param.GetBlockValue("server_name", nullptr);
|
||||
server_name = block.GetBlockValue("server_name", nullptr);
|
||||
if (server_name != nullptr)
|
||||
options = jack_options_t(options | JackServerName);
|
||||
|
||||
if (!param.GetBlockValue("autostart", false))
|
||||
if (!block.GetBlockValue("autostart", false))
|
||||
options = jack_options_t(options | JackNoStartServer);
|
||||
|
||||
/* configure the source ports */
|
||||
|
||||
const char *value = param.GetBlockValue("source_ports", "left,right");
|
||||
const char *value = block.GetBlockValue("source_ports", "left,right");
|
||||
num_source_ports = parse_port_list(value, source_ports, error);
|
||||
if (num_source_ports == 0)
|
||||
return false;
|
||||
|
||||
/* configure the destination ports */
|
||||
|
||||
value = param.GetBlockValue("destination_ports", nullptr);
|
||||
value = block.GetBlockValue("destination_ports", nullptr);
|
||||
if (value == nullptr) {
|
||||
/* compatibility with MPD < 0.16 */
|
||||
value = param.GetBlockValue("ports", nullptr);
|
||||
value = block.GetBlockValue("ports", nullptr);
|
||||
if (value != nullptr)
|
||||
FormatWarning(jack_output_domain,
|
||||
"deprecated option 'ports' in line %d",
|
||||
param.line);
|
||||
block.line);
|
||||
}
|
||||
|
||||
if (value != nullptr) {
|
||||
@@ -432,9 +432,9 @@ JackOutput::Configure(const config_param ¶m, Error &error)
|
||||
"number of source ports (%u) mismatches the "
|
||||
"number of destination ports (%u) in line %d",
|
||||
num_source_ports, num_destination_ports,
|
||||
param.line);
|
||||
block.line);
|
||||
|
||||
ringbuffer_size = param.GetBlockValue("ringbuffer_size", 32768u);
|
||||
ringbuffer_size = block.GetBlockValue("ringbuffer_size", 32768u);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -463,11 +463,11 @@ JackOutput::Disable()
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
mpd_jack_init(const config_param ¶m, Error &error)
|
||||
mpd_jack_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
JackOutput *jd = new JackOutput();
|
||||
|
||||
if (!jd->Configure(param, error)) {
|
||||
if (!jd->Configure(block, error)) {
|
||||
delete jd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -36,11 +36,11 @@ public:
|
||||
NullOutput()
|
||||
:base(null_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
static NullOutput *Create(const config_param ¶m, Error &error);
|
||||
static NullOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Open(AudioFormat &audio_format, gcc_unused Error &error) {
|
||||
if (sync)
|
||||
@@ -78,16 +78,16 @@ public:
|
||||
};
|
||||
|
||||
inline NullOutput *
|
||||
NullOutput::Create(const config_param ¶m, Error &error)
|
||||
NullOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
NullOutput *nd = new NullOutput();
|
||||
|
||||
if (!nd->Initialize(param, error)) {
|
||||
if (!nd->Initialize(block, error)) {
|
||||
delete nd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
nd->sync = param.GetBlockValue("sync", true);
|
||||
nd->sync = block.GetBlockValue("sync", true);
|
||||
|
||||
return nd;
|
||||
}
|
||||
|
||||
@@ -61,9 +61,9 @@ osx_output_test_default_device(void)
|
||||
}
|
||||
|
||||
static void
|
||||
osx_output_configure(OSXOutput *oo, const config_param ¶m)
|
||||
osx_output_configure(OSXOutput *oo, const ConfigBlock &block)
|
||||
{
|
||||
const char *device = param.GetBlockValue("device");
|
||||
const char *device = block.GetBlockValue("device");
|
||||
|
||||
if (device == nullptr || 0 == strcmp(device, "default")) {
|
||||
oo->component_subtype = kAudioUnitSubType_DefaultOutput;
|
||||
@@ -81,15 +81,15 @@ osx_output_configure(OSXOutput *oo, const config_param ¶m)
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
osx_output_init(const config_param ¶m, Error &error)
|
||||
osx_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
OSXOutput *oo = new OSXOutput();
|
||||
if (!oo->base.Configure(param, error)) {
|
||||
if (!oo->base.Configure(block, error)) {
|
||||
delete oo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
osx_output_configure(oo, param);
|
||||
osx_output_configure(oo, block);
|
||||
|
||||
return &oo->base;
|
||||
}
|
||||
|
||||
@@ -54,9 +54,9 @@ class OpenALOutput {
|
||||
OpenALOutput()
|
||||
:base(openal_output_plugin) {}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
static OpenALOutput *Create(const config_param ¶m, Error &error);
|
||||
static OpenALOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Open(AudioFormat &audio_format, Error &error);
|
||||
|
||||
@@ -150,12 +150,12 @@ OpenALOutput::SetupContext(Error &error)
|
||||
}
|
||||
|
||||
inline bool
|
||||
OpenALOutput::Configure(const config_param ¶m, Error &error)
|
||||
OpenALOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!base.Configure(param, error))
|
||||
if (!base.Configure(block, error))
|
||||
return false;
|
||||
|
||||
device_name = param.GetBlockValue("device");
|
||||
device_name = block.GetBlockValue("device");
|
||||
if (device_name == nullptr)
|
||||
device_name = alcGetString(nullptr,
|
||||
ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||
@@ -164,11 +164,11 @@ OpenALOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
inline OpenALOutput *
|
||||
OpenALOutput::Create(const config_param ¶m, Error &error)
|
||||
OpenALOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
OpenALOutput *oo = new OpenALOutput();
|
||||
|
||||
if (!oo->Configure(param, error)) {
|
||||
if (!oo->Configure(block, error)) {
|
||||
delete oo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -87,11 +87,11 @@ public:
|
||||
:base(oss_output_plugin),
|
||||
fd(-1), device(_device) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return base.Configure(param, error_r);
|
||||
bool Initialize(const ConfigBlock &block, Error &error_r) {
|
||||
return base.Configure(block, error_r);
|
||||
}
|
||||
|
||||
static OssOutput *Create(const config_param ¶m, Error &error);
|
||||
static OssOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
#ifdef AFMT_S24_PACKED
|
||||
bool Enable(gcc_unused Error &error) {
|
||||
@@ -192,7 +192,7 @@ oss_open_default(Error &error)
|
||||
int err[ARRAY_SIZE(default_devices)];
|
||||
enum oss_stat ret[ARRAY_SIZE(default_devices)];
|
||||
|
||||
const config_param empty;
|
||||
const ConfigBlock empty;
|
||||
for (int i = ARRAY_SIZE(default_devices); --i >= 0; ) {
|
||||
ret[i] = oss_stat_device(default_devices[i], &err[i]);
|
||||
if (ret[i] == OSS_STAT_NO_ERROR) {
|
||||
@@ -236,12 +236,12 @@ oss_open_default(Error &error)
|
||||
}
|
||||
|
||||
inline OssOutput *
|
||||
OssOutput::Create(const config_param ¶m, Error &error)
|
||||
OssOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
const char *device = param.GetBlockValue("device");
|
||||
const char *device = block.GetBlockValue("device");
|
||||
if (device != nullptr) {
|
||||
OssOutput *od = new OssOutput();
|
||||
if (!od->Initialize(param, error)) {
|
||||
if (!od->Initialize(block, error)) {
|
||||
delete od;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -40,10 +40,10 @@ class PipeOutput {
|
||||
PipeOutput()
|
||||
:base(pipe_output_plugin) {}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
public:
|
||||
static PipeOutput *Create(const config_param ¶m, Error &error);
|
||||
static PipeOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Open(AudioFormat &audio_format, Error &error);
|
||||
|
||||
@@ -58,12 +58,12 @@ public:
|
||||
static constexpr Domain pipe_output_domain("pipe_output");
|
||||
|
||||
inline bool
|
||||
PipeOutput::Configure(const config_param ¶m, Error &error)
|
||||
PipeOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!base.Configure(param, error))
|
||||
if (!base.Configure(block, error))
|
||||
return false;
|
||||
|
||||
cmd = param.GetBlockValue("command", "");
|
||||
cmd = block.GetBlockValue("command", "");
|
||||
if (cmd.empty()) {
|
||||
error.Set(config_domain,
|
||||
"No \"command\" parameter specified");
|
||||
@@ -74,11 +74,11 @@ PipeOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
inline PipeOutput *
|
||||
PipeOutput::Create(const config_param ¶m, Error &error)
|
||||
PipeOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
PipeOutput *po = new PipeOutput();
|
||||
|
||||
if (!po->Configure(param, error)) {
|
||||
if (!po->Configure(block, error)) {
|
||||
delete po;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -98,8 +98,8 @@ public:
|
||||
gcc_const
|
||||
static bool TestDefaultDevice();
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
static PulseOutput *Create(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
static PulseOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Enable(Error &error);
|
||||
void Disable();
|
||||
@@ -430,26 +430,26 @@ PulseOutput::SetupContext(Error &error)
|
||||
}
|
||||
|
||||
inline bool
|
||||
PulseOutput::Configure(const config_param ¶m, Error &error)
|
||||
PulseOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
if (!base.Configure(param, error))
|
||||
if (!base.Configure(block, error))
|
||||
return false;
|
||||
|
||||
name = param.GetBlockValue("name", "mpd_pulse");
|
||||
server = param.GetBlockValue("server");
|
||||
sink = param.GetBlockValue("sink");
|
||||
name = block.GetBlockValue("name", "mpd_pulse");
|
||||
server = block.GetBlockValue("server");
|
||||
sink = block.GetBlockValue("sink");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
PulseOutput *
|
||||
PulseOutput::Create(const config_param ¶m, Error &error)
|
||||
PulseOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
setenv("PULSE_PROP_media.role", "music", true);
|
||||
setenv("PULSE_PROP_application.icon_name", "mpd", true);
|
||||
|
||||
auto *po = new PulseOutput();
|
||||
if (!po->Configure(param, error)) {
|
||||
if (!po->Configure(block, error)) {
|
||||
delete po;
|
||||
return nullptr;
|
||||
}
|
||||
@@ -926,7 +926,7 @@ PulseOutput::Pause()
|
||||
inline bool
|
||||
PulseOutput::TestDefaultDevice()
|
||||
{
|
||||
const config_param empty;
|
||||
const ConfigBlock empty;
|
||||
PulseOutput *po = PulseOutput::Create(empty, IgnoreError());
|
||||
if (po == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -81,13 +81,13 @@ class RecorderOutput {
|
||||
encoder->Dispose();
|
||||
}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return base.Configure(param, error_r);
|
||||
bool Initialize(const ConfigBlock &block, Error &error_r) {
|
||||
return base.Configure(block, error_r);
|
||||
}
|
||||
|
||||
static RecorderOutput *Create(const config_param ¶m, Error &error);
|
||||
static RecorderOutput *Create(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Open(AudioFormat &audio_format, Error &error);
|
||||
void Close();
|
||||
@@ -117,12 +117,12 @@ private:
|
||||
};
|
||||
|
||||
inline bool
|
||||
RecorderOutput::Configure(const config_param ¶m, Error &error)
|
||||
RecorderOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
/* read configuration */
|
||||
|
||||
const char *encoder_name =
|
||||
param.GetBlockValue("encoder", "vorbis");
|
||||
block.GetBlockValue("encoder", "vorbis");
|
||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||
if (encoder_plugin == nullptr) {
|
||||
error.Format(config_domain,
|
||||
@@ -130,11 +130,11 @@ RecorderOutput::Configure(const config_param ¶m, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
path = param.GetBlockPath("path", error);
|
||||
path = block.GetBlockPath("path", error);
|
||||
if (error.IsDefined())
|
||||
return false;
|
||||
|
||||
const char *fmt = param.GetBlockValue("format_path", nullptr);
|
||||
const char *fmt = block.GetBlockValue("format_path", nullptr);
|
||||
if (fmt != nullptr)
|
||||
format_path = fmt;
|
||||
|
||||
@@ -150,7 +150,7 @@ RecorderOutput::Configure(const config_param ¶m, Error &error)
|
||||
|
||||
/* initialize encoder */
|
||||
|
||||
encoder = encoder_init(*encoder_plugin, param, error);
|
||||
encoder = encoder_init(*encoder_plugin, block, error);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -158,16 +158,16 @@ RecorderOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
RecorderOutput *
|
||||
RecorderOutput::Create(const config_param ¶m, Error &error)
|
||||
RecorderOutput::Create(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
RecorderOutput *recorder = new RecorderOutput();
|
||||
|
||||
if (!recorder->Initialize(param, error)) {
|
||||
if (!recorder->Initialize(block, error)) {
|
||||
delete recorder;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!recorder->Configure(param, error)) {
|
||||
if (!recorder->Configure(block, error)) {
|
||||
delete recorder;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -60,11 +60,11 @@ public:
|
||||
return &base;
|
||||
}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
void Configure(const config_param ¶m);
|
||||
void Configure(const ConfigBlock &block);
|
||||
|
||||
bool Open(AudioFormat &audio_format, Error &error);
|
||||
void Close();
|
||||
@@ -124,28 +124,28 @@ roar_output_set_volume(RoarOutput &roar, unsigned volume)
|
||||
}
|
||||
|
||||
inline void
|
||||
RoarOutput::Configure(const config_param ¶m)
|
||||
RoarOutput::Configure(const ConfigBlock &block)
|
||||
{
|
||||
host = param.GetBlockValue("server", "");
|
||||
name = param.GetBlockValue("name", "MPD");
|
||||
host = block.GetBlockValue("server", "");
|
||||
name = block.GetBlockValue("name", "MPD");
|
||||
|
||||
const char *_role = param.GetBlockValue("role", "music");
|
||||
const char *_role = block.GetBlockValue("role", "music");
|
||||
role = _role != nullptr
|
||||
? roar_str2role(_role)
|
||||
: ROAR_ROLE_MUSIC;
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
roar_init(const config_param ¶m, Error &error)
|
||||
roar_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
RoarOutput *self = new RoarOutput();
|
||||
|
||||
if (!self->Initialize(param, error)) {
|
||||
if (!self->Initialize(block, error)) {
|
||||
delete self;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
self->Configure(param);
|
||||
self->Configure(block);
|
||||
return *self;
|
||||
}
|
||||
|
||||
|
||||
@@ -68,11 +68,11 @@ struct ShoutOutput final {
|
||||
shout_free(shout_conn);
|
||||
}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
};
|
||||
|
||||
static int shout_init_count;
|
||||
@@ -92,18 +92,18 @@ shout_encoder_plugin_get(const char *name)
|
||||
|
||||
gcc_pure
|
||||
static const char *
|
||||
require_block_string(const config_param ¶m, const char *name)
|
||||
require_block_string(const ConfigBlock &block, const char *name)
|
||||
{
|
||||
const char *value = param.GetBlockValue(name);
|
||||
const char *value = block.GetBlockValue(name);
|
||||
if (value == nullptr)
|
||||
FormatFatalError("no \"%s\" defined for shout device defined "
|
||||
"at line %d\n", name, param.line);
|
||||
"at line %d\n", name, block.line);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
inline bool
|
||||
ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
ShoutOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
|
||||
const AudioFormat audio_format = base.config_audio_format;
|
||||
@@ -113,22 +113,22 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *host = require_block_string(param, "host");
|
||||
const char *mount = require_block_string(param, "mount");
|
||||
unsigned port = param.GetBlockValue("port", 0u);
|
||||
const char *host = require_block_string(block, "host");
|
||||
const char *mount = require_block_string(block, "mount");
|
||||
unsigned port = block.GetBlockValue("port", 0u);
|
||||
if (port == 0) {
|
||||
error.Set(config_domain, "shout port must be configured");
|
||||
return false;
|
||||
}
|
||||
|
||||
const char *passwd = require_block_string(param, "password");
|
||||
const char *name = require_block_string(param, "name");
|
||||
const char *passwd = require_block_string(block, "password");
|
||||
const char *name = require_block_string(block, "name");
|
||||
|
||||
bool is_public = param.GetBlockValue("public", false);
|
||||
bool is_public = block.GetBlockValue("public", false);
|
||||
|
||||
const char *user = param.GetBlockValue("user", "source");
|
||||
const char *user = block.GetBlockValue("user", "source");
|
||||
|
||||
const char *value = param.GetBlockValue("quality");
|
||||
const char *value = block.GetBlockValue("quality");
|
||||
if (value != nullptr) {
|
||||
char *test;
|
||||
quality = strtod(value, &test);
|
||||
@@ -141,14 +141,14 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (param.GetBlockValue("bitrate") != nullptr) {
|
||||
if (block.GetBlockValue("bitrate") != nullptr) {
|
||||
error.Set(config_domain,
|
||||
"quality and bitrate are "
|
||||
"both defined");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
value = param.GetBlockValue("bitrate");
|
||||
value = block.GetBlockValue("bitrate");
|
||||
if (value == nullptr) {
|
||||
error.Set(config_domain,
|
||||
"neither bitrate nor quality defined");
|
||||
@@ -165,7 +165,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
}
|
||||
|
||||
const char *encoding = param.GetBlockValue("encoding", "ogg");
|
||||
const char *encoding = block.GetBlockValue("encoding", "ogg");
|
||||
const auto encoder_plugin = shout_encoder_plugin_get(encoding);
|
||||
if (encoder_plugin == nullptr) {
|
||||
error.Format(config_domain,
|
||||
@@ -174,7 +174,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
encoder = encoder_init(*encoder_plugin, param, error);
|
||||
encoder = encoder_init(*encoder_plugin, block, error);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -185,7 +185,7 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
shout_format = SHOUT_FORMAT_OGG;
|
||||
|
||||
unsigned protocol;
|
||||
value = param.GetBlockValue("protocol");
|
||||
value = block.GetBlockValue("protocol");
|
||||
if (value != nullptr) {
|
||||
if (0 == strcmp(value, "shoutcast") &&
|
||||
0 != strcmp(encoding, "mp3")) {
|
||||
@@ -226,21 +226,21 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
/* optional paramters */
|
||||
timeout = param.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT);
|
||||
timeout = block.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT);
|
||||
|
||||
value = param.GetBlockValue("genre");
|
||||
value = block.GetBlockValue("genre");
|
||||
if (value != nullptr && shout_set_genre(shout_conn, value)) {
|
||||
error.Set(shout_output_domain, shout_get_error(shout_conn));
|
||||
return false;
|
||||
}
|
||||
|
||||
value = param.GetBlockValue("description");
|
||||
value = block.GetBlockValue("description");
|
||||
if (value != nullptr && shout_set_description(shout_conn, value)) {
|
||||
error.Set(shout_output_domain, shout_get_error(shout_conn));
|
||||
return false;
|
||||
}
|
||||
|
||||
value = param.GetBlockValue("url");
|
||||
value = block.GetBlockValue("url");
|
||||
if (value != nullptr && shout_set_url(shout_conn, value)) {
|
||||
error.Set(shout_output_domain, shout_get_error(shout_conn));
|
||||
return false;
|
||||
@@ -272,15 +272,15 @@ ShoutOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
my_shout_init_driver(const config_param ¶m, Error &error)
|
||||
my_shout_init_driver(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
ShoutOutput *sd = new ShoutOutput();
|
||||
if (!sd->Initialize(param, error)) {
|
||||
if (!sd->Initialize(block, error)) {
|
||||
delete sd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (!sd->Configure(param, error)) {
|
||||
if (!sd->Configure(block, error)) {
|
||||
delete sd;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -60,8 +60,8 @@ struct SolarisOutput {
|
||||
SolarisOutput()
|
||||
:base(solaris_output_plugin) {}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error_r) {
|
||||
return base.Configure(param, error_r);
|
||||
bool Initialize(const ConfigBlock &block, Error &error_r) {
|
||||
return base.Configure(block, error_r);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -75,15 +75,15 @@ solaris_output_test_default_device(void)
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
solaris_output_init(const config_param ¶m, Error &error_r)
|
||||
solaris_output_init(const ConfigBlock &block, Error &error_r)
|
||||
{
|
||||
SolarisOutput *so = new SolarisOutput();
|
||||
if (!so->Initialize(param, error_r)) {
|
||||
if (!so->Initialize(block, error_r)) {
|
||||
delete so;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
so->device = param.GetBlockValue("device", "/dev/audio");
|
||||
so->device = block.GetBlockValue("device", "/dev/audio");
|
||||
|
||||
return &so->base;
|
||||
}
|
||||
|
||||
@@ -122,15 +122,15 @@ fail:
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
winmm_output_init(const config_param ¶m, Error &error)
|
||||
winmm_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
WinmmOutput *wo = new WinmmOutput();
|
||||
if (!wo->base.Configure(param, error)) {
|
||||
if (!wo->base.Configure(block, error)) {
|
||||
delete wo;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
const char *device = param.GetBlockValue("device");
|
||||
const char *device = block.GetBlockValue("device");
|
||||
if (!get_device_id(device, &wo->device_id, error)) {
|
||||
delete wo;
|
||||
return nullptr;
|
||||
|
||||
@@ -42,7 +42,7 @@
|
||||
#include <queue>
|
||||
#include <list>
|
||||
|
||||
struct config_param;
|
||||
struct ConfigBlock;
|
||||
class Error;
|
||||
class EventLoop;
|
||||
class ServerSocket;
|
||||
@@ -162,16 +162,16 @@ public:
|
||||
|
||||
using DeferredMonitor::GetEventLoop;
|
||||
|
||||
bool Init(const config_param ¶m, Error &error);
|
||||
bool Init(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
AudioOutput *InitAndConfigure(const config_param ¶m,
|
||||
AudioOutput *InitAndConfigure(const ConfigBlock &block,
|
||||
Error &error) {
|
||||
if (!Init(param, error))
|
||||
if (!Init(block, error))
|
||||
return nullptr;
|
||||
|
||||
if (!Configure(param, error))
|
||||
if (!Configure(block, error))
|
||||
return nullptr;
|
||||
|
||||
return &base;
|
||||
|
||||
@@ -91,17 +91,17 @@ HttpdOutput::Unbind()
|
||||
}
|
||||
|
||||
inline bool
|
||||
HttpdOutput::Configure(const config_param ¶m, Error &error)
|
||||
HttpdOutput::Configure(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
/* read configuration */
|
||||
name = param.GetBlockValue("name", "Set name in config");
|
||||
genre = param.GetBlockValue("genre", "Set genre in config");
|
||||
website = param.GetBlockValue("website", "Set website in config");
|
||||
name = block.GetBlockValue("name", "Set name in config");
|
||||
genre = block.GetBlockValue("genre", "Set genre in config");
|
||||
website = block.GetBlockValue("website", "Set website in config");
|
||||
|
||||
unsigned port = param.GetBlockValue("port", 8000u);
|
||||
unsigned port = block.GetBlockValue("port", 8000u);
|
||||
|
||||
const char *encoder_name =
|
||||
param.GetBlockValue("encoder", "vorbis");
|
||||
block.GetBlockValue("encoder", "vorbis");
|
||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||
if (encoder_plugin == nullptr) {
|
||||
error.Format(httpd_output_domain,
|
||||
@@ -109,11 +109,11 @@ HttpdOutput::Configure(const config_param ¶m, Error &error)
|
||||
return false;
|
||||
}
|
||||
|
||||
clients_max = param.GetBlockValue("max_clients", 0u);
|
||||
clients_max = block.GetBlockValue("max_clients", 0u);
|
||||
|
||||
/* set up bind_to_address */
|
||||
|
||||
const char *bind_to_address = param.GetBlockValue("bind_to_address");
|
||||
const char *bind_to_address = block.GetBlockValue("bind_to_address");
|
||||
bool success = bind_to_address != nullptr &&
|
||||
strcmp(bind_to_address, "any") != 0
|
||||
? AddHost(bind_to_address, port, error)
|
||||
@@ -123,7 +123,7 @@ HttpdOutput::Configure(const config_param ¶m, Error &error)
|
||||
|
||||
/* initialize encoder */
|
||||
|
||||
encoder = encoder_init(*encoder_plugin, param, error);
|
||||
encoder = encoder_init(*encoder_plugin, block, error);
|
||||
if (encoder == nullptr)
|
||||
return false;
|
||||
|
||||
@@ -136,17 +136,17 @@ HttpdOutput::Configure(const config_param ¶m, Error &error)
|
||||
}
|
||||
|
||||
inline bool
|
||||
HttpdOutput::Init(const config_param ¶m, Error &error)
|
||||
HttpdOutput::Init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
return base.Configure(param, error);
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
httpd_output_init(const config_param ¶m, Error &error)
|
||||
httpd_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
HttpdOutput *httpd = new HttpdOutput(io_thread_get());
|
||||
|
||||
AudioOutput *result = httpd->InitAndConfigure(param, error);
|
||||
AudioOutput *result = httpd->InitAndConfigure(block, error);
|
||||
if (result == nullptr)
|
||||
delete httpd;
|
||||
|
||||
|
||||
@@ -91,11 +91,11 @@ public:
|
||||
return &base;
|
||||
}
|
||||
|
||||
bool Initialize(const config_param ¶m, Error &error) {
|
||||
return base.Configure(param, error);
|
||||
bool Initialize(const ConfigBlock &block, Error &error) {
|
||||
return base.Configure(block, error);
|
||||
}
|
||||
|
||||
bool Configure(const config_param ¶m, Error &error);
|
||||
bool Configure(const ConfigBlock &block, Error &error);
|
||||
|
||||
bool Open(AudioFormat &audio_format, Error &error);
|
||||
void Close();
|
||||
@@ -129,7 +129,7 @@ private:
|
||||
static constexpr Domain sles_domain("sles");
|
||||
|
||||
inline bool
|
||||
SlesOutput::Configure(const config_param &, Error &)
|
||||
SlesOutput::Configure(const ConfigBlock &, Error &)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -445,12 +445,12 @@ sles_test_default_device()
|
||||
}
|
||||
|
||||
static AudioOutput *
|
||||
sles_output_init(const config_param ¶m, Error &error)
|
||||
sles_output_init(const ConfigBlock &block, Error &error)
|
||||
{
|
||||
SlesOutput *sles = new SlesOutput();
|
||||
|
||||
if (!sles->Initialize(param, error) ||
|
||||
!sles->Configure(param, error)) {
|
||||
if (!sles->Initialize(block, error) ||
|
||||
!sles->Configure(block, error)) {
|
||||
delete sles;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user