Skip to content

Commit

Permalink
gst: don't use volatile to mean atomic
Browse files Browse the repository at this point in the history
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/gst-plugins-base/-/merge_requests/1073>
  • Loading branch information
ystreet authored and GStreamer Marge Bot committed Mar 19, 2021
1 parent 00a7111 commit 98249a5
Show file tree
Hide file tree
Showing 45 changed files with 71 additions and 71 deletions.
2 changes: 1 addition & 1 deletion ext/gl/gstgleffects.c
Expand Up @@ -660,7 +660,7 @@ gst_gl_effects_filters_descriptors (void)
gboolean
gst_gl_effects_register_filters (GstPlugin * plugin, GstRank rank)
{
static volatile gsize registered = 0;
static gsize registered = 0;

if (g_once_init_enter (&registered)) {
GTypeInfo info = {
Expand Down
2 changes: 1 addition & 1 deletion ext/gl/gstglimagesink.h
Expand Up @@ -106,7 +106,7 @@ struct _GstGLImageSink
GstBuffer *next_sync;
GstGLSyncMeta *next_sync_meta;

volatile gint to_quit;
gint to_quit;
gboolean keep_aspect_ratio;
gint par_n, par_d;

Expand Down
10 changes: 5 additions & 5 deletions ext/opus/gstopusenc.c
Expand Up @@ -80,7 +80,7 @@ gst_opus_enc_bandwidth_get_type (void)
{OPUS_AUTO, "Auto", "auto"},
{0, NULL, NULL}
};
static volatile GType id = 0;
static GType id = 0;

if (g_once_init_enter ((gsize *) & id)) {
GType _id;
Expand All @@ -106,7 +106,7 @@ gst_opus_enc_frame_size_get_type (void)
{60, "60", "60"},
{0, NULL, NULL}
};
static volatile GType id = 0;
static GType id = 0;

if (g_once_init_enter ((gsize *) & id)) {
GType _id;
Expand All @@ -130,7 +130,7 @@ gst_opus_enc_audio_type_get_type (void)
"restricted-lowdelay"},
{0, NULL, NULL}
};
static volatile GType id = 0;
static GType id = 0;

if (g_once_init_enter ((gsize *) & id)) {
GType _id;
Expand All @@ -153,7 +153,7 @@ gst_opus_enc_bitrate_type_get_type (void)
{BITRATE_TYPE_CONSTRAINED_VBR, "Constrained VBR", "constrained-vbr"},
{0, NULL, NULL}
};
static volatile GType id = 0;
static GType id = 0;

if (g_once_init_enter ((gsize *) & id)) {
GType _id;
Expand Down Expand Up @@ -819,7 +819,7 @@ gst_opus_enc_sink_event (GstAudioEncoder * benc, GstEvent * event)
static GstCaps *
gst_opus_enc_get_sink_template_caps (void)
{
static volatile gsize init = 0;
static gsize init = 0;
static GstCaps *caps = NULL;

if (g_once_init_enter (&init)) {
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/audio/gstaudiodecoder.c
Expand Up @@ -338,7 +338,7 @@ static void gst_audio_decoder_init (GstAudioDecoder * dec,
GType
gst_audio_decoder_get_type (void)
{
static volatile gsize audio_decoder_type = 0;
static gsize audio_decoder_type = 0;

if (g_once_init_enter (&audio_decoder_type)) {
GType _type;
Expand Down
8 changes: 4 additions & 4 deletions gst-libs/gst/audio/gstaudiometa.c
Expand Up @@ -177,7 +177,7 @@ gst_buffer_add_audio_downmix_meta (GstBuffer * buffer,
GType
gst_audio_downmix_meta_api_get_type (void)
{
static volatile GType type;
static GType type;
static const gchar *tags[] =
{ GST_META_TAG_AUDIO_STR, GST_META_TAG_AUDIO_CHANNELS_STR, NULL };

Expand Down Expand Up @@ -280,7 +280,7 @@ gst_buffer_add_audio_clipping_meta (GstBuffer * buffer,
GType
gst_audio_clipping_meta_api_get_type (void)
{
static volatile GType type;
static GType type;
static const gchar *tags[] =
{ GST_META_TAG_AUDIO_STR, GST_META_TAG_AUDIO_RATE_STR, NULL };

Expand Down Expand Up @@ -463,7 +463,7 @@ gst_buffer_add_audio_meta (GstBuffer * buffer, const GstAudioInfo * info,
GType
gst_audio_meta_api_get_type (void)
{
static volatile GType type;
static GType type;
static const gchar *tags[] = {
GST_META_TAG_AUDIO_STR, GST_META_TAG_AUDIO_CHANNELS_STR,
GST_META_TAG_AUDIO_RATE_STR, NULL
Expand Down Expand Up @@ -505,7 +505,7 @@ gst_audio_meta_get_info (void)
GType
gst_audio_level_meta_api_get_type (void)
{
static volatile GType type = 0;
static GType type = 0;
static const gchar *tags[] = { NULL };

if (g_once_init_enter (&type)) {
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/audio/streamvolume.c
Expand Up @@ -66,7 +66,7 @@ gst_stream_volume_class_init (GstStreamVolumeInterface * iface)
GType
gst_stream_volume_get_type (void)
{
static volatile gsize type = 0;
static gsize type = 0;
if (g_once_init_enter (&type)) {
GType tmp;
static const GTypeInfo info = {
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/cocoa/gstglcaopengllayer.m
Expand Up @@ -33,7 +33,7 @@
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT(gst_gl_ca_opengl_layer_debug, "glcaopengllayer",
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/egl/gstgldisplay_egl.c
Expand Up @@ -74,7 +74,7 @@ static guintptr gst_gl_display_egl_get_handle (GstGLDisplay * display);
static void
init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "gldisplayegl", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gbm/gstgldisplay_gbm.c
Expand Up @@ -398,7 +398,7 @@ gst_gl_display_gbm_shutdown_gbm (GstGLDisplayGBM * display_gbm)
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (gst_gl_display_debug, "gldisplay");
Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gl_mkenum.py
Expand Up @@ -22,11 +22,11 @@
'--fprod',
"\n/* enumerations from \"@basename@\" */",
'--vhead',
"GType\n@enum_name@_get_type (void)\n{\n static volatile gsize g_define_type_id__volatile = 0;\n if (g_once_init_enter (&g_define_type_id__volatile)) {\n static const G@Type@Value values[] = {",
"GType\n@enum_name@_get_type (void)\n{\n static gsize static_g_define_type_id = 0;\n if (g_once_init_enter (&static_g_define_type_id)) {\n static const G@Type@Value values[] = {",
'--vprod',
" { C_@TYPE@ (@VALUENAME@), \"@VALUENAME@\", \"@valuenick@\" },",
'--vtail',
" { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);\n }\n return g_define_type_id__volatile;\n}\n"
" { 0, NULL, NULL }\n };\n GType g_define_type_id = g_@type@_register_static (\"@EnumName@\", values);\n g_once_init_leave (&static_g_define_type_id, g_define_type_id);\n }\n return static_g_define_type_id;\n}\n"
]

cmd = []
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglbasememory.c
Expand Up @@ -503,7 +503,7 @@ _mem_free (GstAllocator * allocator, GstMemory * memory)
void
gst_gl_base_memory_init_once (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_GL_BASE_MEMORY, "glbasememory", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglbuffer.c
Expand Up @@ -457,7 +457,7 @@ gst_gl_buffer_allocator_init (GstGLBufferAllocator * allocator)
void
gst_gl_buffer_init_once (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
gst_gl_base_memory_init_once ();
Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglcontext.c
Expand Up @@ -150,7 +150,7 @@ load_self_module (gpointer user_data)
*/
struct ContextShareGroup
{
volatile int refcount;
int refcount;
};

static struct ContextShareGroup *
Expand Down Expand Up @@ -305,7 +305,7 @@ gst_gl_context_class_init (GstGLContextClass * klass)
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_context_debug, "glcontext", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstgldebug.c
Expand Up @@ -105,7 +105,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_marker_debug);
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_GET (gst_performance, "GST_PERFORMANCE");
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstgldisplay.c
Expand Up @@ -277,7 +277,7 @@ gst_gl_display_new (void)
{
GstGLDisplay *display = NULL;
const gchar *user_choice, *platform_choice;
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_display_debug, "gldisplay", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglfeature.c
Expand Up @@ -43,7 +43,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glfeature", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglmemory.c
Expand Up @@ -1109,7 +1109,7 @@ gst_gl_memory_get_texture_id (GstGLMemory * gl_mem)
void
gst_gl_memory_init_once (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
gst_gl_base_memory_init_once ();
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglmemorypbo.c
Expand Up @@ -818,7 +818,7 @@ gst_gl_memory_pbo_upload_transfer (GstGLMemoryPBO * gl_mem)
void
gst_gl_memory_pbo_init_once (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
gst_gl_memory_init_once ();
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglquery.c
Expand Up @@ -58,7 +58,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glquery", 0, "glquery element");
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglrenderbuffer.c
Expand Up @@ -312,7 +312,7 @@ gst_gl_renderbuffer_get_id (GstGLRenderbuffer * gl_mem)
void
gst_gl_renderbuffer_init_once (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
gst_gl_base_memory_init_once ();
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglsl.c
Expand Up @@ -40,7 +40,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glsl", 0,
Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglsyncmeta.c
Expand Up @@ -333,7 +333,7 @@ static gboolean
_gst_gl_sync_meta_init (GstGLSyncMeta * sync_meta, gpointer params,
GstBuffer * buffer)
{
static volatile gsize _init;
static gsize _init;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_sync_meta_debug, "glsyncmeta", 0,
Expand All @@ -359,7 +359,7 @@ _gst_gl_sync_meta_init (GstGLSyncMeta * sync_meta, gpointer params,
GType
gst_gl_sync_meta_api_get_type (void)
{
static volatile GType type = 0;
static GType type = 0;
static const gchar *tags[] = { NULL };

if (g_once_init_enter (&type)) {
Expand Down
4 changes: 2 additions & 2 deletions gst-libs/gst/gl/gstglutils.c
Expand Up @@ -56,7 +56,7 @@ GST_DEBUG_CATEGORY_STATIC (gst_gl_utils_debug);
static GstDebugCategory *
_init_gl_utils_debug_category (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_utils_debug, "glutils", 0,
Expand Down Expand Up @@ -87,7 +87,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");
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/gstglwindow.c
Expand Up @@ -160,7 +160,7 @@ gst_gl_window_default_close (GstGLWindow * window)
static void
_init_debug (void)
{
static volatile gsize _init = 0;
static gsize _init = 0;

if (g_once_init_enter (&_init)) {
GST_DEBUG_CATEGORY_INIT (gst_gl_window_debug, "glwindow", 0,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/gl/wayland/wayland_event_source.c
Expand Up @@ -45,7 +45,7 @@ GST_DEBUG_CATEGORY_STATIC (GST_CAT_DEFAULT);
static void
init_debug (void)
{
static volatile gsize _debug;
static gsize _debug;

if (g_once_init_enter (&_debug)) {
GST_DEBUG_CATEGORY_INIT (GST_CAT_DEFAULT, "glwaylandeventsource", 0,
Expand Down
8 changes: 4 additions & 4 deletions gst-libs/gst/pbutils/encoding-profile.c
Expand Up @@ -360,9 +360,9 @@ gst_encoding_profile_class_intern_init (gpointer klass)
GType
gst_encoding_profile_get_type (void)
{
static volatile gsize g_define_type_id__volatile = 0;
static gsize g_define_type_id_init = 0;

if (g_once_init_enter (&g_define_type_id__volatile)) {
if (g_once_init_enter (&g_define_type_id_init)) {
GType g_define_type_id = g_type_register_static_simple (G_TYPE_OBJECT,
g_intern_static_string ("GstEncodingProfile"),
sizeof (GstEncodingProfileClass),
Expand All @@ -385,9 +385,9 @@ gst_encoding_profile_get_type (void)
/* Register gst-specific GValue functions */
gst_value_register (&gstvtable);

g_once_init_leave (&g_define_type_id__volatile, g_define_type_id);
g_once_init_leave (&g_define_type_id_init, g_define_type_id);
}
return g_define_type_id__volatile;
return g_define_type_id_init;
}


Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/pbutils/gstaudiovisualizer.c
Expand Up @@ -499,7 +499,7 @@ gst_audio_visualizer_change_shader (GstAudioVisualizer * scope)
GType
gst_audio_visualizer_get_type (void)
{
static volatile gsize audio_visualizer_type = 0;
static gsize audio_visualizer_type = 0;

if (g_once_init_enter (&audio_visualizer_type)) {
static const GTypeInfo audio_visualizer_info = {
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/rtp/gstrtpmeta.c
Expand Up @@ -190,7 +190,7 @@ gst_rtp_source_meta_append_csrc (GstRTPSourceMeta * meta, const guint32 * csrc,
GType
gst_rtp_source_meta_api_get_type (void)
{
static volatile GType type = 0;
static GType type = 0;
static const gchar *tags[] = { NULL };

if (g_once_init_enter (&type)) {
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/rtsp/gstrtspextension.c
Expand Up @@ -49,7 +49,7 @@ static guint gst_rtsp_extension_signals[LAST_SIGNAL] = { 0 };
GType
gst_rtsp_extension_get_type (void)
{
static volatile gsize gst_rtsp_extension_type = 0;
static gsize gst_rtsp_extension_type = 0;
static const GTypeInfo gst_rtsp_extension_info = {
sizeof (GstRTSPExtensionInterface),
(GBaseInitFunc) gst_rtsp_extension_iface_init,
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/tag/gsttagmux.c
Expand Up @@ -90,7 +90,7 @@ static gboolean gst_tag_mux_sink_event (GstPad * pad, GstObject * parent,
GType
gst_tag_mux_get_type (void)
{
static volatile gsize tag_mux_type = 0;
static gsize tag_mux_type = 0;

if (g_once_init_enter (&tag_mux_type)) {
const GInterfaceInfo interface_info = { NULL, NULL, NULL };
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/tag/xmpwriter.c
Expand Up @@ -53,7 +53,7 @@ typedef struct
GType
gst_tag_xmp_writer_get_type (void)
{
static volatile gsize xmp_config_type = 0;
static gsize xmp_config_type = 0;

if (g_once_init_enter (&xmp_config_type)) {
GType _type;
Expand Down
2 changes: 1 addition & 1 deletion gst-libs/gst/video/gstvideoaffinetransformationmeta.c
Expand Up @@ -36,7 +36,7 @@
GType
gst_video_affine_transformation_meta_api_get_type (void)
{
static volatile GType type = 0;
static GType type = 0;
static const gchar *tags[] =
{ GST_META_TAG_VIDEO_STR, GST_META_TAG_VIDEO_ORIENTATION_STR,
GST_META_TAG_VIDEO_ORIENTATION_STR, NULL
Expand Down

0 comments on commit 98249a5

Please sign in to comment.