OutputPlugin: pass config_param reference
This commit is contained in:
parent
7a1d466fb2
commit
81c3224076
@ -80,6 +80,15 @@ struct config_param {
|
|||||||
|
|
||||||
config_param &operator=(const config_param &) = delete;
|
config_param &operator=(const config_param &) = delete;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine if this is a "null" instance, i.e. an empty
|
||||||
|
* object that was synthesized and not loaded from a
|
||||||
|
* configuration file.
|
||||||
|
*/
|
||||||
|
bool IsNull() const {
|
||||||
|
return line == unsigned(-1);
|
||||||
|
}
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
void AddBlockParam(const char *_name, const char *_value,
|
void AddBlockParam(const char *_name, const char *_value,
|
||||||
int _line=-1) {
|
int _line=-1) {
|
||||||
|
@ -109,16 +109,23 @@ audio_output_all_init(struct player_control *pc)
|
|||||||
num_audio_outputs = audio_output_config_count();
|
num_audio_outputs = audio_output_config_count();
|
||||||
audio_outputs = g_new(struct audio_output *, num_audio_outputs);
|
audio_outputs = g_new(struct audio_output *, num_audio_outputs);
|
||||||
|
|
||||||
|
const config_param empty;
|
||||||
|
|
||||||
for (i = 0; i < num_audio_outputs; i++)
|
for (i = 0; i < num_audio_outputs; i++)
|
||||||
{
|
{
|
||||||
unsigned int j;
|
unsigned int j;
|
||||||
|
|
||||||
param = config_get_next_param(CONF_AUDIO_OUTPUT, param);
|
param = config_get_next_param(CONF_AUDIO_OUTPUT, param);
|
||||||
|
if (param == nullptr) {
|
||||||
|
/* only allow param to be nullptr if there
|
||||||
|
just one audio output */
|
||||||
|
assert(i == 0);
|
||||||
|
assert(num_audio_outputs == 1);
|
||||||
|
|
||||||
/* only allow param to be NULL if there just one audioOutput */
|
param = ∅
|
||||||
assert(param || (num_audio_outputs == 1));
|
}
|
||||||
|
|
||||||
struct audio_output *output = audio_output_new(param, pc, &error);
|
struct audio_output *output = audio_output_new(*param, pc, &error);
|
||||||
if (output == NULL) {
|
if (output == NULL) {
|
||||||
if (param != NULL)
|
if (param != NULL)
|
||||||
MPD_ERROR("line %i: %s",
|
MPD_ERROR("line %i: %s",
|
||||||
|
@ -75,16 +75,17 @@ audio_output_detect(GError **error)
|
|||||||
* This handles the deprecated options mixer_type (global) and
|
* This handles the deprecated options mixer_type (global) and
|
||||||
* mixer_enabled, if the mixer_type setting is not configured.
|
* mixer_enabled, if the mixer_type setting is not configured.
|
||||||
*/
|
*/
|
||||||
|
gcc_pure
|
||||||
static enum mixer_type
|
static enum mixer_type
|
||||||
audio_output_mixer_type(const struct config_param *param)
|
audio_output_mixer_type(const config_param ¶m)
|
||||||
{
|
{
|
||||||
/* read the local "mixer_type" setting */
|
/* read the local "mixer_type" setting */
|
||||||
const char *p = config_get_block_string(param, "mixer_type", NULL);
|
const char *p = param.GetBlockValue("mixer_type");
|
||||||
if (p != NULL)
|
if (p != NULL)
|
||||||
return mixer_type_parse(p);
|
return mixer_type_parse(p);
|
||||||
|
|
||||||
/* try the local "mixer_enabled" setting next (deprecated) */
|
/* try the local "mixer_enabled" setting next (deprecated) */
|
||||||
if (!config_get_block_bool(param, "mixer_enabled", true))
|
if (!param.GetBlockValue("mixer_enabled", true))
|
||||||
return MIXER_TYPE_NONE;
|
return MIXER_TYPE_NONE;
|
||||||
|
|
||||||
/* fall back to the global "mixer_type" setting (also
|
/* fall back to the global "mixer_type" setting (also
|
||||||
@ -95,7 +96,7 @@ audio_output_mixer_type(const struct config_param *param)
|
|||||||
|
|
||||||
static Mixer *
|
static Mixer *
|
||||||
audio_output_load_mixer(struct audio_output *ao,
|
audio_output_load_mixer(struct audio_output *ao,
|
||||||
const struct config_param *param,
|
const config_param ¶m,
|
||||||
const struct mixer_plugin *plugin,
|
const struct mixer_plugin *plugin,
|
||||||
Filter &filter_chain,
|
Filter &filter_chain,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
@ -111,7 +112,7 @@ audio_output_load_mixer(struct audio_output *ao,
|
|||||||
if (plugin == NULL)
|
if (plugin == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return mixer_new(plugin, ao, param, error_r);
|
return mixer_new(plugin, ao, ¶m, error_r);
|
||||||
|
|
||||||
case MIXER_TYPE_SOFTWARE:
|
case MIXER_TYPE_SOFTWARE:
|
||||||
mixer = mixer_new(&software_mixer_plugin, NULL, NULL, NULL);
|
mixer = mixer_new(&software_mixer_plugin, NULL, NULL, NULL);
|
||||||
@ -129,7 +130,7 @@ audio_output_load_mixer(struct audio_output *ao,
|
|||||||
bool
|
bool
|
||||||
ao_base_init(struct audio_output *ao,
|
ao_base_init(struct audio_output *ao,
|
||||||
const struct audio_output_plugin *plugin,
|
const struct audio_output_plugin *plugin,
|
||||||
const struct config_param *param, GError **error_r)
|
const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
assert(ao != NULL);
|
assert(ao != NULL);
|
||||||
assert(plugin != NULL);
|
assert(plugin != NULL);
|
||||||
@ -140,19 +141,15 @@ ao_base_init(struct audio_output *ao,
|
|||||||
|
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
if (param) {
|
if (!param.IsNull()) {
|
||||||
const char *p;
|
ao->name = param.GetBlockValue(AUDIO_OUTPUT_NAME);
|
||||||
|
|
||||||
ao->name = config_get_block_string(param, AUDIO_OUTPUT_NAME,
|
|
||||||
NULL);
|
|
||||||
if (ao->name == NULL) {
|
if (ao->name == NULL) {
|
||||||
g_set_error(error_r, output_quark(), 0,
|
g_set_error(error_r, output_quark(), 0,
|
||||||
"Missing \"name\" configuration");
|
"Missing \"name\" configuration");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
p = config_get_block_string(param, AUDIO_OUTPUT_FORMAT,
|
const char *p = param.GetBlockValue(AUDIO_OUTPUT_FORMAT);
|
||||||
NULL);
|
|
||||||
if (p != NULL) {
|
if (p != NULL) {
|
||||||
bool success =
|
bool success =
|
||||||
audio_format_parse(ao->config_audio_format,
|
audio_format_parse(ao->config_audio_format,
|
||||||
@ -168,9 +165,9 @@ ao_base_init(struct audio_output *ao,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ao->plugin = plugin;
|
ao->plugin = plugin;
|
||||||
ao->tags = config_get_block_bool(param, "tags", true);
|
ao->tags = param.GetBlockValue("tags", true);
|
||||||
ao->always_on = config_get_block_bool(param, "always_on", false);
|
ao->always_on = param.GetBlockValue("always_on", false);
|
||||||
ao->enabled = config_get_block_bool(param, "enabled", true);
|
ao->enabled = param.GetBlockValue("enabled", true);
|
||||||
ao->really_enabled = false;
|
ao->really_enabled = false;
|
||||||
ao->open = false;
|
ao->open = false;
|
||||||
ao->pause = false;
|
ao->pause = false;
|
||||||
@ -194,7 +191,7 @@ ao_base_init(struct audio_output *ao,
|
|||||||
}
|
}
|
||||||
|
|
||||||
filter_chain_parse(*ao->filter,
|
filter_chain_parse(*ao->filter,
|
||||||
config_get_block_string(param, AUDIO_FILTERS, ""),
|
param.GetBlockValue(AUDIO_FILTERS, ""),
|
||||||
&error
|
&error
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -219,25 +216,24 @@ ao_base_init(struct audio_output *ao,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
audio_output_setup(struct audio_output *ao, const struct config_param *param,
|
audio_output_setup(struct audio_output *ao, const config_param ¶m,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
|
|
||||||
/* create the replay_gain filter */
|
/* create the replay_gain filter */
|
||||||
|
|
||||||
const char *replay_gain_handler =
|
const char *replay_gain_handler =
|
||||||
config_get_block_string(param, "replay_gain_handler",
|
param.GetBlockValue("replay_gain_handler", "software");
|
||||||
"software");
|
|
||||||
|
|
||||||
if (strcmp(replay_gain_handler, "none") != 0) {
|
if (strcmp(replay_gain_handler, "none") != 0) {
|
||||||
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
ao->replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||||
param, NULL);
|
¶m, NULL);
|
||||||
assert(ao->replay_gain_filter != NULL);
|
assert(ao->replay_gain_filter != NULL);
|
||||||
|
|
||||||
ao->replay_gain_serial = 0;
|
ao->replay_gain_serial = 0;
|
||||||
|
|
||||||
ao->other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
ao->other_replay_gain_filter = filter_new(&replay_gain_filter_plugin,
|
||||||
param, NULL);
|
¶m, NULL);
|
||||||
assert(ao->other_replay_gain_filter != NULL);
|
assert(ao->other_replay_gain_filter != NULL);
|
||||||
|
|
||||||
ao->other_replay_gain_serial = 0;
|
ao->other_replay_gain_serial = 0;
|
||||||
@ -284,16 +280,16 @@ audio_output_setup(struct audio_output *ao, const struct config_param *param,
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct audio_output *
|
struct audio_output *
|
||||||
audio_output_new(const struct config_param *param,
|
audio_output_new(const config_param ¶m,
|
||||||
struct player_control *pc,
|
struct player_control *pc,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
const struct audio_output_plugin *plugin;
|
const struct audio_output_plugin *plugin;
|
||||||
|
|
||||||
if (param) {
|
if (!param.IsNull()) {
|
||||||
const char *p;
|
const char *p;
|
||||||
|
|
||||||
p = config_get_block_string(param, AUDIO_OUTPUT_TYPE, NULL);
|
p = param.GetBlockValue(AUDIO_OUTPUT_TYPE);
|
||||||
if (p == NULL) {
|
if (p == NULL) {
|
||||||
g_set_error(error_r, output_quark(), 0,
|
g_set_error(error_r, output_quark(), 0,
|
||||||
"Missing \"type\" configuration");
|
"Missing \"type\" configuration");
|
||||||
|
@ -261,14 +261,14 @@ audio_output_command_is_finished(const struct audio_output *ao)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct audio_output *
|
struct audio_output *
|
||||||
audio_output_new(const struct config_param *param,
|
audio_output_new(const config_param ¶m,
|
||||||
struct player_control *pc,
|
struct player_control *pc,
|
||||||
GError **error_r);
|
GError **error_r);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ao_base_init(struct audio_output *ao,
|
ao_base_init(struct audio_output *ao,
|
||||||
const struct audio_output_plugin *plugin,
|
const struct audio_output_plugin *plugin,
|
||||||
const struct config_param *param, GError **error_r);
|
const config_param ¶m, GError **error_r);
|
||||||
|
|
||||||
void
|
void
|
||||||
ao_base_finish(struct audio_output *ao);
|
ao_base_finish(struct audio_output *ao);
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
struct audio_output *
|
struct audio_output *
|
||||||
ao_plugin_init(const struct audio_output_plugin *plugin,
|
ao_plugin_init(const struct audio_output_plugin *plugin,
|
||||||
const struct config_param *param,
|
const config_param ¶m,
|
||||||
GError **error)
|
GError **error)
|
||||||
{
|
{
|
||||||
assert(plugin != NULL);
|
assert(plugin != NULL);
|
||||||
|
@ -55,7 +55,7 @@ struct audio_output_plugin {
|
|||||||
* @return NULL on error, or an opaque pointer to the plugin's
|
* @return NULL on error, or an opaque pointer to the plugin's
|
||||||
* data
|
* data
|
||||||
*/
|
*/
|
||||||
struct audio_output *(*init)(const struct config_param *param,
|
struct audio_output *(*init)(const config_param ¶m,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -168,7 +168,7 @@ ao_plugin_test_default_device(const struct audio_output_plugin *plugin)
|
|||||||
gcc_malloc
|
gcc_malloc
|
||||||
struct audio_output *
|
struct audio_output *
|
||||||
ao_plugin_init(const struct audio_output_plugin *plugin,
|
ao_plugin_init(const struct audio_output_plugin *plugin,
|
||||||
const struct config_param *param,
|
const config_param ¶m,
|
||||||
GError **error);
|
GError **error);
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -37,9 +37,7 @@
|
|||||||
|
|
||||||
static const char default_device[] = "default";
|
static const char default_device[] = "default";
|
||||||
|
|
||||||
enum {
|
static constexpr unsigned MPD_ALSA_BUFFER_TIME_US = 500000;
|
||||||
MPD_ALSA_BUFFER_TIME_US = 500000,
|
|
||||||
};
|
|
||||||
|
|
||||||
#define MPD_ALSA_RETRY_NR 5
|
#define MPD_ALSA_RETRY_NR 5
|
||||||
|
|
||||||
@ -117,7 +115,7 @@ struct AlsaOutput {
|
|||||||
AlsaOutput():mode(0), writei(snd_pcm_writei) {
|
AlsaOutput():mode(0), writei(snd_pcm_writei) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Init(const config_param *param, GError **error_r) {
|
bool Init(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &alsa_output_plugin,
|
return ao_base_init(&base, &alsa_output_plugin,
|
||||||
param, error_r);
|
param, error_r);
|
||||||
}
|
}
|
||||||
@ -143,36 +141,36 @@ alsa_device(const AlsaOutput *ad)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
alsa_configure(AlsaOutput *ad, const struct config_param *param)
|
alsa_configure(AlsaOutput *ad, const config_param ¶m)
|
||||||
{
|
{
|
||||||
ad->device = config_get_block_string(param, "device", "");
|
ad->device = param.GetBlockValue("device", "");
|
||||||
|
|
||||||
ad->use_mmap = config_get_block_bool(param, "use_mmap", false);
|
ad->use_mmap = param.GetBlockValue("use_mmap", false);
|
||||||
|
|
||||||
ad->dsd_usb = config_get_block_bool(param, "dsd_usb", false);
|
ad->dsd_usb = param.GetBlockValue("dsd_usb", false);
|
||||||
|
|
||||||
ad->buffer_time = config_get_block_unsigned(param, "buffer_time",
|
ad->buffer_time = param.GetBlockValue("buffer_time",
|
||||||
MPD_ALSA_BUFFER_TIME_US);
|
MPD_ALSA_BUFFER_TIME_US);
|
||||||
ad->period_time = config_get_block_unsigned(param, "period_time", 0);
|
ad->period_time = param.GetBlockValue("period_time", 0u);
|
||||||
|
|
||||||
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
#ifdef SND_PCM_NO_AUTO_RESAMPLE
|
||||||
if (!config_get_block_bool(param, "auto_resample", true))
|
if (!param.GetBlockValue("auto_resample", true))
|
||||||
ad->mode |= SND_PCM_NO_AUTO_RESAMPLE;
|
ad->mode |= SND_PCM_NO_AUTO_RESAMPLE;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SND_PCM_NO_AUTO_CHANNELS
|
#ifdef SND_PCM_NO_AUTO_CHANNELS
|
||||||
if (!config_get_block_bool(param, "auto_channels", true))
|
if (!param.GetBlockValue("auto_channels", true))
|
||||||
ad->mode |= SND_PCM_NO_AUTO_CHANNELS;
|
ad->mode |= SND_PCM_NO_AUTO_CHANNELS;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SND_PCM_NO_AUTO_FORMAT
|
#ifdef SND_PCM_NO_AUTO_FORMAT
|
||||||
if (!config_get_block_bool(param, "auto_format", true))
|
if (!param.GetBlockValue("auto_format", true))
|
||||||
ad->mode |= SND_PCM_NO_AUTO_FORMAT;
|
ad->mode |= SND_PCM_NO_AUTO_FORMAT;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
alsa_init(const struct config_param *param, GError **error_r)
|
alsa_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
AlsaOutput *ad = new AlsaOutput();
|
AlsaOutput *ad = new AlsaOutput();
|
||||||
|
|
||||||
|
@ -42,7 +42,7 @@ struct AoOutput {
|
|||||||
ao_option *options;
|
ao_option *options;
|
||||||
ao_device *device;
|
ao_device *device;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &ao_output_plugin, param,
|
return ao_base_init(&base, &ao_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ struct AoOutput {
|
|||||||
ao_base_finish(&base);
|
ao_base_finish(&base);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param *param, GError **error_r);
|
bool Configure(const config_param ¶m, GError **error_r);
|
||||||
};
|
};
|
||||||
|
|
||||||
static inline GQuark
|
static inline GQuark
|
||||||
@ -95,20 +95,20 @@ ao_output_error(GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
AoOutput::Configure(const config_param *param, GError **error_r)
|
AoOutput::Configure(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
options = nullptr;
|
options = nullptr;
|
||||||
|
|
||||||
write_size = config_get_block_unsigned(param, "write_size", 1024);
|
write_size = param.GetBlockValue("write_size", 1024u);
|
||||||
|
|
||||||
if (ao_output_ref == 0) {
|
if (ao_output_ref == 0) {
|
||||||
ao_initialize();
|
ao_initialize();
|
||||||
}
|
}
|
||||||
ao_output_ref++;
|
ao_output_ref++;
|
||||||
|
|
||||||
value = config_get_block_string(param, "driver", "default");
|
value = param.GetBlockValue("driver", "default");
|
||||||
if (0 == strcmp(value, "default"))
|
if (0 == strcmp(value, "default"))
|
||||||
driver = ao_default_driver_id();
|
driver = ao_default_driver_id();
|
||||||
else
|
else
|
||||||
@ -129,9 +129,9 @@ AoOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
g_debug("using ao driver \"%s\" for \"%s\"\n", ai->short_name,
|
g_debug("using ao driver \"%s\" for \"%s\"\n", ai->short_name,
|
||||||
config_get_block_string(param, "name", nullptr));
|
param.GetBlockValue("name", nullptr));
|
||||||
|
|
||||||
value = config_get_block_string(param, "options", nullptr);
|
value = param.GetBlockValue("options", nullptr);
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
gchar **_options = g_strsplit(value, ";", 0);
|
gchar **_options = g_strsplit(value, ";", 0);
|
||||||
|
|
||||||
@ -158,7 +158,7 @@ AoOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
ao_output_init(const config_param *param, GError **error_r)
|
ao_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
AoOutput *ad = new AoOutput();
|
AoOutput *ad = new AoOutput();
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ struct FifoOutput {
|
|||||||
g_free(path);
|
g_free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &fifo_output_plugin, param,
|
return ao_base_init(&base, &fifo_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -186,10 +186,10 @@ fifo_open(FifoOutput *fd, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
fifo_output_init(const config_param *param, GError **error_r)
|
fifo_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
GError *error = nullptr;
|
GError *error = nullptr;
|
||||||
char *path = config_dup_block_path(param, "path", &error);
|
char *path = param.DupBlockPath("path", &error);
|
||||||
if (!path) {
|
if (!path) {
|
||||||
if (error != nullptr)
|
if (error != nullptr)
|
||||||
g_propagate_error(error_r, error);
|
g_propagate_error(error_r, error);
|
||||||
|
@ -123,7 +123,7 @@ struct HttpdOutput final : private ServerSocket {
|
|||||||
HttpdOutput(EventLoop &_loop);
|
HttpdOutput(EventLoop &_loop);
|
||||||
~HttpdOutput();
|
~HttpdOutput();
|
||||||
|
|
||||||
bool Configure(const config_param *param, GError **error_r);
|
bool Configure(const config_param ¶m, GError **error_r);
|
||||||
|
|
||||||
bool Bind(GError **error_r);
|
bool Bind(GError **error_r);
|
||||||
void Unbind();
|
void Unbind();
|
||||||
|
@ -91,18 +91,17 @@ HttpdOutput::Unbind()
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
HttpdOutput::Configure(const config_param *param, GError **error_r)
|
HttpdOutput::Configure(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
/* read configuration */
|
/* read configuration */
|
||||||
name = config_get_block_string(param, "name", "Set name in config");
|
name = param.GetBlockValue("name", "Set name in config");
|
||||||
genre = config_get_block_string(param, "genre", "Set genre in config");
|
genre = param.GetBlockValue("genre", "Set genre in config");
|
||||||
website = config_get_block_string(param, "website",
|
website = param.GetBlockValue("website", "Set website in config");
|
||||||
"Set website in config");
|
|
||||||
|
|
||||||
guint port = config_get_block_unsigned(param, "port", 8000);
|
guint port = param.GetBlockValue("port", 8000u);
|
||||||
|
|
||||||
const char *encoder_name =
|
const char *encoder_name =
|
||||||
config_get_block_string(param, "encoder", "vorbis");
|
param.GetBlockValue("encoder", "vorbis");
|
||||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||||
if (encoder_plugin == NULL) {
|
if (encoder_plugin == NULL) {
|
||||||
g_set_error(error_r, httpd_output_quark(), 0,
|
g_set_error(error_r, httpd_output_quark(), 0,
|
||||||
@ -110,12 +109,11 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
clients_max = config_get_block_unsigned(param,"max_clients", 0);
|
clients_max = param.GetBlockValue("max_clients", 0u);
|
||||||
|
|
||||||
/* set up bind_to_address */
|
/* set up bind_to_address */
|
||||||
|
|
||||||
const char *bind_to_address =
|
const char *bind_to_address = param.GetBlockValue("bind_to_address");
|
||||||
config_get_block_string(param, "bind_to_address", NULL);
|
|
||||||
bool success = bind_to_address != NULL &&
|
bool success = bind_to_address != NULL &&
|
||||||
strcmp(bind_to_address, "any") != 0
|
strcmp(bind_to_address, "any") != 0
|
||||||
? AddHost(bind_to_address, port, error_r)
|
? AddHost(bind_to_address, port, error_r)
|
||||||
@ -125,7 +123,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
|
|
||||||
/* initialize encoder */
|
/* initialize encoder */
|
||||||
|
|
||||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
encoder = encoder_init(*encoder_plugin, ¶m, error_r);
|
||||||
if (encoder == nullptr)
|
if (encoder == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -138,7 +136,7 @@ HttpdOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
httpd_output_init(const struct config_param *param,
|
httpd_output_init(const struct config_param ¶m,
|
||||||
GError **error_r)
|
GError **error_r)
|
||||||
{
|
{
|
||||||
HttpdOutput *httpd = new HttpdOutput(*main_loop);
|
HttpdOutput *httpd = new HttpdOutput(*main_loop);
|
||||||
|
@ -82,7 +82,7 @@ struct JackOutput {
|
|||||||
*/
|
*/
|
||||||
bool pause;
|
bool pause;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &jack_output_plugin, param,
|
return ao_base_init(&base, &jack_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -323,7 +323,7 @@ parse_port_list(int line, const char *source, char **dest, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
mpd_jack_init(const config_param *param, GError **error_r)
|
mpd_jack_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
JackOutput *jd = new JackOutput();
|
JackOutput *jd = new JackOutput();
|
||||||
|
|
||||||
@ -336,7 +336,7 @@ mpd_jack_init(const config_param *param, GError **error_r)
|
|||||||
|
|
||||||
jd->options = JackNullOption;
|
jd->options = JackNullOption;
|
||||||
|
|
||||||
jd->name = config_get_block_string(param, "client_name", nullptr);
|
jd->name = param.GetBlockValue("client_name", nullptr);
|
||||||
if (jd->name != nullptr)
|
if (jd->name != nullptr)
|
||||||
jd->options = jack_options_t(jd->options | JackUseExactName);
|
jd->options = jack_options_t(jd->options | JackUseExactName);
|
||||||
else
|
else
|
||||||
@ -344,35 +344,35 @@ mpd_jack_init(const config_param *param, GError **error_r)
|
|||||||
care about the JackUseExactName option */
|
care about the JackUseExactName option */
|
||||||
jd->name = "Music Player Daemon";
|
jd->name = "Music Player Daemon";
|
||||||
|
|
||||||
jd->server_name = config_get_block_string(param, "server_name", nullptr);
|
jd->server_name = param.GetBlockValue("server_name", nullptr);
|
||||||
if (jd->server_name != nullptr)
|
if (jd->server_name != nullptr)
|
||||||
jd->options = jack_options_t(jd->options | JackServerName);
|
jd->options = jack_options_t(jd->options | JackServerName);
|
||||||
|
|
||||||
if (!config_get_block_bool(param, "autostart", false))
|
if (!param.GetBlockValue("autostart", false))
|
||||||
jd->options = jack_options_t(jd->options | JackNoStartServer);
|
jd->options = jack_options_t(jd->options | JackNoStartServer);
|
||||||
|
|
||||||
/* configure the source ports */
|
/* configure the source ports */
|
||||||
|
|
||||||
value = config_get_block_string(param, "source_ports", "left,right");
|
value = param.GetBlockValue("source_ports", "left,right");
|
||||||
jd->num_source_ports = parse_port_list(param->line, value,
|
jd->num_source_ports = parse_port_list(param.line, value,
|
||||||
jd->source_ports, error_r);
|
jd->source_ports, error_r);
|
||||||
if (jd->num_source_ports == 0)
|
if (jd->num_source_ports == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
/* configure the destination ports */
|
/* configure the destination ports */
|
||||||
|
|
||||||
value = config_get_block_string(param, "destination_ports", nullptr);
|
value = param.GetBlockValue("destination_ports", nullptr);
|
||||||
if (value == nullptr) {
|
if (value == nullptr) {
|
||||||
/* compatibility with MPD < 0.16 */
|
/* compatibility with MPD < 0.16 */
|
||||||
value = config_get_block_string(param, "ports", nullptr);
|
value = param.GetBlockValue("ports", nullptr);
|
||||||
if (value != nullptr)
|
if (value != nullptr)
|
||||||
g_warning("deprecated option 'ports' in line %d",
|
g_warning("deprecated option 'ports' in line %d",
|
||||||
param->line);
|
param.line);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
jd->num_destination_ports =
|
jd->num_destination_ports =
|
||||||
parse_port_list(param->line, value,
|
parse_port_list(param.line, value,
|
||||||
jd->destination_ports, error_r);
|
jd->destination_ports, error_r);
|
||||||
if (jd->num_destination_ports == 0)
|
if (jd->num_destination_ports == 0)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
@ -385,10 +385,9 @@ mpd_jack_init(const config_param *param, GError **error_r)
|
|||||||
g_warning("number of source ports (%u) mismatches the "
|
g_warning("number of source ports (%u) mismatches the "
|
||||||
"number of destination ports (%u) in line %d",
|
"number of destination ports (%u) in line %d",
|
||||||
jd->num_source_ports, jd->num_destination_ports,
|
jd->num_source_ports, jd->num_destination_ports,
|
||||||
param->line);
|
param.line);
|
||||||
|
|
||||||
jd->ringbuffer_size =
|
jd->ringbuffer_size = param.GetBlockValue("ringbuffer_size", 32768u);
|
||||||
config_get_block_unsigned(param, "ringbuffer_size", 32768);
|
|
||||||
|
|
||||||
jack_set_error_function(mpd_jack_error);
|
jack_set_error_function(mpd_jack_error);
|
||||||
|
|
||||||
|
@ -31,7 +31,7 @@ struct NullOutput {
|
|||||||
|
|
||||||
Timer *timer;
|
Timer *timer;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &null_output_plugin, param,
|
return ao_base_init(&base, &null_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -42,7 +42,7 @@ struct NullOutput {
|
|||||||
};
|
};
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
null_init(const config_param *param, GError **error_r)
|
null_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
NullOutput *nd = new NullOutput();
|
NullOutput *nd = new NullOutput();
|
||||||
|
|
||||||
@ -51,7 +51,7 @@ null_init(const config_param *param, GError **error_r)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
nd->sync = config_get_block_bool(param, "sync", true);
|
nd->sync = param.GetBlockValue("sync", true);
|
||||||
|
|
||||||
return &nd->base;
|
return &nd->base;
|
||||||
}
|
}
|
||||||
|
@ -65,9 +65,9 @@ osx_output_test_default_device(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
osx_output_configure(OSXOutput *oo, const struct config_param *param)
|
osx_output_configure(OSXOutput *oo, const config_param ¶m)
|
||||||
{
|
{
|
||||||
const char *device = config_get_block_string(param, "device", NULL);
|
const char *device = param.GetBlockValue("device");
|
||||||
|
|
||||||
if (device == NULL || 0 == strcmp(device, "default")) {
|
if (device == NULL || 0 == strcmp(device, "default")) {
|
||||||
oo->component_subtype = kAudioUnitSubType_DefaultOutput;
|
oo->component_subtype = kAudioUnitSubType_DefaultOutput;
|
||||||
@ -85,7 +85,7 @@ osx_output_configure(OSXOutput *oo, const struct config_param *param)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
osx_output_init(const struct config_param *param, GError **error_r)
|
osx_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
OSXOutput *oo = new OSXOutput();
|
OSXOutput *oo = new OSXOutput();
|
||||||
if (!ao_base_init(&oo->base, &osx_output_plugin, param, error_r)) {
|
if (!ao_base_init(&oo->base, &osx_output_plugin, param, error_r)) {
|
||||||
|
@ -49,7 +49,7 @@ struct OpenALOutput {
|
|||||||
ALenum format;
|
ALenum format;
|
||||||
ALuint frequency;
|
ALuint frequency;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &openal_output_plugin, param,
|
return ao_base_init(&base, &openal_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -140,10 +140,9 @@ openal_setup_context(OpenALOutput *od,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
openal_init(const config_param *param, GError **error_r)
|
openal_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
const char *device_name = config_get_block_string(param, "device", nullptr);
|
const char *device_name = param.GetBlockValue("device");
|
||||||
|
|
||||||
if (device_name == nullptr) {
|
if (device_name == nullptr) {
|
||||||
device_name = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
device_name = alcGetString(nullptr, ALC_DEFAULT_DEVICE_SPECIFIER);
|
||||||
}
|
}
|
||||||
|
@ -80,7 +80,7 @@ struct OssOutput {
|
|||||||
|
|
||||||
OssOutput():fd(-1), device(nullptr) {}
|
OssOutput():fd(-1), device(nullptr) {}
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &oss_output_plugin, param,
|
return ao_base_init(&base, &oss_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -160,11 +160,12 @@ oss_open_default(GError **error)
|
|||||||
int err[G_N_ELEMENTS(default_devices)];
|
int err[G_N_ELEMENTS(default_devices)];
|
||||||
enum oss_stat ret[G_N_ELEMENTS(default_devices)];
|
enum oss_stat ret[G_N_ELEMENTS(default_devices)];
|
||||||
|
|
||||||
|
const config_param empty;
|
||||||
for (int i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
|
for (int i = G_N_ELEMENTS(default_devices); --i >= 0; ) {
|
||||||
ret[i] = oss_stat_device(default_devices[i], &err[i]);
|
ret[i] = oss_stat_device(default_devices[i], &err[i]);
|
||||||
if (ret[i] == OSS_STAT_NO_ERROR) {
|
if (ret[i] == OSS_STAT_NO_ERROR) {
|
||||||
OssOutput *od = new OssOutput();
|
OssOutput *od = new OssOutput();
|
||||||
if (!od->Initialize(nullptr, error)) {
|
if (!od->Initialize(empty, error)) {
|
||||||
delete od;
|
delete od;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -201,9 +202,9 @@ oss_open_default(GError **error)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
oss_output_init(const config_param *param, GError **error_r)
|
oss_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
const char *device = config_get_block_string(param, "device", NULL);
|
const char *device = param.GetBlockValue("device");
|
||||||
if (device != NULL) {
|
if (device != NULL) {
|
||||||
OssOutput *od = new OssOutput();
|
OssOutput *od = new OssOutput();
|
||||||
if (!od->Initialize(param, error_r)) {
|
if (!od->Initialize(param, error_r)) {
|
||||||
|
@ -30,7 +30,7 @@ struct PipeOutput {
|
|||||||
char *cmd;
|
char *cmd;
|
||||||
FILE *fh;
|
FILE *fh;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &pipe_output_plugin, param,
|
return ao_base_init(&base, &pipe_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -39,7 +39,7 @@ struct PipeOutput {
|
|||||||
ao_base_finish(&base);
|
ao_base_finish(&base);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param *param, GError **error_r);
|
bool Configure(const config_param ¶m, GError **error_r);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -52,9 +52,9 @@ pipe_output_quark(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
PipeOutput::Configure(const config_param *param, GError **error_r)
|
PipeOutput::Configure(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
cmd = config_dup_block_string(param, "command", nullptr);
|
cmd = param.DupBlockString("command");
|
||||||
if (cmd == nullptr) {
|
if (cmd == nullptr) {
|
||||||
g_set_error(error_r, pipe_output_quark(), 0,
|
g_set_error(error_r, pipe_output_quark(), 0,
|
||||||
"No \"command\" parameter specified");
|
"No \"command\" parameter specified");
|
||||||
@ -65,7 +65,7 @@ PipeOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
pipe_output_init(const config_param *param, GError **error_r)
|
pipe_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
PipeOutput *pd = new PipeOutput();
|
PipeOutput *pd = new PipeOutput();
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ pulse_output_setup_context(PulseOutput *po, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
pulse_output_init(const struct config_param *param, GError **error_r)
|
pulse_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
PulseOutput *po;
|
PulseOutput *po;
|
||||||
|
|
||||||
@ -356,9 +356,9 @@ pulse_output_init(const struct config_param *param, GError **error_r)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
po->name = config_get_block_string(param, "name", "mpd_pulse");
|
po->name = param.GetBlockValue("name", "mpd_pulse");
|
||||||
po->server = config_get_block_string(param, "server", nullptr);
|
po->server = param.GetBlockValue("server");
|
||||||
po->sink = config_get_block_string(param, "sink", nullptr);
|
po->sink = param.GetBlockValue("sink");
|
||||||
|
|
||||||
po->mixer = nullptr;
|
po->mixer = nullptr;
|
||||||
po->mainloop = nullptr;
|
po->mainloop = nullptr;
|
||||||
@ -923,10 +923,10 @@ pulse_output_pause(struct audio_output *ao)
|
|||||||
static bool
|
static bool
|
||||||
pulse_output_test_default_device(void)
|
pulse_output_test_default_device(void)
|
||||||
{
|
{
|
||||||
PulseOutput *po;
|
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
po = (PulseOutput *)pulse_output_init(nullptr, nullptr);
|
const config_param empty;
|
||||||
|
PulseOutput *po = (PulseOutput *)pulse_output_init(empty, nullptr);
|
||||||
if (po == nullptr)
|
if (po == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
@ -57,7 +57,7 @@ struct RecorderOutput {
|
|||||||
*/
|
*/
|
||||||
char buffer[32768];
|
char buffer[32768];
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &recorder_output_plugin, param,
|
return ao_base_init(&base, &recorder_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -66,7 +66,7 @@ struct RecorderOutput {
|
|||||||
ao_base_finish(&base);
|
ao_base_finish(&base);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param *param, GError **error_r);
|
bool Configure(const config_param ¶m, GError **error_r);
|
||||||
|
|
||||||
bool WriteToFile(const void *data, size_t length, GError **error_r);
|
bool WriteToFile(const void *data, size_t length, GError **error_r);
|
||||||
|
|
||||||
@ -86,12 +86,12 @@ recorder_output_quark(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
RecorderOutput::Configure(const config_param *param, GError **error_r)
|
RecorderOutput::Configure(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
/* read configuration */
|
/* read configuration */
|
||||||
|
|
||||||
const char *encoder_name =
|
const char *encoder_name =
|
||||||
config_get_block_string(param, "encoder", "vorbis");
|
param.GetBlockValue("encoder", "vorbis");
|
||||||
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
const auto encoder_plugin = encoder_plugin_get(encoder_name);
|
||||||
if (encoder_plugin == nullptr) {
|
if (encoder_plugin == nullptr) {
|
||||||
g_set_error(error_r, recorder_output_quark(), 0,
|
g_set_error(error_r, recorder_output_quark(), 0,
|
||||||
@ -99,7 +99,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
path = config_get_block_string(param, "path", nullptr);
|
path = param.GetBlockValue("path");
|
||||||
if (path == nullptr) {
|
if (path == nullptr) {
|
||||||
g_set_error(error_r, recorder_output_quark(), 0,
|
g_set_error(error_r, recorder_output_quark(), 0,
|
||||||
"'path' not configured");
|
"'path' not configured");
|
||||||
@ -108,7 +108,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
|
|
||||||
/* initialize encoder */
|
/* initialize encoder */
|
||||||
|
|
||||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
encoder = encoder_init(*encoder_plugin, ¶m, error_r);
|
||||||
if (encoder == nullptr)
|
if (encoder == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -116,7 +116,7 @@ RecorderOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static audio_output *
|
static audio_output *
|
||||||
recorder_output_init(const config_param *param, GError **error_r)
|
recorder_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
RecorderOutput *recorder = new RecorderOutput();
|
RecorderOutput *recorder = new RecorderOutput();
|
||||||
|
|
||||||
|
@ -108,19 +108,19 @@ roar_output_set_volume(RoarOutput *roar, unsigned volume)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
roar_configure(RoarOutput *self, const struct config_param *param)
|
roar_configure(RoarOutput *self, const config_param ¶m)
|
||||||
{
|
{
|
||||||
self->host = config_dup_block_string(param, "server", nullptr);
|
self->host = param.DupBlockString("server", nullptr);
|
||||||
self->name = config_dup_block_string(param, "name", "MPD");
|
self->name = param.DupBlockString("name", "MPD");
|
||||||
|
|
||||||
const char *role = config_get_block_string(param, "role", "music");
|
const char *role = param.GetBlockValue("role", "music");
|
||||||
self->role = role != nullptr
|
self->role = role != nullptr
|
||||||
? roar_str2role(role)
|
? roar_str2role(role)
|
||||||
: ROAR_ROLE_MUSIC;
|
: ROAR_ROLE_MUSIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
roar_init(const struct config_param *param, GError **error_r)
|
roar_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
RoarOutput *self = new RoarOutput();
|
RoarOutput *self = new RoarOutput();
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@
|
|||||||
#undef G_LOG_DOMAIN
|
#undef G_LOG_DOMAIN
|
||||||
#define G_LOG_DOMAIN "shout"
|
#define G_LOG_DOMAIN "shout"
|
||||||
|
|
||||||
#define DEFAULT_CONN_TIMEOUT 2
|
static constexpr unsigned DEFAULT_CONN_TIMEOUT = 2;
|
||||||
|
|
||||||
struct ShoutOutput final {
|
struct ShoutOutput final {
|
||||||
struct audio_output base;
|
struct audio_output base;
|
||||||
@ -66,7 +66,7 @@ struct ShoutOutput final {
|
|||||||
shout_free(shout_conn);
|
shout_free(shout_conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &shout_output_plugin, param,
|
return ao_base_init(&base, &shout_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -75,7 +75,7 @@ struct ShoutOutput final {
|
|||||||
ao_base_finish(&base);
|
ao_base_finish(&base);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Configure(const config_param *param, GError **error_r);
|
bool Configure(const config_param ¶m, GError **error_r);
|
||||||
};
|
};
|
||||||
|
|
||||||
static int shout_init_count;
|
static int shout_init_count;
|
||||||
@ -102,18 +102,18 @@ shout_encoder_plugin_get(const char *name)
|
|||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
static const char *
|
static const char *
|
||||||
require_block_string(const struct config_param *param, const char *name)
|
require_block_string(const config_param ¶m, const char *name)
|
||||||
{
|
{
|
||||||
const char *value = config_get_block_string(param, name, nullptr);
|
const char *value = param.GetBlockValue(name);
|
||||||
if (value == nullptr)
|
if (value == nullptr)
|
||||||
MPD_ERROR("no \"%s\" defined for shout device defined at line " \
|
MPD_ERROR("no \"%s\" defined for shout device defined at line " \
|
||||||
"%i\n", name, param->line); \
|
"%i\n", name, param.line);
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline bool
|
inline bool
|
||||||
ShoutOutput::Configure(const config_param *param, GError **error_r)
|
ShoutOutput::Configure(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
|
|
||||||
const AudioFormat audio_format = base.config_audio_format;
|
const AudioFormat audio_format = base.config_audio_format;
|
||||||
@ -125,8 +125,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
|
|
||||||
const char *host = require_block_string(param, "host");
|
const char *host = require_block_string(param, "host");
|
||||||
const char *mount = require_block_string(param, "mount");
|
const char *mount = require_block_string(param, "mount");
|
||||||
|
unsigned port = param.GetBlockValue("port", 0u);
|
||||||
unsigned port = config_get_block_unsigned(param, "port", 0);
|
|
||||||
if (port == 0) {
|
if (port == 0) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"shout port must be configured");
|
"shout port must be configured");
|
||||||
@ -136,11 +135,11 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
const char *passwd = require_block_string(param, "password");
|
const char *passwd = require_block_string(param, "password");
|
||||||
const char *name = require_block_string(param, "name");
|
const char *name = require_block_string(param, "name");
|
||||||
|
|
||||||
bool is_public = config_get_block_bool(param, "public", false);
|
bool is_public = param.GetBlockValue("public", false);
|
||||||
|
|
||||||
const char *user = config_get_block_string(param, "user", "source");
|
const char *user = param.GetBlockValue("user", "source");
|
||||||
|
|
||||||
const char *value = config_get_block_string(param, "quality", nullptr);
|
const char *value = param.GetBlockValue("quality");
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
char *test;
|
char *test;
|
||||||
quality = strtod(value, &test);
|
quality = strtod(value, &test);
|
||||||
@ -149,18 +148,18 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"shout quality \"%s\" is not a number in the "
|
"shout quality \"%s\" is not a number in the "
|
||||||
"range -1 to 10, line %i",
|
"range -1 to 10, line %i",
|
||||||
value, param->line);
|
value, param.line);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (config_get_block_string(param, "bitrate", nullptr) != nullptr) {
|
if (param.GetBlockValue("bitrate") != nullptr) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"quality and bitrate are "
|
"quality and bitrate are "
|
||||||
"both defined");
|
"both defined");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
value = config_get_block_string(param, "bitrate", nullptr);
|
value = param.GetBlockValue("bitrate");
|
||||||
if (value == nullptr) {
|
if (value == nullptr) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"neither bitrate nor quality defined");
|
"neither bitrate nor quality defined");
|
||||||
@ -177,8 +176,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *encoding = config_get_block_string(param, "encoding",
|
const char *encoding = param.GetBlockValue("encoding", "ogg");
|
||||||
"ogg");
|
|
||||||
const auto encoder_plugin = shout_encoder_plugin_get(encoding);
|
const auto encoder_plugin = shout_encoder_plugin_get(encoding);
|
||||||
if (encoder_plugin == nullptr) {
|
if (encoder_plugin == nullptr) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
@ -187,7 +185,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
encoder = encoder_init(*encoder_plugin, param, error_r);
|
encoder = encoder_init(*encoder_plugin, ¶m, error_r);
|
||||||
if (encoder == nullptr)
|
if (encoder == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
@ -198,7 +196,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
shout_format = SHOUT_FORMAT_OGG;
|
shout_format = SHOUT_FORMAT_OGG;
|
||||||
|
|
||||||
unsigned protocol;
|
unsigned protocol;
|
||||||
value = config_get_block_string(param, "protocol", nullptr);
|
value = param.GetBlockValue("protocol");
|
||||||
if (value != nullptr) {
|
if (value != nullptr) {
|
||||||
if (0 == strcmp(value, "shoutcast") &&
|
if (0 == strcmp(value, "shoutcast") &&
|
||||||
0 != strcmp(encoding, "mp3")) {
|
0 != strcmp(encoding, "mp3")) {
|
||||||
@ -240,24 +238,23 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* optional paramters */
|
/* optional paramters */
|
||||||
timeout = config_get_block_unsigned(param, "timeout",
|
timeout = param.GetBlockValue("timeout", DEFAULT_CONN_TIMEOUT);
|
||||||
DEFAULT_CONN_TIMEOUT);
|
|
||||||
|
|
||||||
value = config_get_block_string(param, "genre", nullptr);
|
value = param.GetBlockValue("genre");
|
||||||
if (value != nullptr && shout_set_genre(shout_conn, value)) {
|
if (value != nullptr && shout_set_genre(shout_conn, value)) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"%s", shout_get_error(shout_conn));
|
"%s", shout_get_error(shout_conn));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = config_get_block_string(param, "description", nullptr);
|
value = param.GetBlockValue("description");
|
||||||
if (value != nullptr && shout_set_description(shout_conn, value)) {
|
if (value != nullptr && shout_set_description(shout_conn, value)) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"%s", shout_get_error(shout_conn));
|
"%s", shout_get_error(shout_conn));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
value = config_get_block_string(param, "url", nullptr);
|
value = param.GetBlockValue("url");
|
||||||
if (value != nullptr && shout_set_url(shout_conn, value)) {
|
if (value != nullptr && shout_set_url(shout_conn, value)) {
|
||||||
g_set_error(error_r, shout_output_quark(), 0,
|
g_set_error(error_r, shout_output_quark(), 0,
|
||||||
"%s", shout_get_error(shout_conn));
|
"%s", shout_get_error(shout_conn));
|
||||||
@ -290,7 +287,7 @@ ShoutOutput::Configure(const config_param *param, GError **error_r)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
my_shout_init_driver(const config_param *param, GError **error_r)
|
my_shout_init_driver(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
ShoutOutput *sd = new ShoutOutput();
|
ShoutOutput *sd = new ShoutOutput();
|
||||||
if (!sd->Initialize(param, error_r)) {
|
if (!sd->Initialize(param, error_r)) {
|
||||||
|
@ -61,7 +61,7 @@ struct SolarisOutput {
|
|||||||
|
|
||||||
int fd;
|
int fd;
|
||||||
|
|
||||||
bool Initialize(const config_param *param, GError **error_r) {
|
bool Initialize(const config_param ¶m, GError **error_r) {
|
||||||
return ao_base_init(&base, &solaris_output_plugin, param,
|
return ao_base_init(&base, &solaris_output_plugin, param,
|
||||||
error_r);
|
error_r);
|
||||||
}
|
}
|
||||||
@ -90,7 +90,7 @@ solaris_output_test_default_device(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
solaris_output_init(const config_param *param, GError **error_r)
|
solaris_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
SolarisOutput *so = new SolarisOutput();
|
SolarisOutput *so = new SolarisOutput();
|
||||||
if (!so->Initialize(param, error_r)) {
|
if (!so->Initialize(param, error_r)) {
|
||||||
@ -98,7 +98,7 @@ solaris_output_init(const config_param *param, GError **error_r)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
so->device = config_get_block_string(param, "device", "/dev/audio");
|
so->device = param.GetBlockValue("device", "/dev/audio");
|
||||||
|
|
||||||
return &so->base;
|
return &so->base;
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ fail:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static struct audio_output *
|
static struct audio_output *
|
||||||
winmm_output_init(const struct config_param *param, GError **error_r)
|
winmm_output_init(const config_param ¶m, GError **error_r)
|
||||||
{
|
{
|
||||||
WinmmOutput *wo = new WinmmOutput();
|
WinmmOutput *wo = new WinmmOutput();
|
||||||
if (!ao_base_init(&wo->base, &winmm_output_plugin, param, error_r)) {
|
if (!ao_base_init(&wo->base, &winmm_output_plugin, param, error_r)) {
|
||||||
@ -122,7 +122,7 @@ winmm_output_init(const struct config_param *param, GError **error_r)
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *device = config_get_block_string(param, "device", nullptr);
|
const char *device = param.GetBlockValue("device");
|
||||||
if (!get_device_id(device, &wo->device_id, error_r)) {
|
if (!get_device_id(device, &wo->device_id, error_r)) {
|
||||||
ao_base_finish(&wo->base);
|
ao_base_finish(&wo->base);
|
||||||
g_free(wo);
|
g_free(wo);
|
||||||
|
@ -76,8 +76,7 @@ find_named_config_block(ConfigOption option, const char *name)
|
|||||||
const struct config_param *param = NULL;
|
const struct config_param *param = NULL;
|
||||||
|
|
||||||
while ((param = config_get_next_param(option, param)) != NULL) {
|
while ((param = config_get_next_param(option, param)) != NULL) {
|
||||||
const char *current_name =
|
const char *current_name = param->GetBlockValue("name");
|
||||||
config_get_block_string(param, "name", NULL);
|
|
||||||
if (current_name != NULL && strcmp(current_name, name) == 0)
|
if (current_name != NULL && strcmp(current_name, name) == 0)
|
||||||
return param;
|
return param;
|
||||||
}
|
}
|
||||||
@ -104,7 +103,7 @@ load_audio_output(const char *name)
|
|||||||
static struct player_control dummy_player_control(32, 4);
|
static struct player_control dummy_player_control(32, 4);
|
||||||
|
|
||||||
struct audio_output *ao =
|
struct audio_output *ao =
|
||||||
audio_output_new(param, &dummy_player_control, &error);
|
audio_output_new(*param, &dummy_player_control, &error);
|
||||||
if (ao == NULL) {
|
if (ao == NULL) {
|
||||||
g_printerr("%s\n", error->message);
|
g_printerr("%s\n", error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
|
Loading…
Reference in New Issue
Block a user