[Spice-devel] [PATCH spice-server] gstreamer: Compatibility layer for old GLib
Frediano Ziglio
fziglio at redhat.com
Thu Nov 10 12:35:39 UTC 2016
>
> Support new GCond/GMutex interface with former GLib.
>
> Signed-off-by: Frediano Ziglio <fziglio at redhat.com>
> ---
> server/glib-compat.h | 69
> ++++++++++++++++++++++++++++++++++++++++++++++
> server/gstreamer-encoder.c | 1 +
> 2 files changed, 70 insertions(+)
>
> diff --git a/server/glib-compat.h b/server/glib-compat.h
> index 8a27afe..d4ff550 100644
> --- a/server/glib-compat.h
> +++ b/server/glib-compat.h
> @@ -44,4 +44,73 @@ g_queue_remove_boolean(GQueue *queue, gconstpointer data)
> #define g_queue_remove g_queue_remove_boolean
> #endif
>
> +#if !GLIB_CHECK_VERSION(2,32,0)
> +typedef struct {
> + GMutex *mtx_compat;
> +} GMutexCompat;
> +#define GMutex GMutexCompat
> +
> +static inline void
> +g_mutex_lock_compat(GMutexCompat *mtx)
> +{
> + g_mutex_lock(mtx->mtx_compat);
> +}
> +#undef g_mutex_lock
> +#define g_mutex_lock(mtx) g_mutex_lock_compat(mtx)
> +static inline void
> +g_mutex_unlock_compat(GMutexCompat *mtx)
> +{
> + g_mutex_unlock(mtx->mtx_compat);
> +}
> +#undef g_mutex_unlock
> +#define g_mutex_unlock(mtx) g_mutex_unlock_compat(mtx)
> +
> +typedef struct {
> + GCond *cond_compat;
> +} GCondCompat;
> +#define GCond GCondCompat
> +
> +static inline void
> +g_cond_signal_compat(GCondCompat *cond)
> +{
> + g_cond_signal(cond->cond_compat);
> +}
> +#undef g_cond_signal
> +#define g_cond_signal(cond) g_cond_signal_compat(cond)
> +
> +static inline void
> +g_cond_wait_compat(GCondCompat *cond, GMutexCompat *mtx)
> +{
> + g_cond_wait(cond->cond_compat, mtx->mtx_compat);
> +}
> +#undef g_cond_wait
> +#define g_cond_wait(cond, mtx) g_cond_wait_compat(cond, mtx)
> +
> +static inline void
> +g_mutex_init(GMutexCompat *mtx)
> +{
> + mtx->mtx_compat = g_mutex_new();
> +}
> +
> +static inline void
> +g_cond_init(GCondCompat *cond)
> +{
> + cond->cond_compat = g_cond_new();
> +}
> +
> +static inline void
> +g_mutex_clear(GMutexCompat *mtx)
> +{
> + g_mutex_free(mtx->mtx_compat);
> + mtx->mtx_compat = NULL;
> +}
> +
> +static inline void
> +g_cond_clear(GCondCompat *cond)
> +{
> + g_cond_free(cond->cond_compat);
> + cond->cond_compat = NULL;
> +}
> +#endif
> +
> #endif /* GLIB_COMPAT_H_ */
> diff --git a/server/gstreamer-encoder.c b/server/gstreamer-encoder.c
> index 3d5f8a0..c419bb6 100644
> --- a/server/gstreamer-encoder.c
> +++ b/server/gstreamer-encoder.c
> @@ -29,6 +29,7 @@
> #include "red-common.h"
> #include "video-encoder.h"
> #include "utils.h"
> +#include "glib-compat.h"
>
>
> #define SPICE_GST_DEFAULT_FPS 30
I honestly would prefer to use pthread.
Frediano
More information about the Spice-devel
mailing list