pad: Detect, fix and warn when sticky events are in wrong order

We can prevent buggy element from causing other elements to fail or crash
by sorting sticky event at insertion. In this case, we also warn as this
is not supposed to happen.

See: https://bugzilla.gnome.org/show_bug.cgi?id=688188
This commit is contained in:
Nicolas Dufresne 2013-05-07 21:53:37 -04:00 committed by Sebastian Dröge
parent 913b1e6f20
commit a68e33712e

View file

@ -4401,6 +4401,7 @@ store_sticky_event (GstPad * pad, GstEvent * event)
GArray *events;
gboolean res = FALSE;
const gchar *name = NULL;
gboolean insert = TRUE;
if (G_UNLIKELY (GST_PAD_IS_FLUSHING (pad)))
goto flushed;
@ -4429,14 +4430,22 @@ store_sticky_event (GstPad * pad, GstEvent * event)
/* overwrite */
if ((res = gst_event_replace (&ev->event, event)))
ev->received = FALSE;
insert = FALSE;
break;
}
if (type < GST_EVENT_TYPE (ev->event)) {
g_warning (G_STRLOC ":%s:<%s:%s> Sticky event misordering detected",
G_STRFUNC, GST_DEBUG_PAD_NAME (pad));
break;
}
}
if (i == len) {
if (insert) {
PadEvent ev;
ev.event = gst_event_ref (event);
ev.received = FALSE;
g_array_append_val (events, ev);
g_array_insert_val (events, i, ev);
res = TRUE;
}