[vlc-devel] [PATCH 2/7] video output: use vlc_interrupt_t for termination

Alexandre Janniaux ajanni at videolabs.io
Wed Feb 10 11:23:18 UTC 2021


Use the vlc_interrupt_t state to determine whether we were killed
instead of an ad-hoc atomic boolean. No functional change since the
interrupt is created/killed at the same location the atomic was set
previously, and it uses the same kind of atomic operation internally.
---
 src/video_output/video_output.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)

diff --git a/src/video_output/video_output.c b/src/video_output/video_output.c
index d1eaf81242..77658e287d 100644
--- a/src/video_output/video_output.c
+++ b/src/video_output/video_output.c
@@ -99,7 +99,6 @@ typedef struct vout_thread_sys_t
 
     /* Thread & synchronization */
     vout_control_t  control;
-    atomic_bool     control_is_terminated; // shutdown the vout thread
     vlc_thread_t    thread;
 
     struct {
@@ -1778,17 +1777,17 @@ static void *Thread(void *object)
 
         vlc_mouse_t video_mouse;
         while (vout_control_Pop(&sys->control, &video_mouse, deadline) == VLC_SUCCESS) {
-            if (atomic_load(&sys->control_is_terminated))
+            if (vlc_killed())
                 break;
             ThreadProcessMouseState(vout, &video_mouse);
         }
 
-        if (atomic_load(&sys->control_is_terminated))
+        if (vlc_killed())
             break;
 
         wait = ThreadDisplayPicture(vout, &deadline) != VLC_SUCCESS;
 
-        if (atomic_load(&sys->control_is_terminated))
+        if (vlc_killed())
             break;
 
         const bool picture_interlaced = sys->displayed.is_interlaced;
@@ -1851,7 +1850,6 @@ void vout_StopDisplay(vout_thread_t *vout)
 {
     vout_thread_sys_t *sys = VOUT_THREAD_TO_SYS(vout);
 
-    atomic_store(&sys->control_is_terminated, true);
     vlc_interrupt_kill(sys->interrupt);
     // wake up so it goes back to the loop that will detect the terminated state
     vout_control_Wake(&sys->control);
@@ -2001,7 +1999,6 @@ vout_thread_t *vout_Create(vlc_object_t *object)
                spu_Create(vout, vout) : NULL;
 
     vout_control_Init(&sys->control);
-    atomic_init(&sys->control_is_terminated, false);
 
     sys->title.show     = var_InheritBool(vout, "video-title-show");
     sys->title.timeout  = var_InheritInteger(vout, "video-title-timeout");
@@ -2178,7 +2175,6 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
         vout_DisableWindow(vout);
         return -1;
     }
-    atomic_store(&sys->control_is_terminated, false);
     if (vlc_clone(&sys->thread, Thread, vout, VLC_THREAD_PRIORITY_OUTPUT)) {
         vout_ReleaseDisplay(vout);
         vout_DisableWindow(vout);
-- 
2.30.1



More information about the vlc-devel mailing list