From fbffce6d0da0a487ca6909ff5edede70deca11bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Wed, 7 Dec 2022 10:21:52 +0200 Subject: [PATCH] dvbsubenc: Forward GAP events as-is if we wouldn't produce an end packet and are not in the middle of an existing subtitle An end packet is only produced once for the last subtitle, so multiple GAP events between subtitles would result only in a single end packet and nothing else otherwise. This would potentially starve downstream then, so instead forward the GAP events in that case. Part-of: --- .../gst/dvbsubenc/gstdvbsubenc.c | 37 +++++++++++-------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/subprojects/gst-plugins-bad/gst/dvbsubenc/gstdvbsubenc.c b/subprojects/gst-plugins-bad/gst/dvbsubenc/gstdvbsubenc.c index ad316f78bc..5a7ea4c24a 100644 --- a/subprojects/gst-plugins-bad/gst/dvbsubenc/gstdvbsubenc.c +++ b/subprojects/gst-plugins-bad/gst/dvbsubenc/gstdvbsubenc.c @@ -560,24 +560,29 @@ gst_dvb_sub_enc_sink_event (GstPad * pad, GstObject * parent, GstEvent * event) } case GST_EVENT_GAP: { - GstClockTime start, duration; - - gst_event_parse_gap (event, &start, &duration); - if (GST_CLOCK_TIME_IS_VALID (start)) { - if (GST_CLOCK_TIME_IS_VALID (duration)) - start += duration; - /* we do not expect another buffer until after gap, - * so that is our position now */ - GST_DEBUG_OBJECT (enc, - "Got GAP event, advancing time to %" GST_TIME_FORMAT, - GST_TIME_ARGS (start)); - gst_dvb_sub_enc_generate_end_packet (enc, start); + if (!GST_CLOCK_TIME_IS_VALID (enc->current_end_time)) { + ret = gst_pad_event_default (pad, parent, event); } else { - GST_WARNING_OBJECT (enc, "Got GAP event with invalid position"); - } + GstClockTime start, duration; - gst_event_unref (event); - ret = TRUE; + gst_event_parse_gap (event, &start, &duration); + + if (GST_CLOCK_TIME_IS_VALID (start)) { + if (GST_CLOCK_TIME_IS_VALID (duration)) + start += duration; + /* we do not expect another buffer until after gap, + * so that is our position now */ + GST_DEBUG_OBJECT (enc, + "Got GAP event, advancing time to %" GST_TIME_FORMAT, + GST_TIME_ARGS (start)); + gst_dvb_sub_enc_generate_end_packet (enc, start); + } else { + GST_WARNING_OBJECT (enc, "Got GAP event with invalid position"); + } + + gst_event_unref (event); + ret = TRUE; + } break; } case GST_EVENT_SEGMENT: