Allow to set the EOF timestamp.
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -32,6 +32,7 @@ · 31 unmodified lines | ||
| 32 | 32 | #include "libavutil/opt.h" |
| 33 | 33 | #include "audio.h" |
| 34 | 34 | #include "avfilter.h" |
| 35 | +#include "filters.h" | |
| 35 | 36 | #include "internal.h" |
| 36 | 37 | |
| 37 | 38 | typedef struct ANullContext { |
| @@ -105,28 +106,35 @@ static int config_props(AVFilterLink *outlink) · 67 unmodified lines | ||
| 105 | 106 | return 0; |
| 106 | 107 | } |
| 107 | 108 | |
| 108 | −static int request_frame(AVFilterLink *outlink) | |
| 109 | +static int activate(AVFilterContext *ctx) | |
| 109 | 110 | { |
| 110 | − int ret; | |
| 111 | − ANullContext *null = outlink->src->priv; | |
| 112 | − AVFrame *samplesref; | |
| 111 | + ANullContext *null = ctx->priv; | |
| 112 | + AVFilterLink *outlink = ctx->outputs[0]; | |
| 113 | 113 | |
| 114 | 114 | if (null->duration >= 0 && |
| 115 | − av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration) | |
| 116 | − return AVERROR_EOF; | |
| 115 | + av_rescale_q(null->pts, outlink->time_base, AV_TIME_BASE_Q) >= null->duration) { | |
| 116 | + ff_outlink_set_status(outlink, AVERROR_EOF, null->pts); | |
| 117 | + return 0; | |
| 118 | + } | |
| 117 | 119 | |
| 118 | − samplesref = ff_get_audio_buffer(outlink, null->nb_samples); | |
| 119 | − if (!samplesref) | |
| 120 | − return AVERROR(ENOMEM); | |
| 120 | + if (ff_outlink_frame_wanted(outlink)) { | |
| 121 | + AVFrame *samplesref = ff_get_audio_buffer(outlink, null->nb_samples); | |
| 122 | + int ret; | |
| 121 | 123 | |
| 122 | − samplesref->pts = null->pts; | |
| 124 | + if (!samplesref) | |
| 125 | + return AVERROR(ENOMEM); | |
| 123 | 126 | |
| 124 | − ret = ff_filter_frame(outlink, samplesref); | |
| 125 | − if (ret < 0) | |
| 126 | − return ret; | |
| 127 | + samplesref->pts = null->pts; | |
| 128 | + | |
| 129 | + ret = ff_filter_frame(outlink, samplesref); | |
| 130 | + if (ret < 0) | |
| 131 | + return ret; | |
| 132 | + | |
| 133 | + null->pts += null->nb_samples; | |
| 134 | + return 0; | |
| 135 | + } | |
| 127 | 136 | |
| 128 | − null->pts += null->nb_samples; | |
| 129 | − return ret; | |
| 137 | + return FFERROR_NOT_READY; | |
| 130 | 138 | } |
| 131 | 139 | |
| 132 | 140 | static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { |
| @@ -134,7 +142,6 @@ static const AVFilterPad avfilter_asrc_anullsrc_outputs[] = { · 1 unmodified line | ||
| 134 | 142 | .name = "default", |
| 135 | 143 | .type = AVMEDIA_TYPE_AUDIO, |
| 136 | 144 | .config_props = config_props, |
| 137 | − .request_frame = request_frame, | |
| 138 | 145 | }, |
| 139 | 146 | { NULL } |
| 140 | 147 | }; |
| @@ -147,5 +154,6 @@ AVFilter ff_asrc_anullsrc = { · 6 unmodified lines | ||
| 147 | 154 | .priv_size = sizeof(ANullContext), |
| 148 | 155 | .inputs = NULL, |
| 149 | 156 | .outputs = avfilter_asrc_anullsrc_outputs, |
| 157 | + .activate = activate, | |
| 150 | 158 | .priv_class = &anullsrc_class, |
| 151 | 159 | }; |