mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-23 16:50:47 +00:00
gst/gstsystemclock.c (gst_system_clock_init): Unlock the clock if its socks fill with rocks.
Original commit message from CVS: 2005-06-20 Andy Wingo <wingo@pobox.com> * 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.
This commit is contained in:
parent
5910c2f938
commit
3468457954
2 changed files with 16 additions and 14 deletions
|
@ -1,3 +1,10 @@
|
|||
2005-06-20 Andy Wingo <wingo@pobox.com>
|
||||
|
||||
* 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 <tim at centricular dot net>
|
||||
|
||||
* gst/gsturi.c: (gst_element_make_from_uri):
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue