summaryrefslogtreecommitdiff
path: root/gst
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 /gst
parente1f6c37b46997a8244690b4c85d7f7fcd5307373 (diff)
downloadgstreamer-vaapi-d270654c48c19afc3234e126269bf613540b44d8.tar.gz
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>
Diffstat (limited to 'gst')
-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
5 files changed, 8 insertions, 8 deletions
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,