mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-06-05 15:08:53 +00:00
libs/gst/base/gstcollectpads.c: When flushing a pad, also clear the queued buffer so that we don't accidentally use i...
Original commit message from CVS: * libs/gst/base/gstcollectpads.c: (gst_collect_pads_set_flushing_unlocked), (gst_collect_pads_pop), (gst_collect_pads_clear), (gst_collect_pads_flush), (gst_collect_pads_event), (gst_collect_pads_chain): When flushing a pad, also clear the queued buffer so that we don't accidentally use it when we shouldn't. Fix leaks by inreffing incomming buffer. Flush out queued buffers in case of errors. Fixes #347452.
This commit is contained in:
parent
473b67a986
commit
6939f83e75
2 changed files with 48 additions and 21 deletions
12
ChangeLog
12
ChangeLog
|
@ -1,3 +1,15 @@
|
||||||
|
2006-07-28 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
|
* libs/gst/base/gstcollectpads.c:
|
||||||
|
(gst_collect_pads_set_flushing_unlocked), (gst_collect_pads_pop),
|
||||||
|
(gst_collect_pads_clear), (gst_collect_pads_flush),
|
||||||
|
(gst_collect_pads_event), (gst_collect_pads_chain):
|
||||||
|
When flushing a pad, also clear the queued buffer so that we don't
|
||||||
|
accidentally use it when we shouldn't.
|
||||||
|
Fix leaks by inreffing incomming buffer.
|
||||||
|
Flush out queued buffers in case of errors.
|
||||||
|
Fixes #347452.
|
||||||
|
|
||||||
2006-07-28 Wim Taymans <wim@fluendo.com>
|
2006-07-28 Wim Taymans <wim@fluendo.com>
|
||||||
|
|
||||||
* docs/random/phonon-gst:
|
* docs/random/phonon-gst:
|
||||||
|
|
|
@ -79,6 +79,8 @@ GST_DEBUG_CATEGORY_STATIC (collect_pads_debug);
|
||||||
|
|
||||||
GST_BOILERPLATE (GstCollectPads, gst_collect_pads, GstObject, GST_TYPE_OBJECT);
|
GST_BOILERPLATE (GstCollectPads, gst_collect_pads, GstObject, GST_TYPE_OBJECT);
|
||||||
|
|
||||||
|
static void gst_collect_pads_clear (GstCollectPads * pads,
|
||||||
|
GstCollectData * data);
|
||||||
static GstFlowReturn gst_collect_pads_chain (GstPad * pad, GstBuffer * buffer);
|
static GstFlowReturn gst_collect_pads_chain (GstPad * pad, GstBuffer * buffer);
|
||||||
static gboolean gst_collect_pads_event (GstPad * pad, GstEvent * event);
|
static gboolean gst_collect_pads_event (GstPad * pad, GstEvent * event);
|
||||||
static void gst_collect_pads_finalize (GObject * object);
|
static void gst_collect_pads_finalize (GObject * object);
|
||||||
|
@ -417,6 +419,7 @@ gst_collect_pads_set_flushing_unlocked (GstCollectPads * pads,
|
||||||
else
|
else
|
||||||
GST_PAD_UNSET_FLUSHING (cdata->pad);
|
GST_PAD_UNSET_FLUSHING (cdata->pad);
|
||||||
cdata->abidata.ABI.flushing = flushing;
|
cdata->abidata.ABI.flushing = flushing;
|
||||||
|
gst_collect_pads_clear (pads, cdata);
|
||||||
GST_OBJECT_UNLOCK (cdata->pad);
|
GST_OBJECT_UNLOCK (cdata->pad);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -590,15 +593,13 @@ GstBuffer *
|
||||||
gst_collect_pads_pop (GstCollectPads * pads, GstCollectData * data)
|
gst_collect_pads_pop (GstCollectPads * pads, GstCollectData * data)
|
||||||
{
|
{
|
||||||
GstBuffer *result;
|
GstBuffer *result;
|
||||||
GstBuffer **buffer_p;
|
|
||||||
|
|
||||||
g_return_val_if_fail (pads != NULL, NULL);
|
g_return_val_if_fail (pads != NULL, NULL);
|
||||||
g_return_val_if_fail (GST_IS_COLLECT_PADS (pads), NULL);
|
g_return_val_if_fail (GST_IS_COLLECT_PADS (pads), NULL);
|
||||||
g_return_val_if_fail (data != NULL, NULL);
|
g_return_val_if_fail (data != NULL, NULL);
|
||||||
|
|
||||||
if ((result = data->buffer)) {
|
if ((result = data->buffer)) {
|
||||||
buffer_p = &data->buffer;
|
data->buffer = NULL;
|
||||||
gst_buffer_replace (buffer_p, NULL);
|
|
||||||
data->pos = 0;
|
data->pos = 0;
|
||||||
/* one less pad with queued data now */
|
/* one less pad with queued data now */
|
||||||
pads->queuedpads--;
|
pads->queuedpads--;
|
||||||
|
@ -612,6 +613,17 @@ gst_collect_pads_pop (GstCollectPads * pads, GstCollectData * data)
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* pop and unref the currently queued buffer, should e called with the LOCK
|
||||||
|
* helt. */
|
||||||
|
static void
|
||||||
|
gst_collect_pads_clear (GstCollectPads * pads, GstCollectData * data)
|
||||||
|
{
|
||||||
|
GstBuffer *buf;
|
||||||
|
|
||||||
|
if ((buf = gst_collect_pads_pop (pads, data)))
|
||||||
|
gst_buffer_unref (buf);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* gst_collect_pads_available:
|
* gst_collect_pads_available:
|
||||||
* @pads: the collectspads to query
|
* @pads: the collectspads to query
|
||||||
|
@ -755,13 +767,9 @@ gst_collect_pads_flush (GstCollectPads * pads, GstCollectData * data,
|
||||||
|
|
||||||
data->pos += size;
|
data->pos += size;
|
||||||
|
|
||||||
if (data->pos >= GST_BUFFER_SIZE (buffer)) {
|
if (data->pos >= GST_BUFFER_SIZE (buffer))
|
||||||
GstBuffer *buf;
|
/* _clear will also reset data->pos to 0 */
|
||||||
|
gst_collect_pads_clear (pads, data);
|
||||||
/* _pop will also reset data->pos to 0 */
|
|
||||||
buf = gst_collect_pads_pop (pads, data);
|
|
||||||
gst_buffer_unref (buf);
|
|
||||||
}
|
|
||||||
|
|
||||||
return flushsize;
|
return flushsize;
|
||||||
}
|
}
|
||||||
|
@ -894,7 +902,7 @@ gst_collect_pads_event (GstPad * pad, GstEvent * event)
|
||||||
* non-flushing block again */
|
* non-flushing block again */
|
||||||
GST_OBJECT_LOCK (pads);
|
GST_OBJECT_LOCK (pads);
|
||||||
data->abidata.ABI.flushing = TRUE;
|
data->abidata.ABI.flushing = TRUE;
|
||||||
GST_COLLECT_PADS_BROADCAST (pads);
|
gst_collect_pads_clear (pads, data);
|
||||||
GST_OBJECT_UNLOCK (pads);
|
GST_OBJECT_UNLOCK (pads);
|
||||||
|
|
||||||
/* event already cleaned up by forwarding */
|
/* event already cleaned up by forwarding */
|
||||||
|
@ -905,7 +913,7 @@ gst_collect_pads_event (GstPad * pad, GstEvent * event)
|
||||||
/* flush the 1 buffer queue */
|
/* flush the 1 buffer queue */
|
||||||
GST_OBJECT_LOCK (pads);
|
GST_OBJECT_LOCK (pads);
|
||||||
data->abidata.ABI.flushing = FALSE;
|
data->abidata.ABI.flushing = FALSE;
|
||||||
gst_collect_pads_pop (pads, data);
|
gst_collect_pads_clear (pads, data);
|
||||||
/* we need new segment info after the flush */
|
/* we need new segment info after the flush */
|
||||||
gst_segment_init (&data->segment, GST_FORMAT_UNDEFINED);
|
gst_segment_init (&data->segment, GST_FORMAT_UNDEFINED);
|
||||||
data->abidata.ABI.new_segment = FALSE;
|
data->abidata.ABI.new_segment = FALSE;
|
||||||
|
@ -1079,8 +1087,12 @@ gst_collect_pads_chain (GstPad * pad, GstBuffer * buffer)
|
||||||
}
|
}
|
||||||
while (data->buffer != NULL);
|
while (data->buffer != NULL);
|
||||||
|
|
||||||
|
unlock_done:
|
||||||
GST_OBJECT_UNLOCK (pads);
|
GST_OBJECT_UNLOCK (pads);
|
||||||
|
|
||||||
|
done:
|
||||||
|
gst_buffer_unref (buffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/* ERRORS */
|
/* ERRORS */
|
||||||
|
@ -1088,34 +1100,37 @@ not_ours:
|
||||||
{
|
{
|
||||||
/* pretty fatal this one, can't post an error though... */
|
/* pretty fatal this one, can't post an error though... */
|
||||||
GST_WARNING ("not our pad");
|
GST_WARNING ("not our pad");
|
||||||
return GST_FLOW_ERROR;
|
ret = GST_FLOW_ERROR;
|
||||||
|
goto done;
|
||||||
}
|
}
|
||||||
not_started:
|
not_started:
|
||||||
{
|
{
|
||||||
GST_OBJECT_UNLOCK (pads);
|
|
||||||
GST_DEBUG ("not started");
|
GST_DEBUG ("not started");
|
||||||
return GST_FLOW_WRONG_STATE;
|
gst_collect_pads_clear (pads, data);
|
||||||
|
ret = GST_FLOW_WRONG_STATE;
|
||||||
|
goto unlock_done;
|
||||||
}
|
}
|
||||||
flushing:
|
flushing:
|
||||||
{
|
{
|
||||||
GST_OBJECT_UNLOCK (pads);
|
|
||||||
GST_DEBUG ("pad %s:%s is flushing", GST_DEBUG_PAD_NAME (pad));
|
GST_DEBUG ("pad %s:%s is flushing", GST_DEBUG_PAD_NAME (pad));
|
||||||
return GST_FLOW_WRONG_STATE;
|
gst_collect_pads_clear (pads, data);
|
||||||
|
ret = GST_FLOW_WRONG_STATE;
|
||||||
|
goto unlock_done;
|
||||||
}
|
}
|
||||||
unexpected:
|
unexpected:
|
||||||
{
|
{
|
||||||
GST_OBJECT_UNLOCK (pads);
|
|
||||||
/* we should not post an error for this, just inform upstream that
|
/* we should not post an error for this, just inform upstream that
|
||||||
* we don't expect anything anymore */
|
* we don't expect anything anymore */
|
||||||
GST_DEBUG ("pad %s:%s is eos", GST_DEBUG_PAD_NAME (pad));
|
GST_DEBUG ("pad %s:%s is eos", GST_DEBUG_PAD_NAME (pad));
|
||||||
return GST_FLOW_UNEXPECTED;
|
ret = GST_FLOW_UNEXPECTED;
|
||||||
|
goto unlock_done;
|
||||||
}
|
}
|
||||||
error:
|
error:
|
||||||
{
|
{
|
||||||
GST_OBJECT_UNLOCK (pads);
|
|
||||||
/* we print the error, the element should post a reasonable error
|
/* we print the error, the element should post a reasonable error
|
||||||
* message for fatal errors */
|
* message for fatal errors */
|
||||||
GST_DEBUG ("collect failed, reason %d (%s)", ret, gst_flow_get_name (ret));
|
GST_DEBUG ("collect failed, reason %d (%s)", ret, gst_flow_get_name (ret));
|
||||||
return ret;
|
gst_collect_pads_clear (pads, data);
|
||||||
|
goto unlock_done;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue