From ff6342a3112e194c228660516cc19dd1ce4de6d9 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 29 Mar 2013 22:29:13 +0100 Subject: [PATCH] af_lavrresample: add no-detach suboption Normally, af_lavrresample detaches itself immediately if the input and output audio parameters are the same. no-detach prevents this. --- DOCS/man/en/af.rst | 5 +++++ audio/filter/af_lavrresample.c | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/DOCS/man/en/af.rst b/DOCS/man/en/af.rst index f3054e7255..7babf874d4 100644 --- a/DOCS/man/en/af.rst +++ b/DOCS/man/en/af.rst @@ -50,6 +50,11 @@ lavrresample[=option1:option2:...] linear if set then filters will be linearly interpolated between polyphase entries (default: no) + no-detach + don't detach if input and output audio format/rate/channels are the + same. You should add this option if you specify additional parameters, + as automatically inserted lavrresample instances will use the + default settings. lavcac3enc[=tospdif[:bitrate[:minchn]]] Encode multi-channel audio to AC-3 at runtime using libavcodec. Supports diff --git a/audio/filter/af_lavrresample.c b/audio/filter/af_lavrresample.c index 1d3b7639bd..2dd2c613c7 100644 --- a/audio/filter/af_lavrresample.c +++ b/audio/filter/af_lavrresample.c @@ -67,6 +67,7 @@ struct af_resample_opts { }; struct af_resample { + int allow_detach; struct AVAudioResampleContext *avrctx; struct af_resample_opts ctx; // opts in the context struct af_resample_opts opts; // opts requested by the user @@ -128,7 +129,8 @@ static int control(struct af_instance *af, int cmd, void *arg) if (((out->rate == in->rate) || (out->rate == 0)) && (out->format == in->format) && (out->bps == in->bps) && - ((out->nch == in->nch) || out->nch == 0)) + ((out->nch == in->nch) || out->nch == 0) && + s->allow_detach) return AF_DETACH; if (out->rate == 0) @@ -224,6 +226,7 @@ static int control(struct af_instance *af, int cmd, void *arg) {"phase_shift", OPT_ARG_INT, &s->opts.phase_shift, NULL}, {"linear", OPT_ARG_BOOL, &s->opts.linear, NULL}, {"cutoff", OPT_ARG_FLOAT, &s->opts.cutoff, NULL}, + {"detach", OPT_ARG_BOOL, &s->allow_detach, NULL}, {0} }; @@ -307,6 +310,8 @@ static int af_open(struct af_instance *af) .phase_shift = 10, }; + s->allow_detach = 1; + s->avrctx = avresample_alloc_context(); af->setup = s;