From 66f6e1288845ab21787b1fcd4605a90a5b552bb8 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 12 Dec 2011 02:30:45 +0000 Subject: [PATCH] Work around deprecated thread API in glib master Add private replacements for deprecated functions such as g_mutex_new(), g_mutex_free(), g_cond_new() etc., mostly to avoid the deprecation warnings. We'll change these over to the new API once we depend on glib >= 2.32. --- Makefile.am | 1 + ext/jack/gstjackaudioclient.c | 2 + ext/pulse/pulseaudiosink.c | 1 + ext/pulse/pulsesink.c | 2 + ext/soup/gstsouphttpclientsink.c | 2 + gst-libs/gst/glib-compat-private.h | 120 ++++++++++++++++++++++++++++++++++++ gst/audiofx/audiochebband.c | 2 + gst/audiofx/audiocheblimit.c | 2 + gst/audiofx/audiofirfilter.c | 2 + gst/audiofx/audioiirfilter.c | 2 + gst/audiofx/audiowsincband.c | 2 + gst/audiofx/audiowsinclimit.c | 2 + gst/equalizer/gstiirequalizer.c | 2 + gst/imagefreeze/gstimagefreeze.c | 2 + gst/rtpmanager/gstrtpbin.c | 2 + gst/rtpmanager/gstrtpjitterbuffer.c | 2 + gst/rtpmanager/gstrtpsession.c | 2 + gst/rtpmanager/rtpsession.c | 2 + gst/shapewipe/gstshapewipe.c | 1 + gst/udp/gstmultiudpsink.c | 5 +- gst/videobox/gstvideobox.c | 2 + gst/videocrop/gstaspectratiocrop.c | 5 +- gst/videomixer/videomixer.c | 2 + gst/videomixer/videomixer2.c | 2 + sys/oss4/oss4-mixer.c | 1 + sys/v4l2/gstv4l2bufferpool.c | 1 + sys/v4l2/gstv4l2xoverlay.c | 1 + sys/ximage/gstximagesrc.c | 2 + 28 files changed, 170 insertions(+), 4 deletions(-) create mode 100644 gst-libs/gst/glib-compat-private.h diff --git a/Makefile.am b/Makefile.am index fb78f5d..862126d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -38,6 +38,7 @@ DISTCLEANFILES = _stdint.h noinst_HEADERS = \ gst-libs/gst/gettext.h \ gst-libs/gst/gst-i18n-plugin.h + gst-libs/gst/glib-compat-private.h ACLOCAL_AMFLAGS = -I m4 -I common/m4 diff --git a/ext/jack/gstjackaudioclient.c b/ext/jack/gstjackaudioclient.c index 1789edb..2bb3555 100644 --- a/ext/jack/gstjackaudioclient.c +++ b/ext/jack/gstjackaudioclient.c @@ -23,6 +23,8 @@ #include "gstjackaudioclient.h" +#include + GST_DEBUG_CATEGORY_STATIC (gst_jack_audio_client_debug); #define GST_CAT_DEFAULT gst_jack_audio_client_debug diff --git a/ext/pulse/pulseaudiosink.c b/ext/pulse/pulseaudiosink.c index 15f3bf1..cd9f7d9 100644 --- a/ext/pulse/pulseaudiosink.c +++ b/ext/pulse/pulseaudiosink.c @@ -53,6 +53,7 @@ #include #include +#include #include #include "pulsesink.h" diff --git a/ext/pulse/pulsesink.c b/ext/pulse/pulsesink.c index cfab338..3c61770 100644 --- a/ext/pulse/pulsesink.c +++ b/ext/pulse/pulsesink.c @@ -58,6 +58,8 @@ #include /* only used for GST_PLUGINS_BASE_VERSION_* */ +#include + #include "pulsesink.h" #include "pulseutil.h" diff --git a/ext/soup/gstsouphttpclientsink.c b/ext/soup/gstsouphttpclientsink.c index 13cc805..5f3d47e 100644 --- a/ext/soup/gstsouphttpclientsink.c +++ b/ext/soup/gstsouphttpclientsink.c @@ -42,6 +42,8 @@ #include #include "gstsouphttpclientsink.h" +#include + GST_DEBUG_CATEGORY_STATIC (souphttpclientsink_dbg); #define GST_CAT_DEFAULT souphttpclientsink_dbg diff --git a/gst-libs/gst/glib-compat-private.h b/gst-libs/gst/glib-compat-private.h new file mode 100644 index 0000000..d143d32 --- /dev/null +++ b/gst-libs/gst/glib-compat-private.h @@ -0,0 +1,120 @@ +/* + * glib-compat.c + * Functions copied from glib 2.10 + * + * Copyright 2005 David Schleef + */ + +#ifndef __GLIB_COMPAT_PRIVATE_H__ +#define __GLIB_COMPAT_PRIVATE_H__ + +#include + +G_BEGIN_DECLS + +#if !GLIB_CHECK_VERSION(2,25,0) + +#if defined (_MSC_VER) && !defined(_WIN64) +typedef struct _stat32 GStatBuf; +#else +typedef struct stat GStatBuf; +#endif + +#endif + +#if GLIB_CHECK_VERSION(2,26,0) +#define GLIB_HAS_GDATETIME +#endif + +/* See bug #651514 */ +#if GLIB_CHECK_VERSION(2,29,5) +#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_pointer_compare_and_exchange ((a),(b),(c)) +#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_int_compare_and_exchange ((a),(b),(c)) +#else +#define G_ATOMIC_POINTER_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_pointer_compare_and_exchange ((volatile gpointer *)(a),(b),(c)) +#define G_ATOMIC_INT_COMPARE_AND_EXCHANGE(a,b,c) \ + g_atomic_int_compare_and_exchange ((volatile int *)(a),(b),(c)) +#endif + +/* See bug #651514 */ +#if GLIB_CHECK_VERSION(2,29,5) +#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_add ((a),(b)) +#else +#define G_ATOMIC_INT_ADD(a,b) g_atomic_int_exchange_and_add ((a),(b)) +#endif + +/* copies */ + +#if GLIB_CHECK_VERSION (2, 31, 0) +#define g_mutex_new gst_g_mutex_new +static inline GMutex * +gst_g_mutex_new (void) +{ + GMutex *mutex = g_slice_new (GMutex); + g_mutex_init (mutex); + return mutex; +} +#define g_mutex_free gst_g_mutex_free +static inline void +gst_g_mutex_free (GMutex *mutex) +{ + g_mutex_clear (mutex); + g_slice_free (GMutex, mutex); +} +#define g_static_rec_mutex_init gst_g_static_rec_mutex_init +static inline void +gst_g_static_rec_mutex_init (GStaticRecMutex *mutex) +{ + static const GStaticRecMutex init_mutex = G_STATIC_REC_MUTEX_INIT; + + *mutex = init_mutex; +} +#define g_cond_new gst_g_cond_new +static inline GCond * +gst_g_cond_new (void) +{ + GCond *cond = g_slice_new (GCond); + g_cond_init (cond); + return cond; +} +#define g_cond_free gst_g_cond_free +static inline void +gst_g_cond_free (GCond *cond) +{ + g_cond_clear (cond); + g_slice_free (GCond, cond); +} +#define g_cond_timed_wait gst_g_cond_timed_wait +static inline gboolean +gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time) +{ + gint64 end_time; + + if (abs_time == NULL) { + g_cond_wait (cond, mutex); + return TRUE; + } + + end_time = abs_time->tv_sec; + end_time *= 1000000; + end_time += abs_time->tv_usec; + + /* would be nice if we had clock_rtoffset, but that didn't seem to + * make it into the kernel yet... + */ + /* if CLOCK_MONOTONIC is not defined then g_get_montonic_time() and + * g_get_real_time() are returning the same clock and we'd add ~0 + */ + end_time += g_get_monotonic_time () - g_get_real_time (); + return g_cond_wait_until (cond, mutex, end_time); +} +#endif /* GLIB_CHECK_VERSION (2, 31, 0) */ + +/* adaptations */ + +G_END_DECLS + +#endif diff --git a/gst/audiofx/audiochebband.c b/gst/audiofx/audiochebband.c index 89a950c..08c1acf 100644 --- a/gst/audiofx/audiochebband.c +++ b/gst/audiofx/audiochebband.c @@ -82,6 +82,8 @@ #include "audiochebband.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_audio_cheb_band_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/audiofx/audiocheblimit.c b/gst/audiofx/audiocheblimit.c index 8d51fbb..b7bb90b 100644 --- a/gst/audiofx/audiocheblimit.c +++ b/gst/audiofx/audiocheblimit.c @@ -78,6 +78,8 @@ #include "audiocheblimit.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_audio_cheb_limit_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/audiofx/audiofirfilter.c b/gst/audiofx/audiofirfilter.c index b6102ae..bd5a51b 100644 --- a/gst/audiofx/audiofirfilter.c +++ b/gst/audiofx/audiofirfilter.c @@ -57,6 +57,8 @@ #include "audiofirfilter.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_audio_fir_filter_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/audiofx/audioiirfilter.c b/gst/audiofx/audioiirfilter.c index bac16b2..ff5f9ca 100644 --- a/gst/audiofx/audioiirfilter.c +++ b/gst/audiofx/audioiirfilter.c @@ -53,6 +53,8 @@ #include "audioiirfilter.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_audio_iir_filter_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/audiofx/audiowsincband.c b/gst/audiofx/audiowsincband.c index 07356e2..3f94988 100644 --- a/gst/audiofx/audiowsincband.c +++ b/gst/audiofx/audiowsincband.c @@ -64,6 +64,8 @@ #include "audiowsincband.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_gst_audio_wsincband_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/audiofx/audiowsinclimit.c b/gst/audiofx/audiowsinclimit.c index aa0cf4b..ad60569 100644 --- a/gst/audiofx/audiowsinclimit.c +++ b/gst/audiofx/audiowsinclimit.c @@ -64,6 +64,8 @@ #include "audiowsinclimit.h" +#include "gst/glib-compat-private.h" + #define GST_CAT_DEFAULT gst_audio_wsinclimit_debug GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT); diff --git a/gst/equalizer/gstiirequalizer.c b/gst/equalizer/gstiirequalizer.c index c640124..d66db1a 100644 --- a/gst/equalizer/gstiirequalizer.c +++ b/gst/equalizer/gstiirequalizer.c @@ -31,6 +31,8 @@ #include "gstiirequalizer3bands.h" #include "gstiirequalizer10bands.h" +#include "gst/glib-compat-private.h" + GST_DEBUG_CATEGORY (equalizer_debug); #define GST_CAT_DEFAULT equalizer_debug diff --git a/gst/imagefreeze/gstimagefreeze.c b/gst/imagefreeze/gstimagefreeze.c index 77785ca..312f4aa 100644 --- a/gst/imagefreeze/gstimagefreeze.c +++ b/gst/imagefreeze/gstimagefreeze.c @@ -41,6 +41,8 @@ #include "config.h" #endif +#include + #include "gstimagefreeze.h" static void gst_image_freeze_finalize (GObject * object); diff --git a/gst/rtpmanager/gstrtpbin.c b/gst/rtpmanager/gstrtpbin.c index b322f8e..ef00a85 100644 --- a/gst/rtpmanager/gstrtpbin.c +++ b/gst/rtpmanager/gstrtpbin.c @@ -129,6 +129,8 @@ #include "gstrtpsession.h" #include "gstrtpjitterbuffer.h" +#include + GST_DEBUG_CATEGORY_STATIC (gst_rtp_bin_debug); #define GST_CAT_DEFAULT gst_rtp_bin_debug diff --git a/gst/rtpmanager/gstrtpjitterbuffer.c b/gst/rtpmanager/gstrtpjitterbuffer.c index c69d477..4c72fb6 100644 --- a/gst/rtpmanager/gstrtpjitterbuffer.c +++ b/gst/rtpmanager/gstrtpjitterbuffer.c @@ -67,6 +67,8 @@ #include "rtpjitterbuffer.h" #include "rtpstats.h" +#include + GST_DEBUG_CATEGORY (rtpjitterbuffer_debug); #define GST_CAT_DEFAULT (rtpjitterbuffer_debug) diff --git a/gst/rtpmanager/gstrtpsession.c b/gst/rtpmanager/gstrtpsession.c index 6828438..31f9a73 100644 --- a/gst/rtpmanager/gstrtpsession.c +++ b/gst/rtpmanager/gstrtpsession.c @@ -114,6 +114,8 @@ #include +#include + #include "gstrtpbin-marshal.h" #include "gstrtpsession.h" #include "rtpsession.h" diff --git a/gst/rtpmanager/rtpsession.c b/gst/rtpmanager/rtpsession.c index f499106..eed96ac 100644 --- a/gst/rtpmanager/rtpsession.c +++ b/gst/rtpmanager/rtpsession.c @@ -23,6 +23,8 @@ #include #include +#include + #include "gstrtpbin-marshal.h" #include "rtpsession.h" diff --git a/gst/shapewipe/gstshapewipe.c b/gst/shapewipe/gstshapewipe.c index 3397dda..b8c91b5 100644 --- a/gst/shapewipe/gstshapewipe.c +++ b/gst/shapewipe/gstshapewipe.c @@ -46,6 +46,7 @@ #include #include +#include #include "gstshapewipe.h" diff --git a/gst/udp/gstmultiudpsink.c b/gst/udp/gstmultiudpsink.c index a2d74a7..7a35aae 100644 --- a/gst/udp/gstmultiudpsink.c +++ b/gst/udp/gstmultiudpsink.c @@ -41,6 +41,8 @@ #include #include +#include "gst/glib-compat-private.h" + GST_DEBUG_CATEGORY_STATIC (multiudpsink_debug); #define GST_CAT_DEFAULT (multiudpsink_debug) @@ -172,8 +174,7 @@ gst_multiudpsink_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - gst_element_class_add_static_pad_template (element_class, - &sink_template); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_set_details_simple (element_class, "UDP packet sender", "Sink/Network", diff --git a/gst/videobox/gstvideobox.c b/gst/videobox/gstvideobox.c index 691c5f1..9d31184 100644 --- a/gst/videobox/gstvideobox.c +++ b/gst/videobox/gstvideobox.c @@ -66,6 +66,8 @@ #include +#include "gst/glib-compat-private.h" + GST_DEBUG_CATEGORY_STATIC (videobox_debug); #define GST_CAT_DEFAULT videobox_debug diff --git a/gst/videocrop/gstaspectratiocrop.c b/gst/videocrop/gstaspectratiocrop.c index b37217a..150df37 100644 --- a/gst/videocrop/gstaspectratiocrop.c +++ b/gst/videocrop/gstaspectratiocrop.c @@ -43,6 +43,8 @@ #include "gstaspectratiocrop.h" +#include "gst/glib-compat-private.h" + GST_DEBUG_CATEGORY_STATIC (aspect_ratio_crop_debug); #define GST_CAT_DEFAULT aspect_ratio_crop_debug @@ -169,8 +171,7 @@ gst_aspect_ratio_crop_base_init (gpointer g_class) "Crops video into a user-defined aspect-ratio", "Thijs Vermeir "); - gst_element_class_add_static_pad_template (element_class, - &sink_template); + gst_element_class_add_static_pad_template (element_class, &sink_template); gst_element_class_add_static_pad_template (element_class, &src_template); } diff --git a/gst/videomixer/videomixer.c b/gst/videomixer/videomixer.c index 2c78c61..5a49b39 100644 --- a/gst/videomixer/videomixer.c +++ b/gst/videomixer/videomixer.c @@ -89,6 +89,8 @@ #include "videomixer.h" #include "videomixer2.h" +#include "gst/glib-compat-private.h" + #ifdef DISABLE_ORC #define orc_memset memset #else diff --git a/gst/videomixer/videomixer2.c b/gst/videomixer/videomixer2.c index fde327a..b876c22 100644 --- a/gst/videomixer/videomixer2.c +++ b/gst/videomixer/videomixer2.c @@ -93,6 +93,8 @@ #include +#include "gst/glib-compat-private.h" + #ifdef DISABLE_ORC #define orc_memset memset #else diff --git a/sys/oss4/oss4-mixer.c b/sys/oss4/oss4-mixer.c index fa81ecc..87f7ca6 100644 --- a/sys/oss4/oss4-mixer.c +++ b/sys/oss4/oss4-mixer.c @@ -54,6 +54,7 @@ #include #include +#include "gst/glib-compat-private.h" #include diff --git a/sys/v4l2/gstv4l2bufferpool.c b/sys/v4l2/gstv4l2bufferpool.c index e976ec5..b81c6a4 100644 --- a/sys/v4l2/gstv4l2bufferpool.c +++ b/sys/v4l2/gstv4l2bufferpool.c @@ -39,6 +39,7 @@ #endif #include "v4l2_calls.h" #include "gst/gst-i18n-plugin.h" +#include /* videodev2.h is not versioned and we can't easily check for the presence * of enum values at compile time, but the V4L2_CAP_VIDEO_OUTPUT_OVERLAY define diff --git a/sys/v4l2/gstv4l2xoverlay.c b/sys/v4l2/gstv4l2xoverlay.c index 80f114d..60d0919 100644 --- a/sys/v4l2/gstv4l2xoverlay.c +++ b/sys/v4l2/gstv4l2xoverlay.c @@ -40,6 +40,7 @@ #include "v4l2_calls.h" #include "gst/gst-i18n-plugin.h" +#include struct _GstV4l2Xv { diff --git a/sys/ximage/gstximagesrc.c b/sys/ximage/gstximagesrc.c index b0d99ad..36c0b44 100644 --- a/sys/ximage/gstximagesrc.c +++ b/sys/ximage/gstximagesrc.c @@ -49,6 +49,8 @@ #include #include +#include "gst/glib-compat-private.h" + GST_DEBUG_CATEGORY_STATIC (gst_debug_ximage_src); #define GST_CAT_DEFAULT gst_debug_ximage_src -- 2.7.4