sink_buffer: make opaque argument optional.
This commit is contained in:
parent
a2bd8a9384
commit
784675ca91
@ -231,24 +231,25 @@ static void filter_samples(AVFilterLink *link, AVFilterBufferRef *samplesref)
|
|||||||
static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaque)
|
static av_cold int asink_init(AVFilterContext *ctx, const char *args, void *opaque)
|
||||||
{
|
{
|
||||||
BufferSinkContext *buf = ctx->priv;
|
BufferSinkContext *buf = ctx->priv;
|
||||||
AVABufferSinkParams *params;
|
AVABufferSinkParams *params = opaque;
|
||||||
|
|
||||||
if (!opaque) {
|
if (params && params->sample_fmts) {
|
||||||
av_log(ctx, AV_LOG_ERROR,
|
buf->sample_fmts = ff_copy_int_list (params->sample_fmts);
|
||||||
"No opaque field provided, an AVABufferSinkParams struct is required\n");
|
if (!buf->sample_fmts)
|
||||||
return AVERROR(EINVAL);
|
goto fail_enomem;
|
||||||
} else
|
|
||||||
params = (AVABufferSinkParams *)opaque;
|
|
||||||
|
|
||||||
buf->sample_fmts = ff_copy_int_list (params->sample_fmts);
|
|
||||||
buf->channel_layouts = ff_copy_int64_list(params->channel_layouts);
|
|
||||||
if (!buf->sample_fmts || !buf->channel_layouts) {
|
|
||||||
av_freep(&buf->sample_fmts);
|
|
||||||
av_freep(&buf->channel_layouts);
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
}
|
}
|
||||||
|
if (params && params->channel_layouts) {
|
||||||
|
buf->channel_layouts = ff_copy_int64_list(params->channel_layouts);
|
||||||
|
if (!buf->channel_layouts)
|
||||||
|
goto fail_enomem;
|
||||||
|
}
|
||||||
|
if (!common_init(ctx))
|
||||||
|
return 0;
|
||||||
|
|
||||||
return common_init(ctx);
|
fail_enomem:
|
||||||
|
av_freep(&buf->sample_fmts);
|
||||||
|
av_freep(&buf->channel_layouts);
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
static av_cold void asink_uninit(AVFilterContext *ctx)
|
static av_cold void asink_uninit(AVFilterContext *ctx)
|
||||||
@ -266,14 +267,17 @@ static int asink_query_formats(AVFilterContext *ctx)
|
|||||||
AVFilterFormats *formats = NULL;
|
AVFilterFormats *formats = NULL;
|
||||||
AVFilterChannelLayouts *layouts = NULL;
|
AVFilterChannelLayouts *layouts = NULL;
|
||||||
|
|
||||||
|
if (buf->sample_fmts) {
|
||||||
if (!(formats = ff_make_format_list(buf->sample_fmts)))
|
if (!(formats = ff_make_format_list(buf->sample_fmts)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
ff_set_common_formats(ctx, formats);
|
ff_set_common_formats(ctx, formats);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (buf->channel_layouts) {
|
||||||
if (!(layouts = avfilter_make_format64_list(buf->channel_layouts)))
|
if (!(layouts = avfilter_make_format64_list(buf->channel_layouts)))
|
||||||
return AVERROR(ENOMEM);
|
return AVERROR(ENOMEM);
|
||||||
ff_set_common_channel_layouts(ctx, layouts);
|
ff_set_common_channel_layouts(ctx, layouts);
|
||||||
ff_set_common_samplerates (ctx, ff_all_samplerates());
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user