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