summaryrefslogtreecommitdiffstats
path: root/player/lavfi.c
diff options
context:
space:
mode:
Diffstat (limited to 'player/lavfi.c')
-rw-r--r--player/lavfi.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/player/lavfi.c b/player/lavfi.c
index 50c2fd8fc2..2a41aa8a96 100644
--- a/player/lavfi.c
+++ b/player/lavfi.c
@@ -43,6 +43,11 @@
#include "lavfi.h"
+#if LIBAVFILTER_VERSION_MICRO < 100
+#define av_buffersink_get_frame_flags(a, b, c) av_buffersink_get_frame(a, b)
+#define AV_BUFFERSINK_FLAG_NO_REQUEST 0
+#endif
+
struct lavfi {
struct mp_log *log;
char *graph_string;
@@ -266,6 +271,10 @@ enum stream_type lavfi_pad_type(struct lavfi_pad *pad)
void lavfi_set_connected(struct lavfi_pad *pad, bool connected)
{
pad->connected = connected;
+ if (!pad->connected) {
+ pad->output_needed = false;
+ drop_pad_data(pad);
+ }
}
bool lavfi_get_connected(struct lavfi_pad *pad)
@@ -545,19 +554,17 @@ static void read_output_pads(struct lavfi *c)
if (pad->dir != LAVFI_OUT)
continue;
- // If disconnected, read and discard everything.
- if (!pad->pending_v && !pad->pending_a && !pad->connected)
- pad->output_needed = true;
-
- if (!pad->output_needed)
+ // If disconnected, read and discard everything (passively).
+ if (pad->connected && !pad->output_needed)
continue;
assert(pad->buffer);
assert(!pad->pending_v && !pad->pending_a);
+ int flags = pad->output_needed ? 0 : AV_BUFFERSINK_FLAG_NO_REQUEST;
int r = AVERROR_EOF;
if (!pad->buffer_is_eof)
- r = av_buffersink_get_frame(pad->buffer, pad->tmp_frame);
+ r = av_buffersink_get_frame_flags(pad->buffer, pad->tmp_frame, flags);
if (r >= 0) {
pad->output_needed = false;
double pts = mp_pts_from_av(pad->tmp_frame->pts, &pad->timebase);
@@ -583,6 +590,7 @@ static void read_output_pads(struct lavfi *c)
// input pads (via av_buffersrc_get_nb_failed_requests()).
pad->output_eof = false;
} else if (r == AVERROR_EOF) {
+ pad->output_needed = false;
pad->buffer_is_eof = true;
if (!c->draining_recover_eof && !c->draining_new_format)
pad->output_eof = true;
@@ -611,7 +619,7 @@ bool lavfi_process(struct lavfi *c)
bool all_waiting = true;
bool any_needs_input = false;
bool any_needs_output = false;
- bool all_lavfi_eof = true;
+ bool all_output_eof = true;
bool all_input_eof = true;
// Determine the graph state
@@ -623,12 +631,12 @@ bool lavfi_process(struct lavfi *c)
any_needs_input |= pad->input_needed;
all_input_eof &= pad->input_eof;
} else if (pad->dir == LAVFI_OUT) {
- all_lavfi_eof &= pad->buffer_is_eof;
+ all_output_eof &= pad->buffer_is_eof;
any_needs_output |= pad->output_needed;
}
}
- if (all_lavfi_eof && !all_input_eof) {
+ if (all_output_eof && !all_input_eof) {
free_graph(c);
precreate_graph(c);
all_waiting = false;