diff --git a/ChangeLog b/ChangeLog index 1283ea8f66..923d280f42 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2005-06-20 Andy Wingo + + * gst/gstsystemclock.c (gst_system_clock_init): Unlock the clock + if its socks fill with rocks. + (gst_system_clock_obtain): Set the name on object construction. + Avoid double-checked locking. + 2005-06-20 Tim-Philipp Müller * gst/gsturi.c: (gst_element_make_from_uri): diff --git a/gst/gstsystemclock.c b/gst/gstsystemclock.c index 2efef87af1..5b62baf7eb 100644 --- a/gst/gstsystemclock.c +++ b/gst/gstsystemclock.c @@ -122,6 +122,7 @@ gst_system_clock_init (GstSystemClock * clock) no_thread: { g_warning ("could not create async clock thread: %s", error->message); + GST_UNLOCK (clock); } } @@ -141,7 +142,7 @@ gst_system_clock_dispose (GObject * object) } /** - * gst_system_clock_obtain + * gst_system_clock_obtain: * * Get a handle to the default system clock. The refcount of the * clock will be increased so you need to unref the clock after @@ -154,24 +155,18 @@ gst_system_clock_dispose (GObject * object) GstClock * gst_system_clock_obtain (void) { - GstClock *clock = _the_system_clock; + GstClock *clock; + + g_static_mutex_lock (&_gst_sysclock_mutex); + clock = _the_system_clock; if (clock == NULL) { - g_static_mutex_lock (&_gst_sysclock_mutex); - if (_the_system_clock != NULL) { - clock = _the_system_clock; - g_static_mutex_unlock (&_gst_sysclock_mutex); - GST_CAT_DEBUG (GST_CAT_CLOCK, "returning static system clock"); - goto have_clock; - } - GST_CAT_DEBUG (GST_CAT_CLOCK, "creating new static system clock"); /* FIXME: the only way to clean this up is to have a gst_exit() * function; until then, the program will always end with the sysclock * at refcount 1 */ - clock = GST_CLOCK (g_object_new (GST_TYPE_SYSTEM_CLOCK, NULL)); - - gst_object_set_name (GST_OBJECT (clock), "GstSystemClock"); + clock = g_object_new (GST_TYPE_SYSTEM_CLOCK, + "name", "GstSystemClock", NULL); /* we created the global clock; take ownership so * we can hand out instances later */ @@ -181,10 +176,10 @@ gst_system_clock_obtain (void) _the_system_clock = clock; g_static_mutex_unlock (&_gst_sysclock_mutex); } else { + g_static_mutex_unlock (&_gst_sysclock_mutex); GST_CAT_DEBUG (GST_CAT_CLOCK, "returning static system clock"); } -have_clock: /* we ref it since we are a clock factory. */ gst_object_ref (GST_OBJECT (clock)); return clock;