[vlc-devel] [PATCH 07/20] vout: spu: use mutex instead of atomic

Thomas Guillem thomas at gllm.fr
Thu Jun 20 17:23:50 CEST 2019


For spu_ChangeMargin(), like every other setters of the spu API.

sys->margin is already read when the mutex is locked
---
 src/video_output/vout_subpictures.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/video_output/vout_subpictures.c b/src/video_output/vout_subpictures.c
index 6659771929..18a40f51a8 100644
--- a/src/video_output/vout_subpictures.c
+++ b/src/video_output/vout_subpictures.c
@@ -31,7 +31,6 @@
 
 #include <assert.h>
 #include <limits.h>
-#include <stdatomic.h>
 
 #include <vlc_common.h>
 #include <vlc_modules.h>
@@ -87,7 +86,7 @@ struct spu_private_t {
         int height;
     } crop;                                                  /**< cropping */
 
-    atomic_int margin;                 /**< force position of a subpicture */
+    int margin;                        /**< force position of a subpicture */
     video_palette_t palette;              /**< force palette of subpicture */
 
     /* Subpiture filters */
@@ -819,7 +818,7 @@ static void SpuRenderRegion(spu_t *spu,
      * requested (dvd menu) */
     int y_margin = 0;
     if (!crop_requested && subpic->b_subtitle)
-        y_margin = spu_invscale_h(atomic_load(&sys->margin), scale_size);
+        y_margin = spu_invscale_h(sys->margin, scale_size);
 
     /* Place the picture
      * We compute the position in the rendered size */
@@ -1423,7 +1422,7 @@ spu_t *spu_Create(vlc_object_t *object, vout_thread_t *vout)
     /* Initialize private fields */
     vlc_mutex_init(&sys->lock);
 
-    atomic_init(&sys->margin, var_InheritInteger(spu, "sub-margin"));
+    sys->margin = var_InheritInteger(spu, "sub-margin");
 
     sys->source_chain_update = NULL;
     sys->filter_chain_update = NULL;
@@ -1864,7 +1863,9 @@ void spu_ChangeMargin(spu_t *spu, int margin)
 {
     spu_private_t *sys = spu->p;
 
-    atomic_store(&sys->margin, margin);
+    vlc_mutex_lock(&sys->lock);
+    sys->margin = margin;
+    vlc_mutex_unlock(&sys->lock);
 }
 
 void spu_SetHighlight(spu_t *spu, const vlc_spu_highlight_t *hl)
-- 
2.20.1



More information about the vlc-devel mailing list