aboutsummaryrefslogtreecommitdiffstats
path: root/src/encoder
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-08-04 12:24:36 +0200
committerMax Kellermann <max@duempel.org>2013-08-04 14:07:50 +0200
commitca0d09c50fc4246fdae67b8a33799ea580b68593 (patch)
tree0a3fa0f4837c0274d034f8dba52b274f3e519c3a /src/encoder
parent81c3224076da6ad727debc6bab8a5422f7322451 (diff)
downloadmpd-ca0d09c50fc4246fdae67b8a33799ea580b68593.tar.gz
mpd-ca0d09c50fc4246fdae67b8a33799ea580b68593.tar.xz
mpd-ca0d09c50fc4246fdae67b8a33799ea580b68593.zip
EncoderPlugin: pass config_param reference
Diffstat (limited to 'src/encoder')
-rw-r--r--src/encoder/FlacEncoderPlugin.cxx9
-rw-r--r--src/encoder/LameEncoderPlugin.cxx20
-rw-r--r--src/encoder/NullEncoderPlugin.cxx2
-rw-r--r--src/encoder/OpusEncoderPlugin.cxx11
-rw-r--r--src/encoder/TwolameEncoderPlugin.cxx20
-rw-r--r--src/encoder/VorbisEncoderPlugin.cxx18
-rw-r--r--src/encoder/WaveEncoderPlugin.cxx2
7 files changed, 40 insertions, 42 deletions
diff --git a/src/encoder/FlacEncoderPlugin.cxx b/src/encoder/FlacEncoderPlugin.cxx
index 5e7e7f526..a14b97f11 100644
--- a/src/encoder/FlacEncoderPlugin.cxx
+++ b/src/encoder/FlacEncoderPlugin.cxx
@@ -63,17 +63,16 @@ flac_encoder_quark(void)
}
static bool
-flac_encoder_configure(struct flac_encoder *encoder,
- const struct config_param *param, G_GNUC_UNUSED GError **error)
+flac_encoder_configure(struct flac_encoder *encoder, const config_param &param,
+ gcc_unused GError **error)
{
- encoder->compression = config_get_block_unsigned(param,
- "compression", 5);
+ encoder->compression = param.GetBlockValue("compression", 5u);
return true;
}
static Encoder *
-flac_encoder_init(const struct config_param *param, GError **error)
+flac_encoder_init(const config_param &param, GError **error)
{
flac_encoder *encoder = new flac_encoder();
diff --git a/src/encoder/LameEncoderPlugin.cxx b/src/encoder/LameEncoderPlugin.cxx
index ea0b91380..db93b93a3 100644
--- a/src/encoder/LameEncoderPlugin.cxx
+++ b/src/encoder/LameEncoderPlugin.cxx
@@ -43,7 +43,7 @@ struct LameEncoder final {
LameEncoder():encoder(lame_encoder_plugin) {}
- bool Configure(const config_param *param, GError **error);
+ bool Configure(const config_param &param, GError **error);
};
static inline GQuark
@@ -53,12 +53,12 @@ lame_encoder_quark(void)
}
bool
-LameEncoder::Configure(const config_param *param, GError **error)
+LameEncoder::Configure(const config_param &param, GError **error)
{
const char *value;
char *endptr;
- value = config_get_block_string(param, "quality", nullptr);
+ value = param.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -68,26 +68,26 @@ LameEncoder::Configure(const config_param *param, GError **error)
g_set_error(error, lame_encoder_quark(), 0,
"quality \"%s\" is not a number in the "
"range -1 to 10, line %i",
- value, param->line);
+ value, param.line);
return false;
}
- if (config_get_block_string(param, "bitrate", nullptr) != nullptr) {
+ if (param.GetBlockValue("bitrate") != nullptr) {
g_set_error(error, lame_encoder_quark(), 0,
"quality and bitrate are "
"both defined (line %i)",
- param->line);
+ param.line);
return false;
}
} else {
/* a bit rate was configured */
- value = config_get_block_string(param, "bitrate", nullptr);
+ value = param.GetBlockValue("bitrate");
if (value == nullptr) {
g_set_error(error, lame_encoder_quark(), 0,
"neither bitrate nor quality defined "
"at line %i",
- param->line);
+ param.line);
return false;
}
@@ -97,7 +97,7 @@ LameEncoder::Configure(const config_param *param, GError **error)
if (*endptr != '\0' || bitrate <= 0) {
g_set_error(error, lame_encoder_quark(), 0,
"bitrate at line %i should be a positive integer",
- param->line);
+ param.line);
return false;
}
}
@@ -106,7 +106,7 @@ LameEncoder::Configure(const config_param *param, GError **error)
}
static Encoder *
-lame_encoder_init(const struct config_param *param, GError **error_r)
+lame_encoder_init(const config_param &param, GError **error_r)
{
LameEncoder *encoder = new LameEncoder();
diff --git a/src/encoder/NullEncoderPlugin.cxx b/src/encoder/NullEncoderPlugin.cxx
index 206d55c2f..5c01fbd98 100644
--- a/src/encoder/NullEncoderPlugin.cxx
+++ b/src/encoder/NullEncoderPlugin.cxx
@@ -40,7 +40,7 @@ struct NullEncoder final {
};
static Encoder *
-null_encoder_init(gcc_unused const struct config_param *param,
+null_encoder_init(gcc_unused const config_param &param,
gcc_unused GError **error)
{
NullEncoder *encoder = new NullEncoder();
diff --git a/src/encoder/OpusEncoderPlugin.cxx b/src/encoder/OpusEncoderPlugin.cxx
index a6f36f7d5..d67cf1862 100644
--- a/src/encoder/OpusEncoderPlugin.cxx
+++ b/src/encoder/OpusEncoderPlugin.cxx
@@ -75,9 +75,9 @@ opus_encoder_quark(void)
static bool
opus_encoder_configure(struct opus_encoder *encoder,
- const struct config_param *param, GError **error_r)
+ const config_param &param, GError **error_r)
{
- const char *value = config_get_block_string(param, "bitrate", "auto");
+ const char *value = param.GetBlockValue("bitrate", "auto");
if (strcmp(value, "auto") == 0)
encoder->bitrate = OPUS_AUTO;
else if (strcmp(value, "max") == 0)
@@ -93,15 +93,14 @@ opus_encoder_configure(struct opus_encoder *encoder,
}
}
- encoder->complexity = config_get_block_unsigned(param, "complexity",
- 10);
+ encoder->complexity = param.GetBlockValue("complexity", 10u);
if (encoder->complexity > 10) {
g_set_error(error_r, opus_encoder_quark(), 0,
"Invalid complexity");
return false;
}
- value = config_get_block_string(param, "signal", "auto");
+ value = param.GetBlockValue("signal", "auto");
if (strcmp(value, "auto") == 0)
encoder->signal = OPUS_AUTO;
else if (strcmp(value, "voice") == 0)
@@ -118,7 +117,7 @@ opus_encoder_configure(struct opus_encoder *encoder,
}
static Encoder *
-opus_encoder_init(const struct config_param *param, GError **error)
+opus_encoder_init(const config_param &param, GError **error)
{
opus_encoder *encoder = new opus_encoder();
diff --git a/src/encoder/TwolameEncoderPlugin.cxx b/src/encoder/TwolameEncoderPlugin.cxx
index 4e2d47b63..cd85e43b6 100644
--- a/src/encoder/TwolameEncoderPlugin.cxx
+++ b/src/encoder/TwolameEncoderPlugin.cxx
@@ -48,7 +48,7 @@ struct TwolameEncoder final {
TwolameEncoder():encoder(twolame_encoder_plugin) {}
- bool Configure(const config_param *param, GError **error);
+ bool Configure(const config_param &param, GError **error);
};
static inline GQuark
@@ -58,12 +58,12 @@ twolame_encoder_quark(void)
}
bool
-TwolameEncoder::Configure(const config_param *param, GError **error)
+TwolameEncoder::Configure(const config_param &param, GError **error)
{
const char *value;
char *endptr;
- value = config_get_block_string(param, "quality", nullptr);
+ value = param.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -73,26 +73,26 @@ TwolameEncoder::Configure(const config_param *param, GError **error)
g_set_error(error, twolame_encoder_quark(), 0,
"quality \"%s\" is not a number in the "
"range -1 to 10, line %i",
- value, param->line);
+ value, param.line);
return false;
}
- if (config_get_block_string(param, "bitrate", nullptr) != nullptr) {
+ if (param.GetBlockValue("bitrate") != nullptr) {
g_set_error(error, twolame_encoder_quark(), 0,
"quality and bitrate are "
"both defined (line %i)",
- param->line);
+ param.line);
return false;
}
} else {
/* a bit rate was configured */
- value = config_get_block_string(param, "bitrate", nullptr);
+ value = param.GetBlockValue("bitrate");
if (value == nullptr) {
g_set_error(error, twolame_encoder_quark(), 0,
"neither bitrate nor quality defined "
"at line %i",
- param->line);
+ param.line);
return false;
}
@@ -102,7 +102,7 @@ TwolameEncoder::Configure(const config_param *param, GError **error)
if (*endptr != '\0' || bitrate <= 0) {
g_set_error(error, twolame_encoder_quark(), 0,
"bitrate at line %i should be a positive integer",
- param->line);
+ param.line);
return false;
}
}
@@ -111,7 +111,7 @@ TwolameEncoder::Configure(const config_param *param, GError **error)
}
static Encoder *
-twolame_encoder_init(const struct config_param *param, GError **error_r)
+twolame_encoder_init(const config_param &param, GError **error_r)
{
g_debug("libtwolame version %s", get_twolame_version());
diff --git a/src/encoder/VorbisEncoderPlugin.cxx b/src/encoder/VorbisEncoderPlugin.cxx
index bc43ffa43..9d0ba9461 100644
--- a/src/encoder/VorbisEncoderPlugin.cxx
+++ b/src/encoder/VorbisEncoderPlugin.cxx
@@ -62,9 +62,9 @@ vorbis_encoder_quark(void)
static bool
vorbis_encoder_configure(struct vorbis_encoder *encoder,
- const struct config_param *param, GError **error)
+ const config_param &param, GError **error)
{
- const char *value = config_get_block_string(param, "quality", nullptr);
+ const char *value = param.GetBlockValue("quality");
if (value != nullptr) {
/* a quality was configured (VBR) */
@@ -76,26 +76,26 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
g_set_error(error, vorbis_encoder_quark(), 0,
"quality \"%s\" is not a number in the "
"range -1 to 10, line %i",
- value, param->line);
+ value, param.line);
return false;
}
- if (config_get_block_string(param, "bitrate", nullptr) != nullptr) {
+ if (param.GetBlockValue("bitrate") != nullptr) {
g_set_error(error, vorbis_encoder_quark(), 0,
"quality and bitrate are "
"both defined (line %i)",
- param->line);
+ param.line);
return false;
}
} else {
/* a bit rate was configured */
- value = config_get_block_string(param, "bitrate", nullptr);
+ value = param.GetBlockValue("bitrate");
if (value == nullptr) {
g_set_error(error, vorbis_encoder_quark(), 0,
"neither bitrate nor quality defined "
"at line %i",
- param->line);
+ param.line);
return false;
}
@@ -106,7 +106,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
if (*endptr != '\0' || encoder->bitrate <= 0) {
g_set_error(error, vorbis_encoder_quark(), 0,
"bitrate at line %i should be a positive integer",
- param->line);
+ param.line);
return false;
}
}
@@ -115,7 +115,7 @@ vorbis_encoder_configure(struct vorbis_encoder *encoder,
}
static Encoder *
-vorbis_encoder_init(const struct config_param *param, GError **error)
+vorbis_encoder_init(const config_param &param, GError **error)
{
vorbis_encoder *encoder = new vorbis_encoder();
diff --git a/src/encoder/WaveEncoderPlugin.cxx b/src/encoder/WaveEncoderPlugin.cxx
index cc94247cb..17560dfea 100644
--- a/src/encoder/WaveEncoderPlugin.cxx
+++ b/src/encoder/WaveEncoderPlugin.cxx
@@ -83,7 +83,7 @@ fill_wave_header(struct wave_header *header, int channels, int bits,
}
static Encoder *
-wave_encoder_init(gcc_unused const struct config_param *param,
+wave_encoder_init(gcc_unused const config_param &param,
gcc_unused GError **error)
{
WaveEncoder *encoder = new WaveEncoder();