mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-11 01:45:33 +00:00
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>
This commit is contained in:
parent
e1f6c37b46
commit
d270654c48
17 changed files with 32 additions and 32 deletions
|
@ -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,
|
||||
|
|
|
@ -100,7 +100,7 @@ struct _GstVaapiContextInfo
|
|||
struct _GstVaapiContext
|
||||
{
|
||||
/*< private >*/
|
||||
volatile gint ref_count;
|
||||
gint ref_count;
|
||||
GstVaapiDisplay *display;
|
||||
GstVaapiID object_id;
|
||||
|
||||
|
|
|
@ -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[] = {
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -120,7 +120,7 @@ struct _GstVaapiMiniObject
|
|||
{
|
||||
/*< private >*/
|
||||
gconstpointer object_class;
|
||||
volatile gint ref_count;
|
||||
gint ref_count;
|
||||
guint flags;
|
||||
};
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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");
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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");
|
||||
|
|
Loading…
Reference in a new issue