mpegtsdemux: Close a buffer leak and simplify input_done

tsparse leaked input buffers quite badly:

    GST_TRACERS=leaks GST_DEBUG=GST_TRACER:9 gst-launch-1.0 audiotestsrc num-buffers=3 ! avenc_aac ! mpegtsmux ! tsparse ! fakesink

The input_done vfunc was passed the input buffer, which it had to
consume. For this reason, the base class takes a reference on the buffer
if and only if input_done is not NULL.

Before 34af8ed66a, input_done was used in
tsparse to pass on the input buffer on the "src" pad. That commit
changed the code to packetize for that pad as well and removed the use
of input_done.

Afterwards, 0d2e908523 set input_done
again in order to handle automatic alignment of the output buffers to
the input buffers. However, it ignored the provided buffer and did not
even unref it, causing a leak.

Since no code makes use of the buffer provided with input_done, just
remove the argument in order to simplify things a bit.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1274>
This commit is contained in:
Jan Alexander Steffens (heftig) 2020-05-15 17:05:59 +02:00 committed by GStreamer Merge Bot
parent bf004227ec
commit 9b2ed3a3fc
3 changed files with 7 additions and 15 deletions

View file

@ -1431,9 +1431,6 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
packetizer = base->packetizer;
if (klass->input_done)
gst_buffer_ref (buf);
if (GST_BUFFER_IS_DISCONT (buf)) {
GST_DEBUG_OBJECT (base, "Got DISCONT buffer, flushing");
res = mpegts_base_drain (base);
@ -1501,12 +1498,8 @@ mpegts_base_chain (GstPad * pad, GstObject * parent, GstBuffer * buf)
mpegts_packetizer_clear_packet (base->packetizer, &packet);
}
if (klass->input_done) {
if (res == GST_FLOW_OK)
res = klass->input_done (base, buf);
else
gst_buffer_unref (buf);
}
if (res == GST_FLOW_OK && klass->input_done)
res = klass->input_done (base);
return res;
}

View file

@ -210,7 +210,7 @@ struct _MpegTSBaseClass {
void (*flush) (MpegTSBase * base, gboolean hard);
/* Notifies subclasses input buffer has been handled */
GstFlowReturn (*input_done) (MpegTSBase *base, GstBuffer *buffer);
GstFlowReturn (*input_done) (MpegTSBase *base);
/* signals */
void (*pat_info) (GstStructure *pat);

View file

@ -1,7 +1,7 @@
/*
* mpegtsparse.c -
* mpegtsparse.c -
* Copyright (C) 2007 Alessandro Decina
*
*
* Authors:
* Alessandro Decina <alessandro@nnva.org>
* Zaheer Abbas Merali <zaheerabbas at merali dot org>
@ -126,8 +126,7 @@ static gboolean push_event (MpegTSBase * base, GstEvent * event);
#define mpegts_parse_parent_class parent_class
G_DEFINE_TYPE (MpegTSParse2, mpegts_parse, GST_TYPE_MPEGTS_BASE);
static void mpegts_parse_reset (MpegTSBase * base);
static GstFlowReturn mpegts_parse_input_done (MpegTSBase * base,
GstBuffer * buffer);
static GstFlowReturn mpegts_parse_input_done (MpegTSBase * base);
static GstFlowReturn
drain_pending_buffers (MpegTSParse2 * parse, gboolean drain_all);
@ -1088,7 +1087,7 @@ empty_pad (GstPad * pad, MpegTSParse2 * parse)
}
static GstFlowReturn
mpegts_parse_input_done (MpegTSBase * base, GstBuffer * buffer)
mpegts_parse_input_done (MpegTSBase * base)
{
MpegTSParse2 *parse = GST_MPEGTS_PARSE (base);
GstFlowReturn ret = GST_FLOW_OK;