From 16dfb8d4df43c9dc3f7b984953624c06362d220c Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 10 Oct 2005 14:23:26 +0000 Subject: [PATCH] docs/gst/gstreamer-sections.txt: Doc updates. Original commit message from CVS: 2005-10-10 Andy Wingo * docs/gst/gstreamer-sections.txt: Doc updates. * gst/gstutils.h: * gst/gstutils.c (g_static_rec_cond_timed_wait) (g_static_rec_cond_wait): Ported from state changes patch, while we wait on bug #317802 to be solved in a well-distributed GLib. --- ChangeLog | 2 ++ docs/gst/gstreamer-sections.txt | 3 +++ gst/gstutils.c | 59 +++++++++++++++++++++++++++++++++++++++++ gst/gstutils.h | 9 +++++++ 4 files changed, 73 insertions(+) diff --git a/ChangeLog b/ChangeLog index 40b9e5f..2be107a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2005-10-10 Andy Wingo + * docs/gst/gstreamer-sections.txt: Doc updates. + * gst/gstelement.c (gst_element_change_state_func): Renamed from gst_element_change_state, variable name changes. (gst_element_change_state): Split out of gst_element_set_state in diff --git a/docs/gst/gstreamer-sections.txt b/docs/gst/gstreamer-sections.txt index e930f23..70d1e0c 100644 --- a/docs/gst/gstreamer-sections.txt +++ b/docs/gst/gstreamer-sections.txt @@ -2033,7 +2033,10 @@ gst_util_dump_mem gst_util_uint64_scale gst_util_set_object_arg gst_util_set_value_from_string +g_static_rec_cond_timed_wait +g_static_rec_cond_wait +GST_COMPILE_STATIC_REC_COND_WAIT GST_HAVE_UNALIGNED_ACCESS diff --git a/gst/gstutils.c b/gst/gstutils.c index b8723d0..a366d6a 100644 --- a/gst/gstutils.c +++ b/gst/gstutils.c @@ -1816,6 +1816,65 @@ gst_object_default_error (GstObject * source, GError * error, gchar * debug) g_free (name); } +#ifdef GST_COMPILE_STATIC_REC_COND_WAIT + +#if GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P +# define g_system_thread_equal_simple(thread1, thread2) \ + ((thread1).dummy_pointer == (thread2).dummy_pointer) +# define g_system_thread_assign(dest, src) \ + ((dest).dummy_pointer = (src).dummy_pointer) +#else /* GLIB_SIZEOF_SYSTEM_THREAD != SIZEOF_VOID_P */ +# define g_system_thread_equal_simple(thread1, thread2) \ + (memcmp (&(thread1), &(thread2), GLIB_SIZEOF_SYSTEM_THREAD) == 0) +# define g_system_thread_assign(dest, src) \ + (memcpy (&(dest), &(src), GLIB_SIZEOF_SYSTEM_THREAD)) +#endif /* GLIB_SIZEOF_SYSTEM_THREAD == SIZEOF_VOID_P */ + +#define g_system_thread_equal(thread1, thread2) \ + (g_thread_functions_for_glib_use.thread_equal ? \ + g_thread_functions_for_glib_use.thread_equal (&(thread1), &(thread2)) :\ + g_system_thread_equal_simple((thread1), (thread2))) + +static GSystemThread zero_thread; + +gboolean +g_static_rec_cond_timed_wait (GCond * cond, + GStaticRecMutex * mutex, GTimeVal * end_time) +{ + GMutex *smutex; + guint depth; + GSystemThread self; + gboolean res; + + if (!g_thread_supported ()) + return FALSE; + + G_THREAD_UF (thread_self, (&self)); + + g_return_val_if_fail (g_system_thread_equal (self, mutex->owner), FALSE); + + depth = mutex->depth; + + g_system_thread_assign (mutex->owner, zero_thread); + mutex->depth = 0; + smutex = g_static_mutex_get_mutex (&mutex->mutex); + + res = g_cond_timed_wait (cond, smutex, end_time); + + g_system_thread_assign (mutex->owner, self); + mutex->depth = depth; + + return res; +} + +void +g_static_rec_cond_wait (GCond * cond, GStaticRecMutex * mutex) +{ + g_static_rec_cond_timed_wait (cond, mutex, NULL); +} + +#endif /* GST_COMPILE_STATIC_REC_COND_WAIT */ + /** * gst_bin_add_many: * @bin: the bin to add the elements to diff --git a/gst/gstutils.h b/gst/gstutils.h index 3d84d65..3bd1acb 100644 --- a/gst/gstutils.h +++ b/gst/gstutils.h @@ -457,6 +457,15 @@ GST_BOILERPLATE_FULL (type, type_as_function, parent_type, \ void gst_object_default_error (GstObject * source, GError * error, gchar * debug); +/* rec mutex */ +#ifndef g_static_rec_cond_wait +#define GST_COMPILE_STATIC_REC_COND_WAIT +void g_static_rec_cond_wait (GCond *cond, + GStaticRecMutex *mutex); +gboolean g_static_rec_cond_timed_wait (GCond *cond, + GStaticRecMutex *mutex, + GTimeVal *end_time); +#endif /* element functions */ GstFlowReturn gst_element_abort_preroll (GstElement *element); -- 2.7.4