Commit 6e0a7243 authored by Wim Taymans's avatar Wim Taymans

pad: Add destroy notify to pad functions

Add _full variants of the pad function setters that take a destroy notify.
Make some macros that make the old method name pass NULL to this new
function.
parent 2f1ed653
......@@ -1617,30 +1617,38 @@ gst_pad_new_from_template
gst_pad_new_from_static_template
gst_pad_set_chain_function
gst_pad_set_chain_function_full
GstPadChainFunction
gst_pad_set_chain_list_function
gst_pad_set_chain_list_function_full
GstPadChainListFunction
gst_pad_get_range
gst_pad_set_getrange_function
gst_pad_set_getrange_function_full
GstPadGetRangeFunction
gst_pad_set_event_function
gst_pad_set_event_function_full
GstPadEventFunction
gst_pad_set_link_function
gst_pad_set_link_function_full
GstPadLinkFunction
gst_pad_set_unlink_function
gst_pad_set_unlink_function_full
GstPadUnlinkFunction
gst_pad_proxy_query_caps
gst_pad_proxy_query_accept_caps
gst_pad_set_activate_function
gst_pad_set_activate_function_full
GstPadActivateFunction
gst_pad_set_activatemode_function
gst_pad_set_activatemode_function_full
GstPadActivateModeFunction
gst_pad_check_reconfigure
......@@ -1672,8 +1680,10 @@ gst_pad_peer_query_accept_caps
gst_pad_peer_query_caps
gst_pad_set_query_function
gst_pad_set_query_function_full
GstPadQueryFunction
gst_pad_set_iterate_internal_links_function
gst_pad_set_iterate_internal_links_function_full
GstPadIterIntLinkFunction
gst_pad_iterate_internal_links
gst_pad_iterate_internal_links_default
......
......@@ -472,6 +472,27 @@ gst_pad_finalize (GObject * object)
gst_object_unref (task);
}
if (pad->activatenotify)
pad->activatenotify (pad);
if (pad->activatemodenotify)
pad->activatemodenotify (pad);
if (pad->linknotify)
pad->linknotify (pad);
if (pad->unlinknotify)
pad->unlinknotify (pad);
if (pad->chainnotify)
pad->chainnotify (pad);
if (pad->chainlistnotify)
pad->chainlistnotify (pad);
if (pad->getrangenotify)
pad->getrangenotify (pad);
if (pad->eventnotify)
pad->eventnotify (pad);
if (pad->querynotify)
pad->querynotify (pad);
if (pad->iterintlinknotify)
pad->iterintlinknotify (pad);
g_static_rec_mutex_free (&pad->stream_rec_lock);
g_cond_free (pad->block_cond);
......@@ -1180,9 +1201,10 @@ gst_pad_mark_reconfigure (GstPad * pad)
}
/**
* gst_pad_set_activate_function:
* gst_pad_set_activate_function_full:
* @pad: a #GstPad.
* @activate: the #GstPadActivateFunction to set.
* @notify: notify called when @activate will not be used anymore.
*
* Sets the given activate function for @pad. The activate function will
* dispatch to gst_pad_activate_push() or gst_pad_activate_pull() to perform
......@@ -1191,57 +1213,74 @@ gst_pad_mark_reconfigure (GstPad * pad)
* Call this function if your sink pad can start a pull-based task.
*/
void
gst_pad_set_activate_function (GstPad * pad, GstPadActivateFunction activate)
gst_pad_set_activate_function_full (GstPad * pad,
GstPadActivateFunction activate, GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->activatenotify)
pad->activatenotify (pad);
GST_PAD_ACTIVATEFUNC (pad) = activate;
pad->activatenotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "activatefunc set to %s",
GST_DEBUG_FUNCPTR_NAME (activate));
}
/**
* gst_pad_set_activatemode_function:
* gst_pad_set_activatemode_function_full:
* @pad: a #GstPad.
* @activatemode: the #GstPadActivateModeFunction to set.
* @notify: notify called when @activatemode will not be used anymore.
*
* Sets the given activate_mode function for the pad. An activate_mode function
* prepares the element for data passing.
*/
void
gst_pad_set_activatemode_function (GstPad * pad,
GstPadActivateModeFunction activatemode)
gst_pad_set_activatemode_function_full (GstPad * pad,
GstPadActivateModeFunction activatemode, GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->activatemodenotify)
pad->activatemodenotify (pad);
GST_PAD_ACTIVATEMODEFUNC (pad) = activatemode;
pad->activatemodenotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "activatemodefunc set to %s",
GST_DEBUG_FUNCPTR_NAME (activatemode));
}
/**
* gst_pad_set_chain_function:
* gst_pad_set_chain_function_full:
* @pad: a sink #GstPad.
* @chain: the #GstPadChainFunction to set.
* @notify: notify called when @chain will not be used anymore.
*
* Sets the given chain function for the pad. The chain function is called to
* process a #GstBuffer input buffer. see #GstPadChainFunction for more details.
*/
void
gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain)
gst_pad_set_chain_function_full (GstPad * pad, GstPadChainFunction chain,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (GST_PAD_IS_SINK (pad));
if (pad->chainnotify)
pad->chainnotify (pad);
GST_PAD_CHAINFUNC (pad) = chain;
pad->chainnotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "chainfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (chain));
}
/**
* gst_pad_set_chain_list_function:
* gst_pad_set_chain_list_function_full:
* @pad: a sink #GstPad.
* @chainlist: the #GstPadChainListFunction to set.
* @notify: notify called when @chainlist will not be used anymore.
*
* Sets the given chain list function for the pad. The chainlist function is
* called to process a #GstBufferList input buffer list. See
......@@ -1250,98 +1289,123 @@ gst_pad_set_chain_function (GstPad * pad, GstPadChainFunction chain)
* Since: 0.10.24
*/
void
gst_pad_set_chain_list_function (GstPad * pad,
GstPadChainListFunction chainlist)
gst_pad_set_chain_list_function_full (GstPad * pad,
GstPadChainListFunction chainlist, GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (GST_PAD_IS_SINK (pad));
if (pad->chainlistnotify)
pad->chainlistnotify (pad);
GST_PAD_CHAINLISTFUNC (pad) = chainlist;
pad->chainlistnotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "chainlistfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (chainlist));
}
/**
* gst_pad_set_getrange_function:
* gst_pad_set_getrange_function_full:
* @pad: a source #GstPad.
* @get: the #GstPadGetRangeFunction to set.
* @notify: notify called when @get will not be used anymore.
*
* Sets the given getrange function for the pad. The getrange function is
* called to produce a new #GstBuffer to start the processing pipeline. see
* #GstPadGetRangeFunction for a description of the getrange function.
*/
void
gst_pad_set_getrange_function (GstPad * pad, GstPadGetRangeFunction get)
gst_pad_set_getrange_function_full (GstPad * pad, GstPadGetRangeFunction get,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
g_return_if_fail (GST_PAD_IS_SRC (pad));
if (pad->getrangenotify)
pad->getrangenotify (pad);
GST_PAD_GETRANGEFUNC (pad) = get;
pad->getrangenotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "getrangefunc set to %s",
GST_DEBUG_FUNCPTR_NAME (get));
}
/**
* gst_pad_set_event_function:
* gst_pad_set_event_function_full:
* @pad: a #GstPad of either direction.
* @event: the #GstPadEventFunction to set.
* @notify: notify called when @event will not be used anymore.
*
* Sets the given event handler for the pad.
*/
void
gst_pad_set_event_function (GstPad * pad, GstPadEventFunction event)
gst_pad_set_event_function_full (GstPad * pad, GstPadEventFunction event,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->eventnotify)
pad->eventnotify (pad);
GST_PAD_EVENTFUNC (pad) = event;
pad->eventnotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "eventfunc for set to %s",
GST_DEBUG_FUNCPTR_NAME (event));
}
/**
* gst_pad_set_query_function:
* gst_pad_set_query_function_full:
* @pad: a #GstPad of either direction.
* @query: the #GstPadQueryFunction to set.
* @notify: notify called when @query will not be used anymore.
*
* Set the given query function for the pad.
*/
void
gst_pad_set_query_function (GstPad * pad, GstPadQueryFunction query)
gst_pad_set_query_function_full (GstPad * pad, GstPadQueryFunction query,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->querynotify)
pad->querynotify (pad);
GST_PAD_QUERYFUNC (pad) = query;
pad->querynotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "queryfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (query));
}
/**
* gst_pad_set_iterate_internal_links_function:
* gst_pad_set_iterate_internal_links_function_full:
* @pad: a #GstPad of either direction.
* @iterintlink: the #GstPadIterIntLinkFunction to set.
* @notify: notify called when @iterintlink will not be used anymore.
*
* Sets the given internal link iterator function for the pad.
*
* Since: 0.10.21
*/
void
gst_pad_set_iterate_internal_links_function (GstPad * pad,
GstPadIterIntLinkFunction iterintlink)
gst_pad_set_iterate_internal_links_function_full (GstPad * pad,
GstPadIterIntLinkFunction iterintlink, GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->iterintlinknotify)
pad->iterintlinknotify (pad);
GST_PAD_ITERINTLINKFUNC (pad) = iterintlink;
pad->iterintlinknotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "internal link iterator set to %s",
GST_DEBUG_FUNCPTR_NAME (iterintlink));
}
/**
* gst_pad_set_link_function:
* gst_pad_set_link_function_full:
* @pad: a #GstPad.
* @link: the #GstPadLinkFunction to set.
* @notify: notify called when @link will not be used anymore.
*
* Sets the given link function for the pad. It will be called when
* the pad is linked with another pad.
......@@ -1356,29 +1420,40 @@ gst_pad_set_iterate_internal_links_function (GstPad * pad,
* of the peer sink pad, if present.
*/
void
gst_pad_set_link_function (GstPad * pad, GstPadLinkFunction link)
gst_pad_set_link_function_full (GstPad * pad, GstPadLinkFunction link,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->linknotify)
pad->linknotify (pad);
GST_PAD_LINKFUNC (pad) = link;
pad->linknotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "linkfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (link));
}
/**
* gst_pad_set_unlink_function:
* gst_pad_set_unlink_function_full:
* @pad: a #GstPad.
* @unlink: the #GstPadUnlinkFunction to set.
* @notify: notify called when @unlink will not be used anymore.
*
* Sets the given unlink function for the pad. It will be called
* when the pad is unlinked.
*/
void
gst_pad_set_unlink_function (GstPad * pad, GstPadUnlinkFunction unlink)
gst_pad_set_unlink_function_full (GstPad * pad, GstPadUnlinkFunction unlink,
GDestroyNotify notify)
{
g_return_if_fail (GST_IS_PAD (pad));
if (pad->unlinknotify)
pad->unlinknotify (pad);
GST_PAD_UNLINKFUNC (pad) = unlink;
pad->unlinknotify = notify;
GST_CAT_DEBUG_OBJECT (GST_CAT_PADS, pad, "unlinkfunc set to %s",
GST_DEBUG_FUNCPTR_NAME (unlink));
}
......
......@@ -610,24 +610,6 @@ typedef enum {
* @padtemplate: padtemplate for this pad
* @direction: the direction of the pad, cannot change after creating
* the pad.
* @stream_rec_lock: recursive stream lock of the pad, used to protect
* the data used in streaming.
* @task: task for this pad if the pad is actively driving dataflow.
* @block_cond: conditional to signal pad block
* @probes: installed probes
* @mode: current activation mode of the pad
* @activatefunc: pad activation function
* @activatemodefunc: function to activate/deactivate pad in the requested mode
* @peer: the pad this pad is linked to
* @linkfunc: function called when pad is linked
* @unlinkfunc: function called when pad is unlinked
* @chainfunc: function to chain buffer to pad
* @chainlistfunc: function to chain a list of buffers to pad
* @getrangefunc: function to get a range of data from a pad
* @eventfunc: function to send an event to a pad
* @offset: the pad offset
* @queryfunc: perform a query on the pad
* @iterintlinkfunc: get the internal links iterator of this pad
*
* The #GstPad structure. Use the functions to update the variables.
*/
......@@ -641,41 +623,49 @@ struct _GstPad {
GstPadDirection direction;
/*< public >*/ /* with STREAM_LOCK */
/*< private >*/
/* streaming rec_lock */
GStaticRecMutex stream_rec_lock;
GstTask *task;
/*< public >*/ /* with LOCK */
/* block cond, mutex is from the object */
GCond *block_cond;
GHookList probes;
GstPadMode mode;
GstPadActivateFunction activatefunc;
GDestroyNotify activatenotify;
GstPadActivateModeFunction activatemodefunc;
GDestroyNotify activatemodenotify;
/* pad link */
GstPad *peer;
GstPadLinkFunction linkfunc;
GDestroyNotify linknotify;
GstPadUnlinkFunction unlinkfunc;
GDestroyNotify unlinknotify;
/* data transport functions */
GstPadChainFunction chainfunc;
GDestroyNotify chainnotify;
GstPadChainListFunction chainlistfunc;
GDestroyNotify chainlistnotify;
GstPadGetRangeFunction getrangefunc;
GDestroyNotify getrangenotify;
GstPadEventFunction eventfunc;
GDestroyNotify eventnotify;
/* pad offset */
gint64 offset;
/* generic query method */
GstPadQueryFunction queryfunc;
GDestroyNotify querynotify;
/* internal links */
GstPadIterIntLinkFunction iterintlinkfunc;
GDestroyNotify iterintlinknotify;
/*< private >*/
/* counts number of probes attached. */
gint num_probes;
gint num_blocked;
......@@ -837,16 +827,43 @@ GstEvent* gst_pad_get_sticky_event (GstPad *pad, Gs
GstFlowReturn gst_pad_sticky_events_foreach (GstPad *pad, GstPadStickyEventsForeachFunction foreach_func, gpointer user_data);
/* data passing setup functions */
void gst_pad_set_activate_function (GstPad *pad, GstPadActivateFunction activate);
void gst_pad_set_activatemode_function (GstPad *pad, GstPadActivateModeFunction activatemode);
void gst_pad_set_chain_function (GstPad *pad, GstPadChainFunction chain);
void gst_pad_set_chain_list_function (GstPad *pad, GstPadChainListFunction chainlist);
void gst_pad_set_getrange_function (GstPad *pad, GstPadGetRangeFunction get);
void gst_pad_set_event_function (GstPad *pad, GstPadEventFunction event);
void gst_pad_set_activate_function_full (GstPad *pad,
GstPadActivateFunction activate,
GDestroyNotify notify);
void gst_pad_set_activatemode_function_full (GstPad *pad,
GstPadActivateModeFunction activatemode,
GDestroyNotify notify);
/* data passing functions */
void gst_pad_set_chain_function_full (GstPad *pad,
GstPadChainFunction chain,
GDestroyNotify notify);
void gst_pad_set_chain_list_function_full (GstPad *pad,
GstPadChainListFunction chainlist,
GDestroyNotify notify);
void gst_pad_set_getrange_function_full (GstPad *pad,
GstPadGetRangeFunction get,
GDestroyNotify notify);
void gst_pad_set_event_function_full (GstPad *pad,
GstPadEventFunction event,
GDestroyNotify notify);
#define gst_pad_set_activate_function(p,f) gst_pad_set_activate_function_full((p),(f),NULL)
#define gst_pad_set_activatemode_function(p,f) gst_pad_set_activatemode_function_full((p),(f),NULL)
#define gst_pad_set_chain_function(p,f) gst_pad_set_chain_function_full((p),(f),NULL)
#define gst_pad_set_chain_list_function(p,f) gst_pad_set_chain_list_function_full((p),(f),NULL)
#define gst_pad_set_getrange_function(p,f) gst_pad_set_getrange_function_full((p),(f),NULL)
#define gst_pad_set_event_function(p,f) gst_pad_set_event_function_full((p),(f),NULL)
/* pad links */
void gst_pad_set_link_function (GstPad *pad, GstPadLinkFunction link);
void gst_pad_set_unlink_function (GstPad *pad, GstPadUnlinkFunction unlink);
void gst_pad_set_link_function_full (GstPad *pad,
GstPadLinkFunction link,
GDestroyNotify notify);
void gst_pad_set_unlink_function_full (GstPad *pad,
GstPadUnlinkFunction unlink,
GDestroyNotify notify);
#define gst_pad_set_link_function(p,f) gst_pad_set_link_function_full((p),(f),NULL)
#define gst_pad_set_unlink_function(p,f) gst_pad_set_unlink_function_full((p),(f),NULL)
gboolean gst_pad_can_link (GstPad *srcpad, GstPad *sinkpad);
GstPadLinkReturn gst_pad_link (GstPad *srcpad, GstPad *sinkpad);
......@@ -893,19 +910,24 @@ gboolean gst_pad_pause_task (GstPad *pad);
gboolean gst_pad_stop_task (GstPad *pad);
/* internal links */
void gst_pad_set_iterate_internal_links_function (GstPad * pad,
GstPadIterIntLinkFunction iterintlink);
void gst_pad_set_iterate_internal_links_function_full (GstPad * pad,
GstPadIterIntLinkFunction iterintlink,
GDestroyNotify notify);
GstIterator * gst_pad_iterate_internal_links (GstPad * pad);
GstIterator * gst_pad_iterate_internal_links_default (GstPad * pad, GstObject *parent);
#define gst_pad_set_iterate_internal_links_function(p,f) gst_pad_set_iterate_internal_links_function_full((p),(f),NULL)
/* generic query function */
gboolean gst_pad_query (GstPad *pad, GstQuery *query);
gboolean gst_pad_peer_query (GstPad *pad, GstQuery *query);
void gst_pad_set_query_function (GstPad *pad, GstPadQueryFunction query);
void gst_pad_set_query_function_full (GstPad *pad, GstPadQueryFunction query,
GDestroyNotify notify);
gboolean gst_pad_query_default (GstPad *pad, GstObject *parent,
GstQuery *query);
#define gst_pad_set_query_function(p,f) gst_pad_set_query_function_full((p),(f),NULL)
/* misc helper functions */
gboolean gst_pad_forward (GstPad *pad, GstPadForwardFunction forward,
gpointer user_data);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment