aboutsummaryrefslogtreecommitdiffstats
path: root/libavfilter/af_asyncts.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2012-07-02 20:13:40 +0200
committerAnton Khirnov <anton@khirnov.net>2012-07-09 08:25:19 +0200
commitcd99146253cf9de5dad5694b97027d5612fdc61d (patch)
tree0b53395aa59459574c2e5fa1c277b4267e01c4a0 /libavfilter/af_asyncts.c
parent8d18bc550e7dfc62bc872507a02ae2d7827882d6 (diff)
downloadffmpeg-cd99146253cf9de5dad5694b97027d5612fdc61d.tar.gz
lavfi: add error handling to filter_samples().
Diffstat (limited to 'libavfilter/af_asyncts.c')
-rw-r--r--libavfilter/af_asyncts.c38
1 files changed, 22 insertions, 16 deletions
diff --git a/libavfilter/af_asyncts.c b/libavfilter/af_asyncts.c
index 097bc6045f..4052fbdce7 100644
--- a/libavfilter/af_asyncts.c
+++ b/libavfilter/af_asyncts.c
@@ -136,18 +136,18 @@ static int request_frame(AVFilterLink *link)
avresample_convert(s->avr, (void**)buf->extended_data, buf->linesize[0],
nb_samples, NULL, 0, 0);
buf->pts = s->pts;
- ff_filter_samples(link, buf);
- return 0;
+ return ff_filter_samples(link, buf);
}
return ret;
}
-static void write_to_fifo(ASyncContext *s, AVFilterBufferRef *buf)
+static int write_to_fifo(ASyncContext *s, AVFilterBufferRef *buf)
{
- avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data,
- buf->linesize[0], buf->audio->nb_samples);
+ int ret = avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data,
+ buf->linesize[0], buf->audio->nb_samples);
avfilter_unref_buffer(buf);
+ return ret;
}
/* get amount of data currently buffered, in samples */
@@ -156,7 +156,7 @@ static int64_t get_delay(ASyncContext *s)
return avresample_available(s->avr) + avresample_get_delay(s->avr);
}
-static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
+static int filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
{
AVFilterContext *ctx = inlink->dst;
ASyncContext *s = ctx->priv;
@@ -164,7 +164,7 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
int nb_channels = av_get_channel_layout_nb_channels(buf->audio->channel_layout);
int64_t pts = (buf->pts == AV_NOPTS_VALUE) ? buf->pts :
av_rescale_q(buf->pts, inlink->time_base, outlink->time_base);
- int out_size;
+ int out_size, ret;
int64_t delta;
/* buffer data until we get the first timestamp */
@@ -172,14 +172,12 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
if (pts != AV_NOPTS_VALUE) {
s->pts = pts - get_delay(s);
}
- write_to_fifo(s, buf);
- return;
+ return write_to_fifo(s, buf);
}
/* now wait for the next timestamp */
if (pts == AV_NOPTS_VALUE) {
- write_to_fifo(s, buf);
- return;
+ return write_to_fifo(s, buf);
}
/* when we have two timestamps, compute how many samples would we have
@@ -202,8 +200,10 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
if (out_size > 0) {
AVFilterBufferRef *buf_out = ff_get_audio_buffer(outlink, AV_PERM_WRITE,
out_size);
- if (!buf_out)
- return;
+ if (!buf_out) {
+ ret = AVERROR(ENOMEM);
+ goto fail;
+ }
avresample_read(s->avr, (void**)buf_out->extended_data, out_size);
buf_out->pts = s->pts;
@@ -212,7 +212,9 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
av_samples_set_silence(buf_out->extended_data, out_size - delta,
delta, nb_channels, buf->format);
}
- ff_filter_samples(outlink, buf_out);
+ ret = ff_filter_samples(outlink, buf_out);
+ if (ret < 0)
+ goto fail;
s->got_output = 1;
} else {
av_log(ctx, AV_LOG_WARNING, "Non-monotonous timestamps, dropping "
@@ -223,9 +225,13 @@ static void filter_samples(AVFilterLink *inlink, AVFilterBufferRef *buf)
avresample_read(s->avr, NULL, avresample_available(s->avr));
s->pts = pts - avresample_get_delay(s->avr);
- avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data,
- buf->linesize[0], buf->audio->nb_samples);
+ ret = avresample_convert(s->avr, NULL, 0, 0, (void**)buf->extended_data,
+ buf->linesize[0], buf->audio->nb_samples);
+
+fail:
avfilter_unref_buffer(buf);
+
+ return ret;
}
AVFilter avfilter_af_asyncts = {