[vlc-devel] [PATCH 1/4] video_output: move the window lock outside of the window enabling function

Rémi Denis-Courmont remi at remlab.net
Mon Jan 13 13:58:21 CET 2020


A function that does not take necessary locks is Unlocked, e.g. fputc vs fputc_unlocked. The names in this patch are misleading.

Le 13 janvier 2020 13:07:31 GMT+02:00, Steve Lhomme <robux4 at ycbcr.xyz> a écrit :
>---
> src/video_output/video_output.c | 15 +++++++++------
> 1 file changed, 9 insertions(+), 6 deletions(-)
>
>diff --git a/src/video_output/video_output.c
>b/src/video_output/video_output.c
>index 659ede546ba..53c6416a620 100644
>--- a/src/video_output/video_output.c
>+++ b/src/video_output/video_output.c
>@@ -1998,7 +1998,7 @@ int vout_ChangeSource( vout_thread_t *vout, const
>video_format_t *original )
>     return -1;
> }
> 
>-static int vout_EnableWindow(vout_thread_t *vout, const video_format_t
>*original,
>+static int EnableWindowLocked(vout_thread_t *vout, const
>video_format_t *original,
>                              vlc_decoder_device **pp_dec_device)
> {
>     vout_thread_sys_t *sys = vout->p;
>@@ -2006,7 +2006,6 @@ static int vout_EnableWindow(vout_thread_t *vout,
>const video_format_t *original
>     assert(!sys->dummy);
>     assert(vout != NULL);
> 
>-    vlc_mutex_lock(&sys->window_lock);
>     if (!sys->window_enabled) {
>         vout_window_cfg_t wcfg = {
>             .is_fullscreen = var_GetBool(vout, "fullscreen"),
>@@ -2022,7 +2021,6 @@ static int vout_EnableWindow(vout_thread_t *vout,
>const video_format_t *original
>         vout_SizeWindow(vout, original, &wcfg.width, &wcfg.height);
> 
>         if (vout_window_Enable(sys->display_cfg.window, &wcfg)) {
>-            vlc_mutex_unlock(&sys->window_lock);
>             msg_Err(vout, "failed to enable window");
>             return -1;
>         }
>@@ -2036,7 +2034,6 @@ static int vout_EnableWindow(vout_thread_t *vout,
>const video_format_t *original
>sys->dec_device = vlc_decoder_device_Create(&vout->obj,
>sys->display_cfg.window);
>*pp_dec_device = sys->dec_device ? vlc_decoder_device_Hold(
>sys->dec_device ) : NULL;
>     }
>-    vlc_mutex_unlock(&sys->window_lock);
>     return 0;
> }
> 
>@@ -2061,13 +2058,16 @@ int vout_Request(const vout_configuration_t
>*cfg, vlc_video_context *vctx, input
>         return 0;
>     }
> 
>-    if (vout_EnableWindow(vout, &original, NULL) != 0)
>+    vlc_mutex_lock(&sys->window_lock);
>+    if (EnableWindowLocked(vout, &original, NULL) != 0)
>     {
>         /* the window was not enabled, nor the display started */
>         msg_Err(vout, "failed to enable window");
>         video_format_Clean(&original);
>+        vlc_mutex_unlock(&sys->window_lock);
>         return -1;
>     }
>+    vlc_mutex_unlock(&sys->window_lock);
> 
>     if (sys->display != NULL)
>         vout_StopDisplay(vout);
>@@ -2105,6 +2105,7 @@ vlc_decoder_device *vout_GetDevice(const
>vout_device_configuration_t *cfg)
>     vlc_decoder_device *dec_device = NULL;
> 
>     assert(cfg->fmt != NULL);
>+    vout_thread_sys_t *sys = cfg->vout->p;
> 
>     if (!VoutCheckFormat(cfg->fmt))
>         return NULL;
>@@ -2112,7 +2113,9 @@ vlc_decoder_device *vout_GetDevice(const
>vout_device_configuration_t *cfg)
>     video_format_t original;
>     VoutFixFormat(&original, cfg->fmt);
> 
>-    int res = vout_EnableWindow(cfg->vout, &original, &dec_device);
>+    vlc_mutex_lock(&sys->window_lock);
>+    int res = EnableWindowLocked(cfg->vout, &original, &dec_device);
>+    vlc_mutex_unlock(&sys->window_lock);
>     video_format_Clean(&original);
>     if (res != 0)
>         return NULL;
>-- 
>2.17.1
>
>_______________________________________________
>vlc-devel mailing list
>To unsubscribe or modify your subscription options:
>https://mailman.videolan.org/listinfo/vlc-devel

-- 
Envoyé de mon appareil Android avec Courriel K-9 Mail. Veuillez excuser ma brièveté.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20200113/97d3a9f6/attachment.html>


More information about the vlc-devel mailing list