Remove compatibility code cruft for old GLib versions

This commit is contained in:
Tim-Philipp Müller 2012-01-18 17:22:21 +00:00
parent fc0e53ac61
commit 576bbb4fd8
24 changed files with 8 additions and 248 deletions

View file

@ -496,11 +496,7 @@ gst_alsa_mixer_new (const char *device, GstAlsaMixerDirection dir)
if (pipe (ret->pfd) == -1)
goto error;
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_rec_mutex_init (&ret->rec_mutex);
#else
g_rec_mutex_init (&ret->rec_mutex);
#endif
g_static_rec_mutex_init (&ret->task_mutex);
ret->task = gst_task_new (task_monitor_alsa, ret);
@ -583,11 +579,7 @@ gst_alsa_mixer_free (GstAlsaMixer * mixer)
snd_mixer_close (mixer->handle);
mixer->handle = NULL;
}
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_rec_mutex_free (&mixer->rec_mutex);
#else
g_rec_mutex_clear (&mixer->rec_mutex);
#endif
g_free (mixer);
}

View file

@ -55,11 +55,7 @@ struct _GstAlsaMixer
GstTask * task;
GStaticRecMutex task_mutex;
#if !GLIB_CHECK_VERSION (2, 31, 0)
GStaticRecMutex rec_mutex;
#else
GRecMutex rec_mutex;
#endif
int pfd[2];
@ -70,13 +66,8 @@ struct _GstAlsaMixer
GstAlsaMixerDirection dir;
};
#if !GLIB_CHECK_VERSION (2, 31, 0)
#define GST_ALSA_MIXER_LOCK(mixer) g_static_rec_mutex_lock (&mixer->rec_mutex)
#define GST_ALSA_MIXER_UNLOCK(mixer) g_static_rec_mutex_unlock (&mixer->rec_mutex)
#else
#define GST_ALSA_MIXER_LOCK(mixer) g_rec_mutex_lock (&mixer->rec_mutex)
#define GST_ALSA_MIXER_UNLOCK(mixer) g_rec_mutex_unlock (&mixer->rec_mutex)
#endif
GstAlsaMixer* gst_alsa_mixer_new (const gchar *device,
GstAlsaMixerDirection dir);

View file

@ -438,14 +438,8 @@ gst_audio_sink_ring_buffer_activate (GstAudioRingBuffer * buf, gboolean active)
GST_DEBUG_OBJECT (sink, "starting thread");
#if !GLIB_CHECK_VERSION (2, 31, 0)
sink->thread =
g_thread_create ((GThreadFunc) audioringbuffer_thread_func, buf, TRUE,
&error);
#else
sink->thread = g_thread_try_new ("audiosink-ringbuffer",
(GThreadFunc) audioringbuffer_thread_func, buf, &error);
#endif
if (!sink->thread || error != NULL)
goto thread_failed;

View file

@ -398,14 +398,8 @@ gst_audio_src_ring_buffer_acquire (GstAudioRingBuffer * buf,
abuf->running = TRUE;
/* FIXME: handle thread creation failure */
#if !GLIB_CHECK_VERSION (2, 31, 0)
src->thread =
g_thread_create ((GThreadFunc) audioringbuffer_thread_func, buf, TRUE,
NULL);
#else
src->thread = g_thread_try_new ("audiosrc-ringbuffer",
(GThreadFunc) audioringbuffer_thread_func, buf, NULL);
#endif
GST_AUDIO_RING_BUFFER_WAIT (buf);

View file

@ -27,43 +27,19 @@
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)
/* FIXME: can use unconditionally now */
#define GLIB_HAS_GDATETIME
#endif
/* See bug #651514 */
#if GLIB_CHECK_VERSION(2,29,5)
/* FIXME: can use the new functions unconditionally now */
#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)
/* FIXME: use new GLib API */
#define g_mutex_new gst_g_mutex_new
static inline GMutex *
gst_g_mutex_new (void)
@ -126,7 +102,6 @@ gst_g_cond_timed_wait (GCond *cond, GMutex *mutex, GTimeVal *abs_time)
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 */

View file

@ -110,64 +110,6 @@ gst_tag_get_license_translations_dictionary (void)
#endif
#ifdef ENABLE_NLS
#if !GLIB_CHECK_VERSION(2,28,0)
static GVariant *
gst_g_variant_lookup_value (GVariant * dictionary, const gchar * key,
const GVariantType * expected_type)
{
GVariantIter iter;
GVariant *entry;
GVariant *value;
GST_ERROR ("here, using fallback");
g_assert (g_variant_is_of_type (dictionary, G_VARIANT_TYPE ("a{s*}")));
g_assert (expected_type != NULL);
g_variant_iter_init (&iter, dictionary);
while ((entry = g_variant_iter_next_value (&iter))) {
GVariant *entry_key;
gboolean matches;
entry_key = g_variant_get_child_value (entry, 0);
matches = strcmp (g_variant_get_string (entry_key, NULL), key) == 0;
g_variant_unref (entry_key);
if (matches)
break;
g_variant_unref (entry);
}
if (entry == NULL)
return NULL;
value = g_variant_get_child_value (entry, 1);
g_variant_unref (entry);
if (g_variant_is_of_type (value, G_VARIANT_TYPE_VARIANT)) {
GVariant *tmp;
tmp = g_variant_get_variant (value);
g_variant_unref (value);
if (expected_type && !g_variant_is_of_type (tmp, expected_type)) {
g_variant_unref (tmp);
tmp = NULL;
}
value = tmp;
}
g_assert (value == NULL || g_variant_is_of_type (value, expected_type));
return value;
}
#define g_variant_lookup_value gst_g_variant_lookup_value
#endif /* !GLIB_CHECK_VERSION(2,28,0) */
static gboolean
gst_variant_lookup_string_value (GVariant * dict, const gchar * lang,
const gchar ** translation)

View file

@ -47,20 +47,11 @@ static GQuark tag_xmp_writer_key;
typedef struct
{
GSList *schemas;
#if !GLIB_CHECK_VERSION (2, 31, 0)
GStaticMutex lock;
#else
GMutex lock;
#endif
} GstTagXmpWriterData;
#if !GLIB_CHECK_VERSION (2, 31, 0)
#define GST_TAG_XMP_WRITER_DATA_LOCK(data) g_static_mutex_lock(&data->lock)
#define GST_TAG_XMP_WRITER_DATA_UNLOCK(data) g_static_mutex_unlock(&data->lock)
#else
#define GST_TAG_XMP_WRITER_DATA_LOCK(data) g_mutex_lock(&data->lock)
#define GST_TAG_XMP_WRITER_DATA_UNLOCK(data) g_mutex_unlock(&data->lock)
#endif
GType
gst_tag_xmp_writer_get_type (void)
@ -128,11 +119,7 @@ gst_tag_xmp_writer_data_free (gpointer p)
}
g_slist_free (data->schemas);
}
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_mutex_free (&data->lock);
#else
g_mutex_clear (&data->lock);
#endif
g_slice_free (GstTagXmpWriterData, data);
}
@ -145,36 +132,22 @@ gst_tag_xmp_writer_get_data (GstTagXmpWriter * xmpconfig)
data = g_object_get_qdata (G_OBJECT (xmpconfig), tag_xmp_writer_key);
if (!data) {
/* make sure no other thread is creating a GstTagData at the same time */
#if !GLIB_CHECK_VERSION (2, 31, 0)
static GStaticMutex create_mutex = G_STATIC_MUTEX_INIT;
g_static_mutex_lock (&create_mutex);
#else
static GMutex create_mutex; /* no initialisation required */
g_mutex_lock (&create_mutex);
#endif
data = g_object_get_qdata (G_OBJECT (xmpconfig), tag_xmp_writer_key);
if (!data) {
data = g_slice_new (GstTagXmpWriterData);
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_mutex_init (&data->lock);
#else
g_mutex_init (&data->lock);
#endif
data->schemas = NULL;
gst_tag_xmp_writer_data_add_all_schemas_unlocked (data);
g_object_set_qdata_full (G_OBJECT (xmpconfig), tag_xmp_writer_key, data,
gst_tag_xmp_writer_data_free);
}
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_mutex_unlock (&create_mutex);
#else
g_mutex_unlock (&create_mutex);
#endif
}
return data;

View file

@ -136,11 +136,7 @@ struct _GstVideoOverlayRectangle
/* FIXME: we may also need a (private) way to cache converted/scaled
* pixel blobs */
#if !GLIB_CHECK_VERSION (2, 31, 0)
GStaticMutex lock;
#else
GMutex lock;
#endif
GList *scaled_rectangles;
};
@ -150,13 +146,8 @@ struct _GstVideoOverlayRectangleClass
GstMiniObjectClass parent_class;
};
#if !GLIB_CHECK_VERSION (2, 31, 0)
#define GST_RECTANGLE_LOCK(rect) g_static_mutex_lock(&rect->lock)
#define GST_RECTANGLE_UNLOCK(rect) g_static_mutex_unlock(&rect->lock)
#else
#define GST_RECTANGLE_LOCK(rect) g_mutex_lock(&rect->lock)
#define GST_RECTANGLE_UNLOCK(rect) g_mutex_unlock(&rect->lock)
#endif
static void gst_video_overlay_composition_class_init (GstMiniObjectClass * k);
static void gst_video_overlay_composition_finalize (GstMiniObject * comp);
@ -197,11 +188,7 @@ gst_video_overlay_get_seqnum (void)
{
static gint seqnum; /* 0 */
#if GLIB_CHECK_VERSION(2,29,5)
return (guint) g_atomic_int_add (&seqnum, 1);
#else
return (guint) g_atomic_int_exchange_and_add (&seqnum, 1);
#endif
}
#define GST_OVERLAY_COMPOSITION_QUARK gst_overlay_composition_quark_get()
@ -683,11 +670,8 @@ gst_video_overlay_rectangle_finalize (GstMiniObject * mini_obj)
rect->scaled_rectangles =
g_list_delete_link (rect->scaled_rectangles, rect->scaled_rectangles);
}
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_mutex_free (&rect->lock);
#else
g_mutex_clear (&rect->lock);
#endif
/* not chaining up to GstMiniObject's finalize for now, we know it's empty */
}
@ -703,11 +687,7 @@ gst_video_overlay_rectangle_instance_init (GstMiniObject * mini_obj)
{
GstVideoOverlayRectangle *rect = (GstVideoOverlayRectangle *) mini_obj;
#if !GLIB_CHECK_VERSION (2, 31, 0)
g_static_mutex_init (&rect->lock);
#else
g_mutex_init (&rect->lock);
#endif
}
static inline gboolean

View file

@ -40,6 +40,10 @@
*/
/* Element-Checklist-Version: 5 */
/* FIXME 0.11: suppress warnings for deprecated API such as GStaticRecMutex
* with newer GLib versions (>= 2.31.0) */
#define GLIB_DISABLE_DEPRECATION_WARNINGS
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
@ -981,11 +985,7 @@ gst_adder_request_new_pad (GstElement * element, GstPadTemplate * templ,
adder = GST_ADDER (element);
/* increment pad counter */
#if GLIB_CHECK_VERSION(2,29,5)
padcount = g_atomic_int_add (&adder->padcount, 1);
#else
padcount = g_atomic_int_exchange_and_add (&adder->padcount, 1);
#endif
name = g_strdup_printf ("sink_%u", padcount);
newpad = gst_pad_new_from_template (templ, name);

View file

@ -402,21 +402,13 @@ gst_audio_rate_convert_segments (GstAudioRate * audiorate)
static void
gst_audio_rate_notify_drop (GstAudioRate * audiorate)
{
#if !GLIB_CHECK_VERSION(2,26,0)
g_object_notify ((GObject *) audiorate, "drop");
#else
g_object_notify_by_pspec ((GObject *) audiorate, pspec_drop);
#endif
}
static void
gst_audio_rate_notify_add (GstAudioRate * audiorate)
{
#if !GLIB_CHECK_VERSION(2,26,0)
g_object_notify ((GObject *) audiorate, "add");
#else
g_object_notify_by_pspec ((GObject *) audiorate, pspec_add);
#endif
}
static GstFlowReturn

View file

@ -2635,13 +2635,8 @@ gst_multi_socket_sink_start (GstBaseSink * bsink)
this->running = TRUE;
#if !GLIB_CHECK_VERSION (2, 31, 0)
this->thread = g_thread_create ((GThreadFunc) gst_multi_socket_sink_thread,
this, TRUE, NULL);
#else
this->thread = g_thread_new ("multisocketsink",
(GThreadFunc) gst_multi_socket_sink_thread, this);
#endif
GST_OBJECT_FLAG_SET (this, GST_MULTI_SOCKET_SINK_OPEN);

View file

@ -652,21 +652,13 @@ gst_video_rate_swap_prev (GstVideoRate * videorate, GstBuffer * buffer,
static void
gst_video_rate_notify_drop (GstVideoRate * videorate)
{
#if !GLIB_CHECK_VERSION(2,26,0)
g_object_notify ((GObject *) videorate, "drop");
#else
g_object_notify_by_pspec ((GObject *) videorate, pspec_drop);
#endif
}
static void
gst_video_rate_notify_duplicate (GstVideoRate * videorate)
{
#if !GLIB_CHECK_VERSION(2,26,0)
g_object_notify ((GObject *) videorate, "duplicate");
#else
g_object_notify_by_pspec ((GObject *) videorate, pspec_duplicate);
#endif
}
#define MAGIC_LIMIT 25

View file

@ -740,13 +740,8 @@ gst_ximagesink_manage_event_thread (GstXImageSink * ximagesink)
GST_DEBUG_OBJECT (ximagesink, "run xevent thread, expose %d, events %d",
ximagesink->handle_expose, ximagesink->handle_events);
ximagesink->running = TRUE;
#if !GLIB_CHECK_VERSION (2, 31, 0)
ximagesink->event_thread = g_thread_create (
(GThreadFunc) gst_ximagesink_event_thread, ximagesink, TRUE, NULL);
#else
ximagesink->event_thread = g_thread_try_new ("ximagesink-events",
(GThreadFunc) gst_ximagesink_event_thread, ximagesink, NULL);
#endif
}
} else {
if (ximagesink->event_thread) {

View file

@ -1171,13 +1171,8 @@ gst_xvimagesink_manage_event_thread (GstXvImageSink * xvimagesink)
GST_DEBUG_OBJECT (xvimagesink, "run xevent thread, expose %d, events %d",
xvimagesink->handle_expose, xvimagesink->handle_events);
xvimagesink->running = TRUE;
#if !GLIB_CHECK_VERSION (2, 31, 0)
xvimagesink->event_thread = g_thread_create (
(GThreadFunc) gst_xvimagesink_event_thread, xvimagesink, TRUE, NULL);
#else
xvimagesink->event_thread = g_thread_try_new ("xvimagesink-events",
(GThreadFunc) gst_xvimagesink_event_thread, xvimagesink, NULL);
#endif
}
} else {
if (xvimagesink->event_thread) {

View file

@ -395,11 +395,6 @@ main (int argc, char **argv)
GstEncodingProfile *prof;
gchar *inputuri;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx = g_option_context_new ("- encode URIs with GstProfile and encodebin");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());

View file

@ -98,11 +98,6 @@ main (int argc, char **argv)
gulong embed_xid;
GstStateChangeReturn sret;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
gst_init (&argc, &argv);
gtk_init (&argc, &argv);

View file

@ -80,11 +80,6 @@ find_video_sink (void)
int main(int argc, char *argv[])
{
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
gst_init (&argc, &argv);
QApplication app(argc, argv);
app.connect(&app, SIGNAL(lastWindowClosed()), &app, SLOT(quit ()));

View file

@ -2676,11 +2676,6 @@ main (int argc, char **argv)
GOptionContext *ctx;
GError *err = NULL;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx = g_option_context_new ("- test seeking in gsteamer");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());

View file

@ -458,11 +458,6 @@ main (int argc, char **argv)
GOptionContext *ctx;
GError *err = NULL;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx = g_option_context_new ("seek");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());

View file

@ -1809,11 +1809,6 @@ main (int argc, char **argv)
GOptionContext *ctx;
GError *err = NULL;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx = g_option_context_new ("- test seeking in gsteamer");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());

View file

@ -100,11 +100,6 @@ main (int argc, char **argv)
};
GTimer *timer;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx = g_option_context_new ("FILES OR DIRECTORIES WITH AUDIO FILES");
g_option_context_add_main_entries (ctx, options, NULL);
g_option_context_add_group (ctx, gst_init_get_option_group ());

View file

@ -173,11 +173,6 @@ main (int argc, char **argv)
GValueArray *arr;
#endif
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
gst_init (&argc, &argv);
gtk_init (&argc, &argv);

View file

@ -144,11 +144,6 @@ main (gint argc, gchar ** argv)
gulong embed_xid = 0;
gboolean force_aspect = FALSE, draw_borders = FALSE;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
gst_init (&argc, &argv);
gtk_init (&argc, &argv);

View file

@ -514,11 +514,6 @@ main (int argc, char **argv)
};
GOptionContext *ctx;
#if !GLIB_CHECK_VERSION (2, 31, 0)
if (!g_thread_supported ())
g_thread_init (NULL);
#endif
ctx =
g_option_context_new
("- discover files synchronously with GstDiscoverer");