mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-08 18:39:54 +00:00
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 can't change most of these in 0.10 because they're part of our API and ABI.
This commit is contained in:
parent
a8b79513c1
commit
5889260d5a
20 changed files with 211 additions and 12 deletions
|
@ -48,6 +48,71 @@ typedef struct stat GStatBuf;
|
|||
|
||||
/* 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
|
||||
|
|
|
@ -77,6 +77,7 @@
|
|||
#include "gstinfo.h"
|
||||
|
||||
#include "gstbus.h"
|
||||
#include "glib-compat-private.h"
|
||||
|
||||
#define GST_CAT_DEFAULT GST_CAT_BUS
|
||||
/* bus signals */
|
||||
|
|
|
@ -109,6 +109,7 @@
|
|||
#include "gstclock.h"
|
||||
#include "gstinfo.h"
|
||||
#include "gstutils.h"
|
||||
#include "glib-compat-private.h"
|
||||
|
||||
#ifndef GST_DISABLE_TRACE
|
||||
/* #define GST_WITH_ALLOC_TRACE */
|
||||
|
|
|
@ -95,6 +95,7 @@
|
|||
#include "gstinfo.h"
|
||||
#include "gstvalue.h"
|
||||
#include "gst-i18n-lib.h"
|
||||
#include "glib-compat-private.h"
|
||||
|
||||
/* Element signals and args */
|
||||
enum
|
||||
|
|
|
@ -215,29 +215,48 @@ struct _GstObject {
|
|||
*
|
||||
* This macro will return the class lock used to protect deep_notify signal
|
||||
* emission on thread-unsafe glib versions (glib < 2.8).
|
||||
*
|
||||
* Deprecated: 0.10.36: Don't use this, it's not needed any longer.
|
||||
*/
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
#define GST_CLASS_GET_LOCK(obj) (GST_OBJECT_CLASS_CAST(obj)->lock)
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GST_CLASS_LOCK:
|
||||
* @obj: a #GstObjectClass
|
||||
*
|
||||
* Lock the class.
|
||||
*
|
||||
* Deprecated: 0.10.36: Don't use this, it's not needed any longer.
|
||||
*/
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
#define GST_CLASS_LOCK(obj) (g_static_rec_mutex_lock(GST_CLASS_GET_LOCK(obj)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GST_CLASS_TRYLOCK:
|
||||
* @obj: a #GstObjectClass
|
||||
*
|
||||
* Try to lock the class, returns TRUE if class could be locked.
|
||||
*
|
||||
* Deprecated: 0.10.36: Don't use this, it's not needed any longer.
|
||||
*/
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
#define GST_CLASS_TRYLOCK(obj) (g_static_rec_mutex_trylock(GST_CLASS_GET_LOCK(obj)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GST_CLASS_UNLOCK:
|
||||
* @obj: a #GstObjectClass
|
||||
*
|
||||
* Unlock the class.
|
||||
*
|
||||
* Deprecated: 0.10.36: Don't use this, it's not needed any longer.
|
||||
*/
|
||||
#ifndef GST_DISABLE_DEPRECATED
|
||||
#define GST_CLASS_UNLOCK(obj) (g_static_rec_mutex_unlock(GST_CLASS_GET_LOCK(obj)))
|
||||
#endif
|
||||
|
||||
/**
|
||||
* GstObjectClass:
|
||||
|
|
|
@ -72,6 +72,7 @@
|
|||
|
||||
#include "gstinfo.h"
|
||||
#include "gsttask.h"
|
||||
#include "glib-compat-private.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
@ -276,8 +277,13 @@ gst_task_func (GstTask * task)
|
|||
goto no_lock;
|
||||
task->abidata.ABI.thread = tself;
|
||||
/* only update the priority when it was changed */
|
||||
if (priv->prio_set)
|
||||
if (priv->prio_set) {
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
g_thread_set_priority (tself, priv->priority);
|
||||
#else
|
||||
GST_INFO_OBJECT (task, "Thread priorities no longer have any effect");
|
||||
#endif
|
||||
}
|
||||
GST_OBJECT_UNLOCK (task);
|
||||
|
||||
/* fire the enter_thread callback when we need to */
|
||||
|
@ -333,7 +339,9 @@ exit:
|
|||
} else {
|
||||
/* restore normal priority when releasing back into the pool, we will not
|
||||
* touch the priority when a custom callback has been installed. */
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
g_thread_set_priority (tself, G_THREAD_PRIORITY_NORMAL);
|
||||
#endif
|
||||
}
|
||||
/* now we allow messing with the lock again by setting the running flag to
|
||||
* FALSE. Together with the SIGNAL this is the sign for the _join() to
|
||||
|
@ -475,7 +483,11 @@ gst_task_set_priority (GstTask * task, GThreadPriority priority)
|
|||
if (thread != NULL) {
|
||||
/* if this task already has a thread, we can configure the priority right
|
||||
* away, else we do that when we assign a thread to the task. */
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
g_thread_set_priority (thread, priority);
|
||||
#else
|
||||
GST_INFO_OBJECT (task, "Thread priorities no longer have any effect");
|
||||
#endif
|
||||
}
|
||||
GST_OBJECT_UNLOCK (task);
|
||||
}
|
||||
|
|
|
@ -284,7 +284,11 @@ struct _GstBaseParsePrivate
|
|||
GstIndex *index;
|
||||
gint index_id;
|
||||
gboolean own_index;
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
GStaticMutex index_lock;
|
||||
#else
|
||||
GMutex index_lock;
|
||||
#endif
|
||||
|
||||
/* seek table entries only maintained if upstream is BYTE seekable */
|
||||
gboolean upstream_seekable;
|
||||
|
@ -333,6 +337,18 @@ typedef struct _GstBaseParseSeek
|
|||
GstClockTime start_ts;
|
||||
} GstBaseParseSeek;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
#define GST_BASE_PARSE_INDEX_LOCK(parse) \
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
#define GST_BASE_PARSE_INDEX_UNLOCK(parse) \
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
#else
|
||||
#define GST_BASE_PARSE_INDEX_LOCK(parse) \
|
||||
g_mutex_lock (&parse->priv->index_lock);
|
||||
#define GST_BASE_PARSE_INDEX_UNLOCK(parse) \
|
||||
g_mutex_unlock (&parse->priv->index_lock);
|
||||
#endif
|
||||
|
||||
static GstElementClass *parent_class = NULL;
|
||||
|
||||
static void gst_base_parse_class_init (GstBaseParseClass * klass);
|
||||
|
@ -474,8 +490,11 @@ gst_base_parse_finalize (GObject * object)
|
|||
gst_object_unref (parse->priv->index);
|
||||
parse->priv->index = NULL;
|
||||
}
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
g_static_mutex_free (&parse->priv->index_lock);
|
||||
#else
|
||||
g_mutex_clear (&parse->priv->index_lock);
|
||||
#endif
|
||||
|
||||
gst_base_parse_clear_queues (parse);
|
||||
|
||||
|
@ -560,7 +579,11 @@ gst_base_parse_init (GstBaseParse * parse, GstBaseParseClass * bclass)
|
|||
|
||||
parse->priv->pad_mode = GST_ACTIVATE_NONE;
|
||||
|
||||
#if !GLIB_CHECK_VERSION (2, 31, 0)
|
||||
g_static_mutex_init (&parse->priv->index_lock);
|
||||
#else
|
||||
g_mutex_init (&parse->priv->index_lock);
|
||||
#endif
|
||||
|
||||
/* init state */
|
||||
gst_base_parse_reset (parse);
|
||||
|
@ -1488,11 +1511,11 @@ gst_base_parse_add_index_entry (GstBaseParse * parse, guint64 offset,
|
|||
associations[1].value = offset;
|
||||
|
||||
/* index might change on-the-fly, although that would be nutty app ... */
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_LOCK (parse);
|
||||
gst_index_add_associationv (parse->priv->index, parse->priv->index_id,
|
||||
(key) ? GST_ASSOCIATION_FLAG_KEY_UNIT : GST_ASSOCIATION_FLAG_DELTA_UNIT,
|
||||
2, (const GstIndexAssociation *) &associations);
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_UNLOCK (parse);
|
||||
|
||||
if (key) {
|
||||
parse->priv->index_last_offset = offset;
|
||||
|
@ -3632,7 +3655,7 @@ gst_base_parse_find_offset (GstBaseParse * parse, GstClockTime time,
|
|||
goto exit;
|
||||
}
|
||||
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_LOCK (parse);
|
||||
if (parse->priv->index) {
|
||||
/* Let's check if we have an index entry for that time */
|
||||
entry = gst_index_get_assoc_entry (parse->priv->index,
|
||||
|
@ -3656,7 +3679,7 @@ gst_base_parse_find_offset (GstBaseParse * parse, GstClockTime time,
|
|||
ts = GST_CLOCK_TIME_NONE;
|
||||
}
|
||||
}
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_UNLOCK (parse);
|
||||
|
||||
exit:
|
||||
if (_ts)
|
||||
|
@ -4007,7 +4030,7 @@ gst_base_parse_set_index (GstElement * element, GstIndex * index)
|
|||
{
|
||||
GstBaseParse *parse = GST_BASE_PARSE (element);
|
||||
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_LOCK (parse);
|
||||
if (parse->priv->index)
|
||||
gst_object_unref (parse->priv->index);
|
||||
if (index) {
|
||||
|
@ -4018,7 +4041,7 @@ gst_base_parse_set_index (GstElement * element, GstIndex * index)
|
|||
} else {
|
||||
parse->priv->index = NULL;
|
||||
}
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_UNLOCK (parse);
|
||||
}
|
||||
|
||||
static GstIndex *
|
||||
|
@ -4027,10 +4050,10 @@ gst_base_parse_get_index (GstElement * element)
|
|||
GstBaseParse *parse = GST_BASE_PARSE (element);
|
||||
GstIndex *result = NULL;
|
||||
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_LOCK (parse);
|
||||
if (parse->priv->index)
|
||||
result = gst_object_ref (parse->priv->index);
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_UNLOCK (parse);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -4047,7 +4070,7 @@ gst_base_parse_change_state (GstElement * element, GstStateChange transition)
|
|||
case GST_STATE_CHANGE_READY_TO_PAUSED:
|
||||
/* If this is our own index destroy it as the
|
||||
* old entries might be wrong for the new stream */
|
||||
g_static_mutex_lock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_LOCK (parse);
|
||||
if (parse->priv->own_index) {
|
||||
gst_object_unref (parse->priv->index);
|
||||
parse->priv->index = NULL;
|
||||
|
@ -4063,7 +4086,7 @@ gst_base_parse_change_state (GstElement * element, GstStateChange transition)
|
|||
&parse->priv->index_id);
|
||||
parse->priv->own_index = TRUE;
|
||||
}
|
||||
g_static_mutex_unlock (&parse->priv->index_lock);
|
||||
GST_BASE_PARSE_INDEX_UNLOCK (parse);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
|
|
@ -166,6 +166,7 @@
|
|||
#include <string.h>
|
||||
|
||||
#include <gst/gst_private.h>
|
||||
#include <gst/glib-compat-private.h>
|
||||
|
||||
#include "gstbasesrc.h"
|
||||
#include "gsttypefindhelper.h"
|
||||
|
|
|
@ -207,6 +207,7 @@
|
|||
|
||||
#include "../../../gst/gst_private.h"
|
||||
#include "../../../gst/gst-i18n-lib.h"
|
||||
#include "../../../gst/glib-compat-private.h"
|
||||
#include "gstbasetransform.h"
|
||||
#include <gst/gstmarshal.h>
|
||||
|
||||
|
|
|
@ -73,6 +73,7 @@
|
|||
*/
|
||||
|
||||
#include "gstcollectpads.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (collect_pads_debug);
|
||||
#define GST_CAT_DEFAULT collect_pads_debug
|
||||
|
|
|
@ -84,6 +84,8 @@
|
|||
|
||||
#include "gstcollectpads2.h"
|
||||
|
||||
#include "../../../gst/glib-compat-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (collect_pads2_debug);
|
||||
#define GST_CAT_DEFAULT collect_pads2_debug
|
||||
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
#include <gst/gst.h>
|
||||
#include "string.h"
|
||||
#include "gstdataqueue.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (data_queue_debug);
|
||||
#define GST_CAT_DEFAULT (data_queue_debug)
|
||||
|
|
|
@ -286,6 +286,68 @@ gst_g_thread_create (GThreadFunc func, gpointer data, gboolean joinable,
|
|||
g_assert (joinable);
|
||||
return g_thread_try_new ("gst-check", func, data, error);
|
||||
}
|
||||
#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
|
||||
|
||||
#define MAIN_INIT() \
|
||||
|
|
|
@ -80,6 +80,7 @@
|
|||
#include "gstcontrollerprivate.h"
|
||||
#include "gstcontrolsource.h"
|
||||
#include "gstinterpolationcontrolsource.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
#define GST_CAT_DEFAULT controller_debug
|
||||
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);
|
||||
|
|
|
@ -43,6 +43,7 @@
|
|||
#include "gstcontrolsource.h"
|
||||
#include "gstinterpolationcontrolsource.h"
|
||||
#include "gstinterpolationcontrolsourceprivate.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
#define GST_CAT_DEFAULT controller_debug
|
||||
GST_DEBUG_CATEGORY_EXTERN (GST_CAT_DEFAULT);
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
#include "gstlfocontrolsource.h"
|
||||
#include "gstlfocontrolsourceprivate.h"
|
||||
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
#include <gst/math-compat.h>
|
||||
|
||||
#define EMPTY(x) (x)
|
||||
|
|
|
@ -59,6 +59,8 @@
|
|||
|
||||
#include "gstinputselector.h"
|
||||
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
GST_DEBUG_CATEGORY_STATIC (input_selector_debug);
|
||||
#define GST_CAT_DEFAULT input_selector_debug
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@
|
|||
#include "gstqueue.h"
|
||||
|
||||
#include "../../gst/gst-i18n-lib.h"
|
||||
#include "../../gst/glib-compat-private.h"
|
||||
|
||||
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
|
||||
GST_PAD_SINK,
|
||||
|
|
|
@ -63,6 +63,7 @@
|
|||
#include <glib/gstdio.h>
|
||||
|
||||
#include "gst/gst-i18n-lib.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@
|
|||
#endif
|
||||
|
||||
#include "gsttee.h"
|
||||
#include "gst/glib-compat-private.h"
|
||||
|
||||
#include <string.h>
|
||||
|
||||
|
|
Loading…
Reference in a new issue