[vlc-commits] [Git][videolan/vlc][master] video_output: reset clock on display error

Jean-Baptiste Kempf (@jbk) gitlab at videolan.org
Sun Mar 5 15:37:35 UTC 2023



Jean-Baptiste Kempf pushed to branch master at VideoLAN / VLC


Commits:
fc213d43 by Alexandre Janniaux at 2023-03-05T15:14:00+00:00
video_output: reset clock on display error

The member sys->clock is assigned from the vout_Request to the decoder
clock, and was assigned back to NULL when the vout was stopped.

However, when the decoder_UpdateVideoOutput call would fail because of
the display, the clock would have been assigned to the video output and
vout_Stop would never be called since the vout was never started,
leading to the sys->clock member being unexpectedly non-null when
starting the video output.

 1/ Creation of the first decoder.
 2/ Decoder_UpdateVideoOutput() is called from the decoder.
 3/ Calling input_resource_RequestVout with first decoder clock.
 4/ Display fails to open, but sys->clock is now non-null.
 5/ Close of the first ES / decoder, sys->clock is destroyed.
 6/ Creation of a second decoder.
 7/ Decoder_UpdateVideoOutput() is called from the second decoder.
 8/ Calling input_resource_RequestVout with the second decoder clock.
 9/ If the window synchronously reports a size, then the previous
    released clock is used and it crashes.

The clock must either be NULL when failing to open the vout or assigned
before the window is started.

Having the clock being NULL when enabling the window is handy because it
won't trigger an interrupt of the clock for nothing, but also the
additional lock will still happen only on error, when no other client is
using the clock lock anyway.

Indirect regression from 316fb5633f8ed100eabebedde958d71536a0ff09.

Fixes #27756

- - - - -


1 changed file:

- src/video_output/video_output.c


Changes:

=====================================
src/video_output/video_output.c
=====================================
@@ -2198,20 +2198,25 @@ int vout_Request(const vout_configuration_t *cfg, vlc_video_context *vctx, input
     if (vout_Start(vout, vctx, cfg))
     {
         msg_Err(cfg->vout, "video output display creation failed");
-        vout_DisableWindow(vout);
-        return -1;
+        goto error_display;
     }
     atomic_store(&sys->control_is_terminated, false);
-    if (vlc_clone(&sys->thread, Thread, vout)) {
-        vout_ReleaseDisplay(vout);
-        vout_DisableWindow(vout);
-        return -1;
-    }
+    if (vlc_clone(&sys->thread, Thread, vout))
+        goto error_thread;
 
     if (input != NULL && sys->spu)
         spu_Attach(sys->spu, input);
     vout_IntfReinit(cfg->vout);
     return 0;
+
+error_thread:
+    vout_ReleaseDisplay(vout);
+error_display:
+    vout_DisableWindow(vout);
+    vlc_mutex_lock(&sys->clock_lock);
+    sys->clock = NULL;
+    vlc_mutex_unlock(&sys->clock_lock);
+    return -1;
 }
 
 vlc_decoder_device *vout_GetDevice(vout_thread_t *vout)



View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fc213d43090c24d3eb77031ec4acb66ef38978f6

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/commit/fc213d43090c24d3eb77031ec4acb66ef38978f6
You're receiving this email because of your account on code.videolan.org.


VideoLAN code repository instance


More information about the vlc-commits mailing list