* is typically done when the demuxer can perform random access on the upstream
* peer element for improved performance.
*
- * Although convenience functions exist on #GstPad to start/pause/stop tasks, it
+ * Although convenience functions exist on #GstPad to start/pause/stop tasks, it
* might sometimes be needed to create a #GstTask manually if it is not related to
* a #GstPad.
*
#include "gstinfo.h"
#include "gsttask.h"
+#ifdef HAVE_SYS_PRCTL_H
+#include <sys/prctl.h>
+#endif
+
GST_DEBUG_CATEGORY_STATIC (task_debug);
#define GST_CAT_DEFAULT (task_debug)
G_OBJECT_CLASS (gst_task_parent_class)->finalize (object);
}
+/* should be called with the object LOCK */
+static void
+gst_task_configure_name (GstTask * task)
+{
+#ifdef HAVE_SYS_PRCTL_H
+ const gchar *name;
+ gchar thread_name[17] = { 0, };
+
+ name = GST_OBJECT_NAME (task);
+
+ /* set the thread name to something easily identifiable */
+ if (!snprintf (thread_name, 17, "%s", GST_STR_NULL (name))) {
+ GST_DEBUG_OBJECT (task, "Could not create thread name for '%s'", name);
+ } else {
+ GST_DEBUG_OBJECT (task, "Setting thread name to '%s'", thread_name);
+ if (prctl (PR_SET_NAME, (unsigned long int) thread_name))
+ GST_DEBUG_OBJECT (task, "Failed to set thread name");
+ }
+#endif
+}
+
static void
gst_task_func (GstTask * task)
{
/* locking order is TASK_LOCK, LOCK */
g_static_rec_mutex_lock (lock);
GST_OBJECT_LOCK (task);
+ /* configure the thread name now */
+ gst_task_configure_name (task);
+
while (G_LIKELY (task->state != GST_TASK_STOPPED)) {
while (G_UNLIKELY (task->state == GST_TASK_PAUSED)) {
gint t;
g_thread_set_priority (tself, G_THREAD_PRIORITY_NORMAL);
}
/* now we allow messing with the lock again by setting the running flag to
- * FALSE. Together with the SIGNAL this is the sign for the _join() to
- * complete.
+ * FALSE. Together with the SIGNAL this is the sign for the _join() to
+ * complete.
* Note that we still have not dropped the final ref on the task. We could
* check here if there is a pending join() going on and drop the last ref
* before releasing the lock as we can be sure that a ref is held by the
* The task will automatically be stopped with this call.
*
* This function cannot be called from within a task function as this
- * would cause a deadlock. The function will detect this and print a
+ * would cause a deadlock. The function will detect this and print a
* g_warning.
*
* Returns: %TRUE if the task could be joined.