mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-02-17 19:55:32 +00:00
multiqueue: Use iterate_internal_links instead of deprecated get_internal_links
This commit is contained in:
parent
884467d493
commit
269d3581c5
2 changed files with 82 additions and 25 deletions
|
@ -373,6 +373,7 @@ gst_multi_queue_finalize (GObject * object)
|
||||||
g_list_foreach (mqueue->queues, (GFunc) gst_single_queue_free, NULL);
|
g_list_foreach (mqueue->queues, (GFunc) gst_single_queue_free, NULL);
|
||||||
g_list_free (mqueue->queues);
|
g_list_free (mqueue->queues);
|
||||||
mqueue->queues = NULL;
|
mqueue->queues = NULL;
|
||||||
|
mqueue->queues_cookie++;
|
||||||
|
|
||||||
/* free/unref instance data */
|
/* free/unref instance data */
|
||||||
g_mutex_free (mqueue->qlock);
|
g_mutex_free (mqueue->qlock);
|
||||||
|
@ -464,36 +465,89 @@ gst_multi_queue_get_property (GObject * object, guint prop_id,
|
||||||
GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
|
GST_MULTI_QUEUE_MUTEX_UNLOCK (mq);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GList *
|
typedef struct
|
||||||
gst_multi_queue_get_internal_links (GstPad * pad)
|
|
||||||
{
|
{
|
||||||
GList *res = NULL;
|
GstIterator parent;
|
||||||
|
|
||||||
GstMultiQueue *mqueue;
|
GstMultiQueue *mqueue;
|
||||||
GstSingleQueue *sq = NULL;
|
GstPad *pad;
|
||||||
GList *tmp;
|
GList *current;
|
||||||
|
} GstMultiQueueIterator;
|
||||||
|
|
||||||
|
static void
|
||||||
|
_iterate_free (GstIterator * it)
|
||||||
|
{
|
||||||
|
GstMultiQueueIterator *mit = (GstMultiQueueIterator *) it;
|
||||||
|
|
||||||
|
g_object_unref (mit->mqueue);
|
||||||
|
g_object_unref (mit->pad);
|
||||||
|
|
||||||
|
g_free (it);
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstIteratorResult
|
||||||
|
_iterate_next (GstIterator * it, gpointer * result)
|
||||||
|
{
|
||||||
|
GstMultiQueueIterator *mit = (GstMultiQueueIterator *) it;
|
||||||
|
GList *current;
|
||||||
|
GstPad *res = NULL;
|
||||||
|
|
||||||
|
/* Find which single queue it belongs to */
|
||||||
|
for (current = mit->current; !res && current; current = current->next) {
|
||||||
|
GstSingleQueue *sq = (GstSingleQueue *) current->data;
|
||||||
|
|
||||||
|
if (sq->sinkpad == mit->pad)
|
||||||
|
res = sq->srcpad;
|
||||||
|
if (sq->srcpad == mit->pad)
|
||||||
|
res = sq->sinkpad;
|
||||||
|
}
|
||||||
|
|
||||||
|
*result = res;
|
||||||
|
|
||||||
|
mit->current = current;
|
||||||
|
|
||||||
|
return res ? GST_ITERATOR_OK : GST_ITERATOR_DONE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstIteratorItem
|
||||||
|
_iterate_item (GstIterator * it, gpointer item)
|
||||||
|
{
|
||||||
|
GstPad *pad = (GstPad *) item;
|
||||||
|
gst_object_ref (pad);
|
||||||
|
|
||||||
|
return GST_ITERATOR_ITEM_PASS;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
_iterate_resync (GstIterator * it)
|
||||||
|
{
|
||||||
|
GstMultiQueueIterator *mit = (GstMultiQueueIterator *) it;
|
||||||
|
|
||||||
|
mit->current = mit->mqueue->queues;
|
||||||
|
}
|
||||||
|
|
||||||
|
static GstIterator *
|
||||||
|
gst_multi_queue_iterate_internal_links (GstPad * pad)
|
||||||
|
{
|
||||||
|
GstMultiQueue *mqueue;
|
||||||
|
GstMultiQueueIterator *ret;
|
||||||
|
|
||||||
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
g_return_val_if_fail (GST_IS_PAD (pad), NULL);
|
||||||
|
|
||||||
mqueue = GST_MULTI_QUEUE (GST_PAD_PARENT (pad));
|
mqueue = GST_MULTI_QUEUE (GST_PAD_PARENT (pad));
|
||||||
if (!mqueue)
|
if (!mqueue)
|
||||||
goto no_parent;
|
goto no_parent;
|
||||||
|
|
||||||
GST_MULTI_QUEUE_MUTEX_LOCK (mqueue);
|
ret = (GstMultiQueueIterator *)
|
||||||
/* Find which single queue it belongs to */
|
gst_iterator_new (sizeof (GstMultiQueueIterator),
|
||||||
for (tmp = mqueue->queues; tmp && !res; tmp = g_list_next (tmp)) {
|
GST_TYPE_PAD,
|
||||||
sq = (GstSingleQueue *) tmp->data;
|
mqueue->qlock,
|
||||||
|
&mqueue->queues_cookie,
|
||||||
|
_iterate_next, _iterate_item, _iterate_resync, _iterate_free);
|
||||||
|
ret->mqueue = g_object_ref (mqueue);
|
||||||
|
ret->current = mqueue->queues;
|
||||||
|
ret->pad = g_object_ref (pad);
|
||||||
|
|
||||||
if (sq->sinkpad == pad)
|
return (GstIterator *) ret;
|
||||||
res = g_list_prepend (res, sq->srcpad);
|
|
||||||
if (sq->srcpad == pad)
|
|
||||||
res = g_list_prepend (res, sq->sinkpad);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!res)
|
|
||||||
GST_WARNING_OBJECT (mqueue, "That pad doesn't belong to this element ???");
|
|
||||||
GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
|
|
||||||
no_parent:
|
no_parent:
|
||||||
{
|
{
|
||||||
|
@ -521,6 +575,7 @@ gst_multi_queue_request_new_pad (GstElement * element, GstPadTemplate * temp,
|
||||||
|
|
||||||
GST_MULTI_QUEUE_MUTEX_LOCK (mqueue);
|
GST_MULTI_QUEUE_MUTEX_LOCK (mqueue);
|
||||||
mqueue->queues = g_list_append (mqueue->queues, squeue);
|
mqueue->queues = g_list_append (mqueue->queues, squeue);
|
||||||
|
mqueue->queues_cookie++;
|
||||||
GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue);
|
GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue);
|
||||||
|
|
||||||
GST_DEBUG_OBJECT (mqueue, "Returning pad %s:%s",
|
GST_DEBUG_OBJECT (mqueue, "Returning pad %s:%s",
|
||||||
|
@ -558,6 +613,7 @@ gst_multi_queue_release_pad (GstElement * element, GstPad * pad)
|
||||||
|
|
||||||
/* remove it from the list */
|
/* remove it from the list */
|
||||||
mqueue->queues = g_list_delete_link (mqueue->queues, tmp);
|
mqueue->queues = g_list_delete_link (mqueue->queues, tmp);
|
||||||
|
mqueue->queues_cookie++;
|
||||||
|
|
||||||
/* FIXME : recompute next-non-linked */
|
/* FIXME : recompute next-non-linked */
|
||||||
GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue);
|
GST_MULTI_QUEUE_MUTEX_UNLOCK (mqueue);
|
||||||
|
@ -1461,8 +1517,8 @@ gst_single_queue_new (GstMultiQueue * mqueue)
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_getcaps));
|
||||||
gst_pad_set_bufferalloc_function (sq->sinkpad,
|
gst_pad_set_bufferalloc_function (sq->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_bufferalloc));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_bufferalloc));
|
||||||
gst_pad_set_internal_link_function (sq->sinkpad,
|
gst_pad_set_iterate_internal_links_function (sq->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_get_internal_links));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_iterate_internal_links));
|
||||||
|
|
||||||
tmp = g_strdup_printf ("src%d", sq->id);
|
tmp = g_strdup_printf ("src%d", sq->id);
|
||||||
sq->srcpad = gst_pad_new_from_static_template (&srctemplate, tmp);
|
sq->srcpad = gst_pad_new_from_static_template (&srctemplate, tmp);
|
||||||
|
@ -1476,8 +1532,8 @@ gst_single_queue_new (GstMultiQueue * mqueue)
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_src_event));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_src_event));
|
||||||
gst_pad_set_query_function (sq->srcpad,
|
gst_pad_set_query_function (sq->srcpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_src_query));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_src_query));
|
||||||
gst_pad_set_internal_link_function (sq->srcpad,
|
gst_pad_set_iterate_internal_links_function (sq->sinkpad,
|
||||||
GST_DEBUG_FUNCPTR (gst_multi_queue_get_internal_links));
|
GST_DEBUG_FUNCPTR (gst_multi_queue_iterate_internal_links));
|
||||||
|
|
||||||
gst_pad_set_element_private (sq->sinkpad, (gpointer) sq);
|
gst_pad_set_element_private (sq->sinkpad, (gpointer) sq);
|
||||||
gst_pad_set_element_private (sq->srcpad, (gpointer) sq);
|
gst_pad_set_element_private (sq->srcpad, (gpointer) sq);
|
||||||
|
|
|
@ -55,6 +55,7 @@ struct _GstMultiQueue {
|
||||||
|
|
||||||
/* The list of individual queues */
|
/* The list of individual queues */
|
||||||
GList *queues;
|
GList *queues;
|
||||||
|
guint32 queues_cookie;
|
||||||
|
|
||||||
GstDataQueueSize max_size, extra_size;
|
GstDataQueueSize max_size, extra_size;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue