mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-21 07:46:38 +00:00
GstPad: install thread callbacks of the task
Install thread status callbacks on the task object of a pad and post STREAM_STATUS messages.
This commit is contained in:
parent
d4a9ece0b1
commit
540560a758
1 changed files with 50 additions and 0 deletions
50
gst/gstpad.c
50
gst/gstpad.c
|
@ -4801,6 +4801,55 @@ gst_pad_get_element_private (GstPad * pad)
|
|||
return pad->element_private;
|
||||
}
|
||||
|
||||
static void
|
||||
do_stream_status (GstPad * pad, GstStreamStatusType type,
|
||||
GThread * thread, GstTask * task)
|
||||
{
|
||||
GstElement *parent;
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "doing stream-status %d", type);
|
||||
|
||||
if ((parent = GST_ELEMENT_CAST (gst_pad_get_parent (pad)))) {
|
||||
if (GST_IS_ELEMENT (parent)) {
|
||||
GstMessage *message;
|
||||
GValue value = { 0 };
|
||||
|
||||
message = gst_message_new_stream_status (GST_OBJECT_CAST (pad),
|
||||
type, parent);
|
||||
|
||||
g_value_init (&value, GST_TYPE_TASK);
|
||||
g_value_set_object (&value, task);
|
||||
gst_message_set_stream_status_object (message, &value);
|
||||
g_value_unset (&value);
|
||||
|
||||
GST_DEBUG_OBJECT (pad, "posting stream-status %d", type);
|
||||
gst_element_post_message (parent, message);
|
||||
}
|
||||
gst_object_unref (parent);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pad_enter_thread (GstTask * task, GThread * thread, gpointer user_data)
|
||||
{
|
||||
do_stream_status (GST_PAD_CAST (user_data), GST_STREAM_STATUS_TYPE_ENTER,
|
||||
thread, task);
|
||||
}
|
||||
|
||||
static void
|
||||
pad_leave_thread (GstTask * task, GThread * thread, gpointer user_data)
|
||||
{
|
||||
do_stream_status (GST_PAD_CAST (user_data), GST_STREAM_STATUS_TYPE_LEAVE,
|
||||
thread, task);
|
||||
}
|
||||
|
||||
static GstTaskThreadCallbacks thr_callbacks = {
|
||||
NULL,
|
||||
pad_enter_thread,
|
||||
pad_leave_thread,
|
||||
NULL
|
||||
};
|
||||
|
||||
/**
|
||||
* gst_pad_start_task:
|
||||
* @pad: the #GstPad to start the task of
|
||||
|
@ -4830,6 +4879,7 @@ gst_pad_start_task (GstPad * pad, GstTaskFunction func, gpointer data)
|
|||
if (task == NULL) {
|
||||
task = gst_task_create (func, data);
|
||||
gst_task_set_lock (task, GST_PAD_GET_STREAM_LOCK (pad));
|
||||
gst_task_set_thread_callbacks (task, &thr_callbacks, pad, NULL);
|
||||
GST_PAD_TASK (pad) = task;
|
||||
GST_DEBUG_OBJECT (pad, "created task");
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue