pad: use new event methods to replace events

Using the new event methods, we can atomically transfer the event from the
pending list to the active list.
This commit is contained in:
Wim Taymans 2011-06-09 13:37:28 +02:00
parent 1b21f2af8f
commit ab0ab2fbca

View file

@ -2727,7 +2727,6 @@ gst_pad_update_events (GstPad * pad)
if (G_UNLIKELY ((eventfunc = GST_PAD_EVENTFUNC (pad)) == NULL)) if (G_UNLIKELY ((eventfunc = GST_PAD_EVENTFUNC (pad)) == NULL))
goto no_function; goto no_function;
restart:
for (i = 0; i < GST_EVENT_MAX_STICKY; i++) { for (i = 0; i < GST_EVENT_MAX_STICKY; i++) {
gboolean res; gboolean res;
PadEvent *ev; PadEvent *ev;
@ -2735,7 +2734,7 @@ restart:
ev = &pad->priv->events[i]; ev = &pad->priv->events[i];
/* skip without pending event */ /* skip without pending event */
if ((event = ev->pending) == NULL) if ((event = gst_event_steal (&ev->pending)) == NULL)
continue; continue;
gst_event_ref (event); gst_event_ref (event);
@ -2746,20 +2745,12 @@ restart:
GST_OBJECT_LOCK (pad); GST_OBJECT_LOCK (pad);
/* things could have changed while we release the lock, check if we still /* things could have changed while we release the lock, check if we still
* are handling the same event, if we don't something changed and we have * are handling the same event, if we don't something changed and we have
* to try again. FIXME. we need a cookie here. */ * to try again. FIXME. we need a cookie here. FIXME, we also want to remove
if (event != ev->pending) { * that lock eventually and then do the retry elsewhere. */
GST_DEBUG_OBJECT (pad, "events changed, restarting");
goto restart;
}
/* remove the event from the pending entry in all cases */
ev->pending = NULL;
if (res) { if (res) {
/* make the event active */ /* make the event active */
if (ev->event) gst_event_take (&ev->event, event);
gst_event_unref (ev->event);
ev->event = event;
} else { } else {
gst_event_unref (event); gst_event_unref (event);
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;