mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-22 05:56:31 +00:00
gst/: Add works-in-place flag, use for _pad_alloc().
Original commit message from CVS: Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net> * gst/gstelement.h: * gst/gstpad.c: (gst_pad_alloc_buffer): Add works-in-place flag, use for _pad_alloc(). * gst/elements/gstidentity.c: (gst_identity_init): * gst/gstqueue.c: (gst_queue_init): Use works-in-place flag (#300932).
This commit is contained in:
parent
fc3f486636
commit
3c8e11f0a3
7 changed files with 71 additions and 15 deletions
11
ChangeLog
11
ChangeLog
|
@ -1,3 +1,14 @@
|
|||
2005-04-22 Luca Ognibene <luogni@tin.it>
|
||||
|
||||
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
||||
* gst/gstelement.h:
|
||||
* gst/gstpad.c: (gst_pad_alloc_buffer):
|
||||
Add works-in-place flag, use for _pad_alloc().
|
||||
* gst/elements/gstidentity.c: (gst_identity_init):
|
||||
* gst/gstqueue.c: (gst_queue_init):
|
||||
Use works-in-place flag (#300932).
|
||||
|
||||
2005-04-22 Kjartan Maraas <kmaraas@gnome.org>
|
||||
|
||||
Reviewed by: Ronald S. Bultje <rbultje@ronald.bitfreak.net>
|
||||
|
|
|
@ -227,6 +227,8 @@ gst_identity_init (GstIdentity * identity)
|
|||
identity->srccaps = NULL;
|
||||
|
||||
GST_FLAG_SET (identity, GST_ELEMENT_EVENT_AWARE);
|
||||
GST_FLAG_SET (identity, GST_ELEMENT_WORK_IN_PLACE);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -126,6 +126,9 @@ typedef enum {
|
|||
/* element is in error */
|
||||
GST_ELEMENT_IN_ERROR,
|
||||
|
||||
/* element doesn't change passed buffer or change it in place */
|
||||
GST_ELEMENT_WORK_IN_PLACE,
|
||||
|
||||
/* use some padding for future expansion */
|
||||
GST_ELEMENT_FLAG_LAST = GST_OBJECT_FLAG_LAST + 16
|
||||
} GstElementFlags;
|
||||
|
|
58
gst/gstpad.c
58
gst/gstpad.c
|
@ -2979,20 +2979,56 @@ gst_pad_alloc_buffer (GstPad * pad, guint64 offset, gint size)
|
|||
|
||||
peer = GST_RPAD_PEER (pad);
|
||||
|
||||
if (peer && peer->bufferallocfunc) {
|
||||
GstBuffer *ret;
|
||||
while (peer) {
|
||||
if (peer->bufferallocfunc) {
|
||||
GstBuffer *ret;
|
||||
|
||||
GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer",
|
||||
GST_DEBUG_PAD_NAME (pad));
|
||||
GST_CAT_DEBUG (GST_CAT_PADS,
|
||||
"calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
|
||||
GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
|
||||
&peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer)));
|
||||
GST_CAT_DEBUG (GST_CAT_BUFFER, "(%s:%s): getting buffer",
|
||||
GST_DEBUG_PAD_NAME (pad));
|
||||
GST_CAT_DEBUG (GST_CAT_PADS,
|
||||
"calling bufferallocfunc &%s (@%p) of peer pad %s:%s",
|
||||
GST_DEBUG_FUNCPTR_NAME (peer->bufferallocfunc),
|
||||
&peer->bufferallocfunc, GST_DEBUG_PAD_NAME (((GstPad *) peer)));
|
||||
|
||||
ret = (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
|
||||
if (ret)
|
||||
return ret;
|
||||
ret = (peer->bufferallocfunc) (GST_PAD (peer), offset, size);
|
||||
if (ret)
|
||||
return ret;
|
||||
else
|
||||
break;
|
||||
} else {
|
||||
/*
|
||||
there is a peer but it doesn't have a bufferallocfunc.
|
||||
Try to proxy the request if GST_ELEMENT_WORK_IN_PLACE
|
||||
is setted (try only when there is a single src pad)
|
||||
*/
|
||||
GstElement *parent = GST_PAD_PARENT (peer);
|
||||
|
||||
if (parent == NULL)
|
||||
break;
|
||||
if (GST_FLAG_IS_SET (parent, GST_ELEMENT_WORK_IN_PLACE)) {
|
||||
/* get the src pad. don't proxy if src pad numbers != 1 */
|
||||
const GList *pads;
|
||||
GstPad *src = NULL;
|
||||
gint src_pad_count = 0;
|
||||
|
||||
for (pads = gst_element_get_pad_list (parent);
|
||||
pads != NULL; pads = pads->next) {
|
||||
GstPad *t = GST_PAD (pads->data);
|
||||
|
||||
if (GST_PAD_DIRECTION (t) == GST_PAD_SRC) {
|
||||
src = t;
|
||||
src_pad_count++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((src == NULL) || (src_pad_count != 1))
|
||||
break;
|
||||
peer = GST_RPAD_PEER (src);
|
||||
} else
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return gst_buffer_new_and_alloc (size);
|
||||
}
|
||||
|
||||
|
|
|
@ -354,6 +354,8 @@ gst_queue_init (GstQueue * queue)
|
|||
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue,
|
||||
"initialized queue's not_empty & not_full conditions");
|
||||
|
||||
GST_FLAG_SET (queue, GST_ELEMENT_WORK_IN_PLACE);
|
||||
}
|
||||
|
||||
/* called only once, as opposed to dispose */
|
||||
|
@ -918,8 +920,7 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
|
|||
GST_QUEUE_MUTEX_LOCK;
|
||||
|
||||
if (gst_element_get_state (GST_ELEMENT (queue)) == GST_STATE_PLAYING) {
|
||||
gboolean need_response =
|
||||
GST_DATA_FLAG_IS_SET (GST_DATA (event),
|
||||
gboolean need_response = GST_DATA_FLAG_IS_SET (GST_DATA (event),
|
||||
GST_EVENT_COMMON_FLAG_NEED_RESPONSE);
|
||||
|
||||
er = g_new (GstQueueEventResponse, 1);
|
||||
|
|
|
@ -227,6 +227,8 @@ gst_identity_init (GstIdentity * identity)
|
|||
identity->srccaps = NULL;
|
||||
|
||||
GST_FLAG_SET (identity, GST_ELEMENT_EVENT_AWARE);
|
||||
GST_FLAG_SET (identity, GST_ELEMENT_WORK_IN_PLACE);
|
||||
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
@ -354,6 +354,8 @@ gst_queue_init (GstQueue * queue)
|
|||
|
||||
GST_CAT_DEBUG_OBJECT (GST_CAT_THREAD, queue,
|
||||
"initialized queue's not_empty & not_full conditions");
|
||||
|
||||
GST_FLAG_SET (queue, GST_ELEMENT_WORK_IN_PLACE);
|
||||
}
|
||||
|
||||
/* called only once, as opposed to dispose */
|
||||
|
@ -918,8 +920,7 @@ gst_queue_handle_src_event (GstPad * pad, GstEvent * event)
|
|||
GST_QUEUE_MUTEX_LOCK;
|
||||
|
||||
if (gst_element_get_state (GST_ELEMENT (queue)) == GST_STATE_PLAYING) {
|
||||
gboolean need_response =
|
||||
GST_DATA_FLAG_IS_SET (GST_DATA (event),
|
||||
gboolean need_response = GST_DATA_FLAG_IS_SET (GST_DATA (event),
|
||||
GST_EVENT_COMMON_FLAG_NEED_RESPONSE);
|
||||
|
||||
er = g_new (GstQueueEventResponse, 1);
|
||||
|
|
Loading…
Reference in a new issue