summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-07-22 14:45:12 +0200
committerwm4 <wm4@nowhere>2013-07-22 15:11:04 +0200
commit1189f64dd1c9edabeee92af00aa694cc4e662315 (patch)
treea49b663f8ad14a2fb354e27722d46ed159f5035a
parent3b8dfddb4cb6e9431da659b10c5b31a9f17c81b5 (diff)
downloadmpv-1189f64dd1c9edabeee92af00aa694cc4e662315.tar.bz2
mpv-1189f64dd1c9edabeee92af00aa694cc4e662315.tar.xz
af_force: use new option API
-rw-r--r--audio/filter/af_force.c55
1 files changed, 21 insertions, 34 deletions
diff --git a/audio/filter/af_force.c b/audio/filter/af_force.c
index 765a77750f..75424167b9 100644
--- a/audio/filter/af_force.c
+++ b/audio/filter/af_force.c
@@ -19,7 +19,6 @@
#include <libavutil/common.h>
-#include "core/m_config.h"
#include "core/m_option.h"
#include "audio/format.h"
@@ -41,27 +40,9 @@ struct priv {
struct mp_audio temp;
};
-static const struct priv defaults = {
- .in_format = AF_FORMAT_UNKNOWN,
- .out_format = AF_FORMAT_UNKNOWN,
-};
-
-#define OPT_BASE_STRUCT struct priv
-
-static const struct m_option options[] = {
- OPT_AUDIOFORMAT("format", in_format, 0),
- OPT_INTRANGE("srate", in_srate, 0, 1000, 8*48000),
- OPT_CHMAP("channels", in_channels, CONF_MIN, .min = 0),
- OPT_AUDIOFORMAT("out-format", out_format, 0),
- OPT_INTRANGE("out-srate", out_srate, 0, 1000, 8*48000),
- OPT_CHMAP("out-channels", out_channels, CONF_MIN, .min = 0),
- OPT_FLAG("fail", fail, 0),
- {0}
-};
-
static int control(struct af_instance *af, int cmd, void *arg)
{
- struct priv *priv = af->setup;
+ struct priv *priv = af->priv;
switch (cmd) {
case AF_CONTROL_REINIT: {
@@ -102,18 +83,13 @@ static int control(struct af_instance *af, int cmd, void *arg)
return mp_audio_config_equals(in, &orig_in) ? AF_OK : AF_FALSE;
}
- case AF_CONTROL_COMMAND_LINE: {
- if (m_config_parse_suboptions(priv->config, "af_force", (char *)arg) < 0)
- return AF_ERROR;
- return AF_OK;
- }
}
return AF_UNKNOWN;
}
static struct mp_audio *play(struct af_instance *af, struct mp_audio *data)
{
- struct priv *priv = af->setup;
+ struct priv *priv = af->priv;
struct mp_audio *r = &priv->temp;
*r = *af->data;
@@ -125,7 +101,6 @@ static struct mp_audio *play(struct af_instance *af, struct mp_audio *data)
static void uninit(struct af_instance *af)
{
- talloc_free(af->setup);
}
static int af_open(struct af_instance *af)
@@ -134,21 +109,33 @@ static int af_open(struct af_instance *af)
af->uninit = uninit;
af->play = play;
af->mul = 1;
- struct priv *priv = talloc(NULL, struct priv);
- af->setup = priv;
- *priv = defaults;
- priv->config = m_config_simple(priv);
- talloc_steal(priv, priv->config);
- m_config_register_options(priv->config, options);
+ struct priv *priv = af->priv;
af->data = &priv->data;
return AF_OK;
}
+#define OPT_BASE_STRUCT struct priv
+
struct af_info af_info_force = {
"Force audio format",
"force",
"",
"",
0,
- af_open
+ af_open,
+ .priv_size = sizeof(struct priv),
+ .priv_defaults = &(const struct priv) {
+ .in_format = AF_FORMAT_UNKNOWN,
+ .out_format = AF_FORMAT_UNKNOWN,
+ },
+ .options = (const struct m_option[]) {
+ OPT_AUDIOFORMAT("format", in_format, 0),
+ OPT_INTRANGE("srate", in_srate, 0, 1000, 8*48000),
+ OPT_CHMAP("channels", in_channels, CONF_MIN, .min = 0),
+ OPT_AUDIOFORMAT("out-format", out_format, 0),
+ OPT_INTRANGE("out-srate", out_srate, 0, 1000, 8*48000),
+ OPT_CHMAP("out-channels", out_channels, CONF_MIN, .min = 0),
+ OPT_FLAG("fail", fail, 0),
+ {0}
+ },
};