summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Waters <matthew@centricular.com>2021-03-19 17:42:36 +1100
committerMatthew Waters <matthew@centricular.com>2021-03-19 19:03:54 +1100
commitd270654c48c19afc3234e126269bf613540b44d8 (patch)
tree6c6dbe776b96f162d6dfe950504c84926c9e89ca
parente1f6c37b46997a8244690b4c85d7f7fcd5307373 (diff)
gst: don't use volatile to mean atomic
volatile is not sufficient to provide atomic guarantees and real atomics should be used instead. GCC 11 has started warning about using volatile with atomic operations. https://gitlab.gnome.org/GNOME/glib/-/merge_requests/1719 Discovered in https://gitlab.freedesktop.org/gstreamer/gst-plugins-good/-/issues/868 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/-/merge_requests/418>
-rw-r--r--gst-libs/gst/vaapi/gstvaapicontext.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapicontext.h2
-rw-r--r--gst-libs/gst/vaapi/gstvaapiencoder.c4
-rw-r--r--gst-libs/gst/vaapi/gstvaapifilter.c4
-rw-r--r--gst-libs/gst/vaapi/gstvaapiminiobject.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapiminiobject.h2
-rw-r--r--gst-libs/gst/vaapi/gstvaapitexture_glx.c2
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils_egl.c4
-rw-r--r--gst-libs/gst/vaapi/gstvaapiutils_egl.h2
-rw-r--r--gst-libs/gst/vaapi/gstvaapivalue.c10
-rw-r--r--gst-libs/gst/vaapi/gstvaapiwindow_wayland.c2
-rw-r--r--gst/vaapi/gstvaapipluginbase.c2
-rw-r--r--gst/vaapi/gstvaapisink.c6
-rw-r--r--gst/vaapi/gstvaapisink.h2
-rw-r--r--gst/vaapi/gstvaapivideocontext.c2
-rw-r--r--gst/vaapi/gstvaapivideomemory.c4
-rw-r--r--tests/internal/simple-decoder.c12
17 files changed, 32 insertions, 32 deletions
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.c b/gst-libs/gst/vaapi/gstvaapicontext.c
index 52fd751b..88cd1105 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.c
+++ b/gst-libs/gst/vaapi/gstvaapicontext.c
@@ -51,7 +51,7 @@ static void
_init_vaapi_context_debug (void)
{
#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapi_context, "vaapicontext", 0,
diff --git a/gst-libs/gst/vaapi/gstvaapicontext.h b/gst-libs/gst/vaapi/gstvaapicontext.h
index 820fa639..7117722b 100644
--- a/gst-libs/gst/vaapi/gstvaapicontext.h
+++ b/gst-libs/gst/vaapi/gstvaapicontext.h
@@ -100,7 +100,7 @@ struct _GstVaapiContextInfo
struct _GstVaapiContext
{
/*< private >*/
- volatile gint ref_count;
+ gint ref_count;
GstVaapiDisplay *display;
GstVaapiID object_id;
diff --git a/gst-libs/gst/vaapi/gstvaapiencoder.c b/gst-libs/gst/vaapi/gstvaapiencoder.c
index 83d26f0f..6c103ace 100644
--- a/gst-libs/gst/vaapi/gstvaapiencoder.c
+++ b/gst-libs/gst/vaapi/gstvaapiencoder.c
@@ -1822,7 +1822,7 @@ out:
GType
gst_vaapi_encoder_tune_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
static const GEnumValue encoder_tune_values[] = {
/* *INDENT-OFF* */
@@ -1850,7 +1850,7 @@ gst_vaapi_encoder_tune_get_type (void)
GType
gst_vaapi_encoder_mbbrc_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
if (g_once_init_enter (&g_type)) {
static const GEnumValue encoder_mbbrc_values[] = {
diff --git a/gst-libs/gst/vaapi/gstvaapifilter.c b/gst-libs/gst/vaapi/gstvaapifilter.c
index a9443e40..e0b3cd5f 100644
--- a/gst-libs/gst/vaapi/gstvaapifilter.c
+++ b/gst-libs/gst/vaapi/gstvaapifilter.c
@@ -38,7 +38,7 @@ struct _GstVaapiFilterOpData
{
GstVaapiFilterOp op;
GParamSpec *pspec;
- volatile gint ref_count;
+ gint ref_count;
guint va_type;
guint va_subtype;
gpointer va_caps;
@@ -550,7 +550,7 @@ op_data_new (GstVaapiFilterOp op, GParamSpec * pspec)
op_data->op = op;
op_data->pspec = pspec;
- op_data->ref_count = 1;
+ g_atomic_int_set (&op_data->ref_count, 1);
op_data->va_buffer = VA_INVALID_ID;
switch (op) {
diff --git a/gst-libs/gst/vaapi/gstvaapiminiobject.c b/gst-libs/gst/vaapi/gstvaapiminiobject.c
index 7b189832..30586b04 100644
--- a/gst-libs/gst/vaapi/gstvaapiminiobject.c
+++ b/gst-libs/gst/vaapi/gstvaapiminiobject.c
@@ -70,7 +70,7 @@ gst_vaapi_mini_object_new (const GstVaapiMiniObjectClass * object_class)
return NULL;
object->object_class = object_class;
- object->ref_count = 1;
+ g_atomic_int_set (&object->ref_count, 1);
object->flags = 0;
return object;
}
diff --git a/gst-libs/gst/vaapi/gstvaapiminiobject.h b/gst-libs/gst/vaapi/gstvaapiminiobject.h
index 778fc07b..52f28636 100644
--- a/gst-libs/gst/vaapi/gstvaapiminiobject.h
+++ b/gst-libs/gst/vaapi/gstvaapiminiobject.h
@@ -120,7 +120,7 @@ struct _GstVaapiMiniObject
{
/*< private >*/
gconstpointer object_class;
- volatile gint ref_count;
+ gint ref_count;
guint flags;
};
diff --git a/gst-libs/gst/vaapi/gstvaapitexture_glx.c b/gst-libs/gst/vaapi/gstvaapitexture_glx.c
index 273afc9b..76f450ad 100644
--- a/gst-libs/gst/vaapi/gstvaapitexture_glx.c
+++ b/gst-libs/gst/vaapi/gstvaapitexture_glx.c
@@ -249,7 +249,7 @@ GstVaapiGLApi
gl_get_curent_api_once ()
{
static GstVaapiGLApi cur_api = GST_VAAPI_GL_API_NONE;
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
cur_api = gl_get_current_api (NULL, NULL);
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_egl.c b/gst-libs/gst/vaapi/gstvaapiutils_egl.c
index 0c2a1f5a..99ae37d2 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils_egl.c
+++ b/gst-libs/gst/vaapi/gstvaapiutils_egl.c
@@ -614,7 +614,7 @@ egl_display_thread (gpointer data)
g_cond_broadcast (&display->gl_thread_ready);
g_mutex_unlock (&display->mutex);
- while (!display->gl_thread_cancel) {
+ while (!g_atomic_int_get (&display->gl_thread_cancel)) {
EglMessage *const msg =
g_async_queue_timeout_pop (display->gl_queue, 100000);
@@ -671,7 +671,7 @@ egl_display_init (EglDisplay * display)
static void
egl_display_finalize (EglDisplay * display)
{
- display->gl_thread_cancel = TRUE;
+ g_atomic_int_set (&display->gl_thread_cancel, TRUE);
g_thread_join (display->gl_thread);
g_cond_clear (&display->gl_thread_ready);
g_mutex_clear (&display->mutex);
diff --git a/gst-libs/gst/vaapi/gstvaapiutils_egl.h b/gst-libs/gst/vaapi/gstvaapiutils_egl.h
index abf3735e..20b553ea 100644
--- a/gst-libs/gst/vaapi/gstvaapiutils_egl.h
+++ b/gst-libs/gst/vaapi/gstvaapiutils_egl.h
@@ -120,7 +120,7 @@ struct egl_display_s
GMutex mutex;
GThread *gl_thread;
GCond gl_thread_ready;
- volatile gboolean gl_thread_cancel;
+ gboolean gl_thread_cancel;
GAsyncQueue *gl_queue;
gboolean created;
};
diff --git a/gst-libs/gst/vaapi/gstvaapivalue.c b/gst-libs/gst/vaapi/gstvaapivalue.c
index 1e012133..62e440b6 100644
--- a/gst-libs/gst/vaapi/gstvaapivalue.c
+++ b/gst-libs/gst/vaapi/gstvaapivalue.c
@@ -50,7 +50,7 @@ default_free_func (gpointer data)
GType
gst_vaapi_point_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
if (g_once_init_enter (&g_type)) {
GType type =
@@ -67,7 +67,7 @@ gst_vaapi_point_get_type (void)
GType
gst_vaapi_rectangle_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
if (g_once_init_enter (&g_type)) {
GType type =
@@ -85,7 +85,7 @@ gst_vaapi_rectangle_get_type (void)
GType
gst_vaapi_render_mode_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
static const GEnumValue render_modes[] = {
{GST_VAAPI_RENDER_MODE_OVERLAY,
@@ -108,7 +108,7 @@ gst_vaapi_render_mode_get_type (void)
GType
gst_vaapi_rotation_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
static const GEnumValue rotation_values[] = {
{GST_VAAPI_ROTATION_0,
@@ -137,7 +137,7 @@ gst_vaapi_rotation_get_type (void)
GType
gst_vaapi_rate_control_get_type (void)
{
- static volatile gsize g_type = 0;
+ static gsize g_type = 0;
static const GEnumValue rate_control_values[] = {
{GST_VAAPI_RATECONTROL_NONE,
diff --git a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
index caf1dc63..394a089b 100644
--- a/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
+++ b/gst-libs/gst/vaapi/gstvaapiwindow_wayland.c
@@ -98,7 +98,7 @@ struct _GstVaapiWindowWaylandPrivate
guint is_shown:1;
guint fullscreen_on_show:1;
guint sync_failed:1;
- volatile guint num_frames_pending;
+ guint num_frames_pending;
gint configure_pending;
gboolean need_vpp;
gboolean dmabuf_broken;
diff --git a/gst/vaapi/gstvaapipluginbase.c b/gst/vaapi/gstvaapipluginbase.c
index 3a8664ba..a670e976 100644
--- a/gst/vaapi/gstvaapipluginbase.c
+++ b/gst/vaapi/gstvaapipluginbase.c
@@ -1546,7 +1546,7 @@ static void
_init_performance_debug (void)
{
#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE");
diff --git a/gst/vaapi/gstvaapisink.c b/gst/vaapi/gstvaapisink.c
index e722b713..9b5ae982 100644
--- a/gst/vaapi/gstvaapisink.c
+++ b/gst/vaapi/gstvaapisink.c
@@ -976,7 +976,7 @@ static gpointer
gst_vaapisink_event_thread (GstVaapiSink * sink)
{
GST_OBJECT_LOCK (sink);
- while (!sink->event_thread_cancel) {
+ while (!g_atomic_int_get (&sink->event_thread_cancel)) {
GST_OBJECT_UNLOCK (sink);
sink->backend->handle_events (sink);
g_usleep (G_USEC_PER_SEC / 20);
@@ -1001,7 +1001,7 @@ gst_vaapisink_set_event_handling (GstVaapiSink * sink, gboolean handle_events)
if (sink->backend->pre_start_event_thread)
sink->backend->pre_start_event_thread (sink);
- sink->event_thread_cancel = FALSE;
+ g_atomic_int_set (&sink->event_thread_cancel, FALSE);
sink->event_thread = g_thread_try_new ("vaapisink-events",
(GThreadFunc) gst_vaapisink_event_thread, sink, NULL);
} else if (!handle_events && sink->event_thread) {
@@ -1012,7 +1012,7 @@ gst_vaapisink_set_event_handling (GstVaapiSink * sink, gboolean handle_events)
/* Grab thread and mark it as NULL */
thread = sink->event_thread;
sink->event_thread = NULL;
- sink->event_thread_cancel = TRUE;
+ g_atomic_int_set (&sink->event_thread_cancel, TRUE);
}
GST_OBJECT_UNLOCK (sink);
diff --git a/gst/vaapi/gstvaapisink.h b/gst/vaapi/gstvaapisink.h
index 1fb6e832..525f4221 100644
--- a/gst/vaapi/gstvaapisink.h
+++ b/gst/vaapi/gstvaapisink.h
@@ -99,7 +99,7 @@ struct _GstVaapiSink
guint color_standard;
gint32 view_id;
GThread *event_thread;
- volatile gboolean event_thread_cancel;
+ gboolean event_thread_cancel;
/* Color balance values */
guint cb_changed;
diff --git a/gst/vaapi/gstvaapivideocontext.c b/gst/vaapi/gstvaapivideocontext.c
index bd3db01d..ae3af85d 100644
--- a/gst/vaapi/gstvaapivideocontext.c
+++ b/gst/vaapi/gstvaapivideocontext.c
@@ -44,7 +44,7 @@ static void
_init_context_debug (void)
{
#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (GST_CAT_CONTEXT, "GST_CONTEXT");
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index abf97157..750385a4 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -47,7 +47,7 @@ static void
_init_performance_debug (void)
{
#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (CAT_PERFORMANCE, "GST_PERFORMANCE");
@@ -60,7 +60,7 @@ static void
_init_vaapi_video_memory_debug (void)
{
#ifndef GST_DISABLE_GST_DEBUG
- static volatile gsize _init = 0;
+ static gsize _init = 0;
if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_debug_vaapivideomemory, "vaapivideomemory", 0,
diff --git a/tests/internal/simple-decoder.c b/tests/internal/simple-decoder.c
index 134b8451..75752767 100644
--- a/tests/internal/simple-decoder.c
+++ b/tests/internal/simple-decoder.c
@@ -85,7 +85,7 @@ typedef struct
GstVaapiDisplay *display;
GstVaapiDecoder *decoder;
GThread *decoder_thread;
- volatile gboolean decoder_thread_cancel;
+ gboolean decoder_thread_cancel;
GAsyncQueue *decoder_queue;
GstVaapiCodec codec;
guint fps_n;
@@ -97,7 +97,7 @@ typedef struct
guint window_width;
guint window_height;
GThread *render_thread;
- volatile gboolean render_thread_cancel;
+ gboolean render_thread_cancel;
GCond render_ready;
RenderFrame *last_frame;
GError *error;
@@ -241,7 +241,7 @@ decoder_thread (gpointer data)
pts = g_get_monotonic_time ();
ofs = 0;
- while (!app->decoder_thread_cancel) {
+ while (!g_atomic_int_get (&app->decoder_thread_cancel)) {
if (G_UNLIKELY (ofs == app->file_size))
buffer = NULL;
else {
@@ -376,7 +376,7 @@ stop_decoder (App * app)
{
g_timer_stop (app->timer);
- app->decoder_thread_cancel = TRUE;
+ g_atomic_int_set (&app->decoder_thread_cancel, TRUE);
g_thread_join (app->decoder_thread);
g_print ("Decoder thread stopped\n");
return TRUE;
@@ -462,7 +462,7 @@ renderer_thread (gpointer data)
g_print ("Render thread started\n");
- while (!app->render_thread_cancel) {
+ while (!g_atomic_int_get (&app->render_thread_cancel)) {
rfp = g_async_queue_timeout_pop (app->decoder_queue, 1000000);
if (rfp && !renderer_process (app, rfp))
break;
@@ -497,7 +497,7 @@ start_renderer (App * app)
static gboolean
stop_renderer (App * app)
{
- app->render_thread_cancel = TRUE;
+ g_atomic_int_set (&app->render_thread_cancel, TRUE);
g_thread_join (app->render_thread);
g_print ("Render thread stopped\n");