diff options
author | Anton Khirnov <anton@khirnov.net> | 2012-07-02 22:13:40 +0400 |
---|---|---|
committer | Anton Khirnov <anton@khirnov.net> | 2012-07-09 10:25:19 +0400 |
commit | cd99146253cf9de5dad5694b97027d5612fdc61d (patch) | |
tree | 0b53395aa59459574c2e5fa1c277b4267e01c4a0 /libavfilter/af_amix.c | |
parent | 8d18bc550e7dfc62bc872507a02ae2d7827882d6 (diff) |
lavfi: add error handling to filter_samples().
Diffstat (limited to 'libavfilter/af_amix.c')
-rw-r--r-- | libavfilter/af_amix.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/libavfilter/af_amix.c b/libavfilter/af_amix.c index 439231fbd1..d79a626d0a 100644 --- a/libavfilter/af_amix.c +++ b/libavfilter/af_amix.c @@ -311,9 +311,7 @@ static int output_frame(AVFilterLink *outlink, int nb_samples) if (s->next_pts != AV_NOPTS_VALUE) s->next_pts += nb_samples; - ff_filter_samples(outlink, out_buf); - - return 0; + return ff_filter_samples(outlink, out_buf); } /** @@ -454,31 +452,37 @@ static int request_frame(AVFilterLink *outlink) return output_frame(outlink, available_samples); } -static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) +static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf) { AVFilterContext *ctx = inlink->dst; MixContext *s = ctx->priv; AVFilterLink *outlink = ctx->outputs[0]; - int i; + int i, ret = 0; for (i = 0; i < ctx->nb_inputs; i++) if (ctx->inputs[i] == inlink) break; if (i >= ctx->nb_inputs) { av_log(ctx, AV_LOG_ERROR, "unknown input link\n"); - return; + ret = AVERROR(EINVAL); + goto fail; } if (i == 0) { int64_t pts = av_rescale_q(buf->pts, inlink->time_base, outlink->time_base); - frame_list_add_frame(s->frame_list, buf->audio->nb_samples, pts); + ret = frame_list_add_frame(s->frame_list, buf->audio->nb_samples, pts); + if (ret < 0) + goto fail; } - av_audio_fifo_write(s->fifos[i], (void **)buf->extended_data, - buf->audio->nb_samples); + ret = av_audio_fifo_write(s->fifos[i], (void **)buf->extended_data, + buf->audio->nb_samples); +fail: avfilter_unref_buffer(buf); + + return ret; } static int init(AVFilterContext *ctx, const char *args) |