*** gstreamer-0.8.10.old/gst/schedulers/gstoptimalscheduler.c	Wed Apr 27 12:27:44 2005
--- gstreamer-0.8.10/gst/schedulers/gstoptimalscheduler.c	Mon Jul 25 14:21:51 2005
*************** static GstSchedulerState gst_opt_schedul
*** 355,360 ****
--- 355,361 ----
  static void gst_opt_scheduler_show (GstScheduler * sched);
  
  static GstSchedulerClass *parent_class = NULL;
+ static GMutex *ref_lock;
  
  static GType
  gst_opt_scheduler_get_type (void)
*************** gst_opt_scheduler_class_init (GstOptSche
*** 433,438 ****
--- 434,441 ----
  #ifdef USE_COTHREADS
    do_cothreads_init (NULL);
  #endif
+ 
+   ref_lock = g_mutex_new();
  }
  
  static void
*************** schedule_group (GstOptSchedulerGroup * g
*** 1208,1214 ****
--- 1211,1219 ----
       * elements. */
      if (group->entry && GST_ELEMENT_IS_DECOUPLED (group->entry)) {
        entry = group->entry;
+       g_mutex_lock(ref_lock);
        gst_object_ref (GST_OBJECT (entry));
+       g_mutex_unlock(ref_lock);
      }
  
      for (l = lcopy; l; l = l->next) {
*************** schedule_group (GstOptSchedulerGroup * g
*** 1229,1236 ****
  
        gst_object_unref (GST_OBJECT (e));
      }
!     if (entry)
        gst_object_unref (GST_OBJECT (entry));
      g_slist_free (lcopy);
    }
    return TRUE;
--- 1234,1244 ----
  
        gst_object_unref (GST_OBJECT (e));
      }
!     if (entry) {
!       g_mutex_lock(ref_lock);
        gst_object_unref (GST_OBJECT (entry));
+       g_mutex_unlock(ref_lock);
+     }
      g_slist_free (lcopy);
    }
    return TRUE;
