static void
gst_pipeline_init (GstPipeline *pipeline)
{
- const gchar *schedname;
GstScheduler *scheduler;
- /* we're a manager by default */
+ /* pipelines are managing bins */
GST_FLAG_SET (pipeline, GST_BIN_FLAG_MANAGER);
- schedname = gst_scheduler_factory_get_default_name ();
-
- scheduler = gst_scheduler_factory_make (schedname, GST_ELEMENT (pipeline));
+ /* get an instance of the default scheduler */
+ scheduler = gst_scheduler_factory_make (NULL, GST_ELEMENT (pipeline));
- GST_ELEMENT_SCHED (pipeline) = scheduler;
-
- gst_object_ref (GST_OBJECT (scheduler));
- gst_object_sink (GST_OBJECT (scheduler));
-
gst_scheduler_setup (scheduler);
}
if (GST_ELEMENT_SCHED (pipeline)) {
gst_scheduler_reset (GST_ELEMENT_SCHED (pipeline));
gst_object_unref (GST_OBJECT (GST_ELEMENT_SCHED (pipeline)));
+ GST_ELEMENT_SCHED (pipeline) = NULL;
}
}
* @parent: the parent element of this scheduler
*
* Create a new #GstScheduler instance from the
- * given schedulerfactory with the given parent.
+ * given schedulerfactory with the given parent. @parent will
+ * have its scheduler set to the returned #GstScheduler instance.
*
- * Returns: A new #GstScheduler instance.
+ * Returns: A new #GstScheduler instance with a reference count of %1.
*/
GstScheduler*
gst_scheduler_factory_create (GstSchedulerFactory *factory, GstElement *parent)
GstScheduler *new = NULL;
g_return_val_if_fail (factory != NULL, NULL);
+ g_return_val_if_fail (parent != NULL, NULL);
if (gst_plugin_feature_ensure_loaded (GST_PLUGIN_FEATURE (factory))) {
g_return_val_if_fail (factory->type != 0, NULL);
new = GST_SCHEDULER (g_object_new (factory->type, NULL));
new->parent = parent;
+
+ GST_ELEMENT_SCHED (parent) = new;
+
+ /* let's refcount the scheduler */
+ gst_object_ref (GST_OBJECT (new));
+ gst_object_sink (GST_OBJECT (new));
}
return new;
* @parent: the parent element of this scheduler
*
* Create a new #GstScheduler instance from the
- * schedulerfactory with the given name and parent.
+ * schedulerfactory with the given name and parent. @parent will
+ * have its scheduler set to the returned #GstScheduler instance.
+ * If %NULL is passed as @name, the default scheduler name will
+ * be used.
*
- * Returns: A new #GstScheduler instance.
+ * Returns: A new #GstScheduler instance with a reference count of %1.
*/
GstScheduler*
gst_scheduler_factory_make (const gchar *name, GstElement *parent)
{
GstSchedulerFactory *factory;
- g_return_val_if_fail (name != NULL, NULL);
-
- factory = gst_scheduler_factory_find (name);
+ if (name)
+ factory = gst_scheduler_factory_find (name);
+ else
+ factory = gst_scheduler_factory_find (gst_scheduler_factory_get_default_name ());
if (factory == NULL)
return NULL;
#ifndef GST_DISABLE_LOADSAVE
gstobject_class->save_thyself = GST_DEBUG_FUNCPTR (gst_thread_save_thyself);
- gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR(gst_thread_restore_thyself);
+ gstobject_class->restore_thyself = GST_DEBUG_FUNCPTR (gst_thread_restore_thyself);
#endif
gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_thread_change_state);
-/* gstbin_class->schedule = gst_thread_schedule_dummy; */
-
gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_thread_set_property);
gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_thread_get_property);
static void
gst_thread_init (GstThread *thread)
{
- const gchar *schedname;
GstScheduler *scheduler;
GST_DEBUG (GST_CAT_THREAD, "initializing thread");
- /* we're a manager by default */
+ /* threads are managing bins and iterate themselves */
/* CR1: the GstBin code checks these flags */
GST_FLAG_SET (thread, GST_BIN_FLAG_MANAGER);
GST_FLAG_SET (thread, GST_BIN_SELF_SCHEDULABLE);
- schedname = gst_scheduler_factory_get_default_name ();
-
- scheduler = gst_scheduler_factory_make (schedname, GST_ELEMENT (thread));
-
- GST_ELEMENT_SCHED (thread) = scheduler;
-
- gst_object_ref (GST_OBJECT (scheduler));
- gst_object_sink (GST_OBJECT (scheduler));
+ scheduler = gst_scheduler_factory_make (NULL, GST_ELEMENT (thread));
thread->lock = g_mutex_new ();
thread->cond = g_cond_new ();