pad: notify caps after we store the new caps

notify caps after we store the new caps so that the new caps are actually
visible for the app.
This commit is contained in:
Wim Taymans 2011-06-21 10:29:51 +02:00
parent 69409f1ec8
commit de3b6e733f

View file

@ -2695,7 +2695,7 @@ gst_pad_set_caps (GstPad * pad, GstCaps * caps)
static gboolean static gboolean
do_event_function (GstPad * pad, GstEvent * event, do_event_function (GstPad * pad, GstEvent * event,
GstPadEventFunction eventfunc) GstPadEventFunction eventfunc, gboolean * caps_notify)
{ {
gboolean result = TRUE; gboolean result = TRUE;
GstCaps *caps, *templ; GstCaps *caps, *templ;
@ -2711,7 +2711,7 @@ do_event_function (GstPad * pad, GstEvent * event,
if (!gst_caps_can_intersect (caps, templ)) if (!gst_caps_can_intersect (caps, templ))
goto not_accepted; goto not_accepted;
g_object_notify_by_pspec ((GObject *) pad, pspec_caps); *caps_notify = TRUE;
gst_caps_unref (templ); gst_caps_unref (templ);
break; break;
@ -2747,6 +2747,7 @@ gst_pad_update_events (GstPad * pad)
guint i; guint i;
GstPadEventFunction eventfunc; GstPadEventFunction eventfunc;
GstEvent *event; GstEvent *event;
gboolean caps_notify = FALSE;
if (G_UNLIKELY ((eventfunc = GST_PAD_EVENTFUNC (pad)) == NULL)) if (G_UNLIKELY ((eventfunc = GST_PAD_EVENTFUNC (pad)) == NULL))
goto no_function; goto no_function;
@ -2764,9 +2765,8 @@ gst_pad_update_events (GstPad * pad)
gst_event_ref (event); gst_event_ref (event);
GST_OBJECT_UNLOCK (pad); GST_OBJECT_UNLOCK (pad);
res = do_event_function (pad, event, eventfunc); res = do_event_function (pad, event, eventfunc, &caps_notify);
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. FIXME, we also want to remove * to try again. FIXME. we need a cookie here. FIXME, we also want to remove
@ -2775,13 +2775,19 @@ gst_pad_update_events (GstPad * pad)
if (res) { if (res) {
/* make the event active */ /* make the event active */
gst_event_take (&ev->event, event); gst_event_take (&ev->event, event);
/* notify caps change when needed */
if (caps_notify) {
g_object_notify_by_pspec ((GObject *) pad, pspec_caps);
caps_notify = FALSE;
}
} else { } else {
gst_event_unref (event); gst_event_unref (event);
ret = GST_FLOW_ERROR; ret = GST_FLOW_ERROR;
} }
GST_OBJECT_LOCK (pad);
} }
/* when we get here all events were successfully updated. */ /* when we get here all events were successfully updated. */
return ret; return ret;
/* ERRORS */ /* ERRORS */