summaryrefslogtreecommitdiffstats
path: root/audio/filter
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-12-04 21:16:32 +0100
committerwm4 <wm4@nowhere>2013-12-04 23:12:52 +0100
commitad8e3d8c302bd686e811380fe8e47a08a939128c (patch)
treed16f8b14ae9d699d4bbdec48b3895a2f29bdcaf4 /audio/filter
parentd74419e6f09f46db2ff3fa422f3aef189bfd4254 (diff)
downloadmpv-ad8e3d8c302bd686e811380fe8e47a08a939128c.tar.bz2
mpv-ad8e3d8c302bd686e811380fe8e47a08a939128c.tar.xz
af_sweep: use option parser
Diffstat (limited to 'audio/filter')
-rw-r--r--audio/filter/af_sweep.c23
1 files changed, 7 insertions, 16 deletions
diff --git a/audio/filter/af_sweep.c b/audio/filter/af_sweep.c
index a06cad7600..93e259d4a1 100644
--- a/audio/filter/af_sweep.c
+++ b/audio/filter/af_sweep.c
@@ -36,7 +36,6 @@ typedef struct af_sweep_s{
// Initialization and runtime control
static int control(struct af_instance* af, int cmd, void* arg)
{
- af_sweept* s = (af_sweept*)af->setup;
struct mp_audio *data= (struct mp_audio*)arg;
switch(cmd){
@@ -45,26 +44,14 @@ static int control(struct af_instance* af, int cmd, void* arg)
mp_audio_set_format(af->data, AF_FORMAT_S16);
return af_test_output(af, data);
- case AF_CONTROL_COMMAND_LINE:
- sscanf((char*)arg,"%lf", &s->delta);
- return AF_OK;
-/* case AF_CONTROL_RESAMPLE_RATE | AF_CONTROL_SET:
- af->data->rate = *(int*)arg;
- return AF_OK;*/
}
return AF_UNKNOWN;
}
-// Deallocate memory
-static void uninit(struct af_instance* af)
-{
- free(af->setup);
-}
-
// Filter data through filter
static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
{
- af_sweept *s = af->setup;
+ af_sweept *s = af->priv;
int i, j;
int16_t *in = (int16_t*)data->planes[0];
int chans = data->nch;
@@ -82,14 +69,18 @@ static struct mp_audio* play(struct af_instance* af, struct mp_audio* data)
static int af_open(struct af_instance* af){
af->control=control;
- af->uninit=uninit;
af->play=play;
- af->setup=calloc(1,sizeof(af_sweept));
return AF_OK;
}
+#define OPT_BASE_STRUCT af_sweept
struct af_info af_info_sweep = {
.info = "sine sweep",
.name = "sweep",
.open = af_open,
+ .priv_size = sizeof(af_sweept),
+ .options = (const struct m_option[]) {
+ OPT_DOUBLE("delta", delta, 0),
+ {0}
+ },
};