]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - glsdk/gst-plugins-ugly0-10.git/commitdiff
Work around deprecated thread API in glib master
authorTim-Philipp Müller <tim.muller@collabora.co.uk>
Mon, 12 Dec 2011 11:33:31 +0000 (11:33 +0000)
committerNikhil Devshatwar <a0132237@ti.com>
Fri, 17 May 2013 09:40:49 +0000 (15:10 +0530)
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 can't change most of
these in 0.10 because they're part of our API and ABI.

Suppress deprecation warnings in selected files, mostly for
g_static_rec_mutex_*. StaticRecMutex is part of our API/ABI,
not much we can do here in 0.10.

gst-libs/gst/Makefile.am
gst-libs/gst/glib-compat-private.h [new file with mode: 0644]
gst/asfdemux/gstasfdemux.c
gst/mpegaudioparse/gstmpegaudioparse.c
gst/realmedia/rademux.c
gst/realmedia/rdtmanager.c
gst/realmedia/rmdemux.c

index 2df58b3b9b4e152a160814cbc82366f1b1a7bcc3..17887bf36643ea6bcb9a7ec8df4b735a7da34e09 100644 (file)
@@ -1 +1 @@
-noinst_HEADERS = gst-i18n-plugin.h gettext.h
+noinst_HEADERS = gst-i18n-plugin.h gettext.h glib-compat-private.h
diff --git a/gst-libs/gst/glib-compat-private.h b/gst-libs/gst/glib-compat-private.h
new file mode 100644 (file)
index 0000000..b9248e6
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * glib-compat.c
+ * Functions copied from glib 2.10
+ *
+ * Copyright 2005 David Schleef <ds@schleef.org>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifndef __GLIB_COMPAT_PRIVATE_H__
+#define __GLIB_COMPAT_PRIVATE_H__
+
+#include <glib.h>
+
+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
index d205010155913347759bd5eb05c783b5000609a3..743e432a2b42ebc35229b9ba89abe28375a2ce19 100644 (file)
 #include "config.h"
 #endif
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include <gst/gstutils.h>
 #include <gst/base/gstbytereader.h>
 #include <gst/riff/riff-media.h>
index b45165381f22c562aaf1f29cae3af35127bf8f49..bafefabd124cd246c9ec44374f59a301476a7a3c 100644 (file)
@@ -40,6 +40,8 @@
 
 #include "gstmpegaudioparse.h"
 
+#include <gst/glib-compat-private.h>
+
 GST_DEBUG_CATEGORY_STATIC (mp3parse_debug);
 #define GST_CAT_DEFAULT mp3parse_debug
 
index fdbfd73e74f3541bbb792ab367a4275f295173af..7e986a2e1144a767efb360ebd213f0f38e76ea96 100644 (file)
 #include "config.h"
 #endif
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "rademux.h"
 #include "rmdemux.h"
 #include "rmutils.h"
index 29c8b6696c23e00bfbfb204e1fd4934d2a92c2b2..a09e9f1e513beb1b58518d8baa5136faf44b15c9 100644 (file)
@@ -56,6 +56,8 @@
 #include "rdtmanager.h"
 #include "rdtjitterbuffer.h"
 
+#include <gst/glib-compat-private.h>
+
 #include <stdio.h>
 
 GST_DEBUG_CATEGORY_STATIC (rdtmanager_debug);
index 9ee028eb6522ea5b0fe3efb7cbf5a84072a5a9c2..c17c8770f8a3dc659ecfd81a8128dff8324fbe37 100644 (file)
 #  include "config.h"
 #endif
 
+/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
+ * with newer GLib versions (>= 2.31.0) */
+#define GLIB_DISABLE_DEPRECATION_WARNINGS
+
 #include "rmdemux.h"
 #include "rmutils.h"