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.
This commit is contained in:
wm4 2013-03-29 22:29:13 +01:00
parent abd5e8a2e7
commit ff6342a311
2 changed files with 11 additions and 1 deletions

View File

@ -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

View File

@ -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;