From 6326c764ee85fa17f1d7838f6e4d5824e07e3132 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Fri, 17 Feb 2017 15:48:17 -0300 Subject: [PATCH] pad: Add API to get the current state of a task Avoiding the user to need to deal with the locking himself etc. API: gst_pad_task_get_state https://bugzilla.gnome.org/show_bug.cgi?id=778830 --- docs/gst/gstreamer-sections.txt | 1 + gst/gstpad.c | 34 +++++++++++++++++++++++++++++++++ gst/gstpad.h | 1 + 3 files changed, 36 insertions(+) diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index 5628d8cbb2..b0e6e6c870 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2058,6 +2058,7 @@ gst_pad_chain_list gst_pad_start_task gst_pad_pause_task gst_pad_stop_task +gst_pad_task_get_state gst_pad_set_active diff --git a/gst/gstpad.c b/gst/gstpad.c index f5142e6f6d..4ff6059858 100644 --- a/gst/gstpad.c +++ b/gst/gstpad.c @@ -6069,6 +6069,40 @@ no_task: } } +/** + * gst_pad_get_task_state: + * @pad: the #GstPad to get task state from + * + * Get @pad task state. If no task is currently + * set, GST_TASK_STOPPED is returned. + * + * Returns: The current state of @pad's task. + */ +GstTaskState +gst_pad_get_task_state (GstPad * pad) +{ + GstTask *task; + GstTaskState res; + + g_return_val_if_fail (GST_IS_PAD (pad), GST_TASK_STOPPED); + + GST_OBJECT_LOCK (pad); + task = GST_PAD_TASK (pad); + if (task == NULL) + goto no_task; + res = gst_task_get_state (task); + GST_OBJECT_UNLOCK (pad); + + return res; + +no_task: + { + GST_DEBUG_OBJECT (pad, "pad has no task"); + GST_OBJECT_UNLOCK (pad); + return GST_TASK_STOPPED; + } +} + /** * gst_pad_stop_task: * @pad: the #GstPad to stop the task of diff --git a/gst/gstpad.h b/gst/gstpad.h index 9c9bf5b410..2893ae0a78 100644 --- a/gst/gstpad.h +++ b/gst/gstpad.h @@ -1417,6 +1417,7 @@ gboolean gst_pad_start_task (GstPad *pad, GstTaskFunction func, gpointer user_data, GDestroyNotify notify); gboolean gst_pad_pause_task (GstPad *pad); gboolean gst_pad_stop_task (GstPad *pad); +GstTaskState gst_pad_get_task_state (GstPad *pad); /* internal links */ void gst_pad_set_iterate_internal_links_function_full (GstPad * pad, -- 2.34.1