validate: pad-monitor: Fix pad function data properly

Until now we were overriding pad functions forgetting about the function
data (that are set using the _full variant of the functions setters), meaning
that the data was lost and any user of that feature would get empty data when
the wrapped function were called.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/7470>
This commit is contained in:
Thibault Saunier 2024-09-07 08:37:33 -04:00 committed by Backport Bot
parent f7faf5e8e5
commit d01cc28c07

View file

@ -2996,21 +2996,28 @@ gst_validate_pad_monitor_do_setup (GstValidateMonitor * monitor)
pad_monitor->event_func = GST_PAD_EVENTFUNC (pad); pad_monitor->event_func = GST_PAD_EVENTFUNC (pad);
pad_monitor->event_full_func = GST_PAD_EVENTFULLFUNC (pad); pad_monitor->event_full_func = GST_PAD_EVENTFULLFUNC (pad);
pad_monitor->query_func = GST_PAD_QUERYFUNC (pad); gpointer eventdata = pad->eventdata;
pad_monitor->activatemode_func = GST_PAD_ACTIVATEMODEFUNC (pad); GDestroyNotify eventnotify = pad->eventnotify;
pad_monitor->get_range_func = GST_PAD_GETRANGEFUNC (pad); pad->eventdata = NULL;
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) { pad->eventnotify = NULL;
if (GST_PAD_DIRECTION (pad) == GST_PAD_SINK) {
pad_monitor->chain_func = GST_PAD_CHAINFUNC (pad); pad_monitor->chain_func = GST_PAD_CHAINFUNC (pad);
gpointer chaindata = pad->chaindata;
GDestroyNotify chainnotify = pad->chainnotify;
pad->chaindata = NULL;
pad->chainnotify = NULL;
if (pad_monitor->chain_func) if (pad_monitor->chain_func)
gst_pad_set_chain_function (pad, gst_validate_pad_monitor_chain_func); gst_pad_set_chain_function_full (pad, gst_validate_pad_monitor_chain_func,
chaindata, chainnotify);
if (pad_monitor->event_full_func) if (pad_monitor->event_full_func)
gst_pad_set_event_full_function (pad, gst_pad_set_event_full_function_full (pad,
gst_validate_pad_monitor_sink_event_full_func); gst_validate_pad_monitor_sink_event_full_func,
eventdata, eventnotify);
else else
gst_pad_set_event_function (pad, gst_pad_set_event_function_full (pad,
gst_validate_pad_monitor_sink_event_func); gst_validate_pad_monitor_sink_event_func, eventdata, eventnotify);
} else { } else {
gst_pad_set_event_function (pad, gst_validate_pad_monitor_src_event_func); gst_pad_set_event_function (pad, gst_validate_pad_monitor_src_event_func);
@ -3022,13 +3029,32 @@ gst_validate_pad_monitor_do_setup (GstValidateMonitor * monitor)
(GstPadProbeCallback) gst_validate_pad_monitor_pad_probe, pad_monitor, (GstPadProbeCallback) gst_validate_pad_monitor_pad_probe, pad_monitor,
NULL); NULL);
} }
gst_pad_set_query_function (pad, gst_validate_pad_monitor_query_func);
gst_pad_set_activatemode_function (pad, pad_monitor->query_func = GST_PAD_QUERYFUNC (pad);
gst_validate_pad_monitor_activatemode_func); gpointer querydata = pad->querydata;
GDestroyNotify querynotify = pad->querynotify;
pad->querydata = NULL;
pad->querynotify = NULL;
gst_pad_set_query_function_full (pad, gst_validate_pad_monitor_query_func,
querydata, querynotify);
pad_monitor->activatemode_func = GST_PAD_ACTIVATEMODEFUNC (pad);
gpointer activatemodedata = pad->activatemodedata;
GDestroyNotify activatemodenotify = pad->activatemodenotify;
pad->activatemodedata = NULL;
pad->activatemodenotify = NULL;
gst_pad_set_activatemode_function_full (pad,
gst_validate_pad_monitor_activatemode_func,
activatemodedata, activatemodenotify);
if (GST_PAD_IS_SRC (pad)) { if (GST_PAD_IS_SRC (pad)) {
gst_pad_set_getrange_function (pad, pad_monitor->get_range_func = GST_PAD_GETRANGEFUNC (pad);
gst_validate_pad_monitor_get_range_func); gpointer getrangedata = pad->getrangedata;
GDestroyNotify getrangenotify = pad->getrangenotify;
pad->getrangedata = NULL;
pad->getrangenotify = NULL;
gst_pad_set_getrange_function_full (pad,
gst_validate_pad_monitor_get_range_func, getrangedata, getrangenotify);
} }
gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (monitor), gst_validate_reporter_set_name (GST_VALIDATE_REPORTER (monitor),