]> git.sesse.net Git - vlc/blobdiff - modules/video_output/opengl.c
opengl: fix an crash/hang on exit because opengl needs the init and end to be done...
[vlc] / modules / video_output / opengl.c
index 2cff793f71e372aa93614dd9a67deaa5e7711382..04432a00746755052d06e85b8be20864f1626e6c 100644 (file)
@@ -196,26 +196,6 @@ static int CreateVout( vlc_object_t *p_this )
     var_Create( p_sys->p_vout, "video-deco",
                 VLC_VAR_BOOL | VLC_VAR_DOINHERIT );
 
-    psz = var_CreateGetString( p_vout, "opengl-provider" );
-    p_sys->p_vout->p_module =
-        module_need( p_sys->p_vout, "opengl provider", psz, false );
-    free( psz );
-    if( p_sys->p_vout->p_module == NULL )
-    {
-        msg_Warn( p_vout, "No OpenGL provider found" );
-        vlc_object_detach( p_sys->p_vout );
-        vlc_object_release( p_sys->p_vout );
-        free( p_sys );
-        return VLC_ENOOBJ;
-    }
-
-    p_vout->pf_init = Init;
-    p_vout->pf_end = End;
-    p_vout->pf_manage = Manage;
-    p_vout->pf_render = Render;
-    p_vout->pf_display = DisplayVideo;
-    p_vout->pf_control = Control;
-
     /* Forward events from the opengl provider */
     var_Create( p_sys->p_vout, "mouse-x", VLC_VAR_INTEGER );
     var_Create( p_sys->p_vout, "mouse-y", VLC_VAR_INTEGER );
@@ -234,9 +214,31 @@ static int CreateVout( vlc_object_t *p_this )
     var_AddCallback( p_sys->p_vout, "mouse-moved", SendEvents, p_vout );
     var_AddCallback( p_sys->p_vout, "mouse-clicked", SendEvents, p_vout );
     var_AddCallback( p_sys->p_vout, "mouse-button-down", SendEvents, p_vout );
+    var_AddCallback( p_sys->p_vout, "video-on-top", SendEvents, p_vout );
     var_AddCallback( p_vout, "autoscale", SendEvents, p_sys->p_vout );
     var_AddCallback( p_vout, "scale", SendEvents, p_sys->p_vout );
 
+    psz = var_CreateGetString( p_vout, "opengl-provider" );
+    p_sys->p_vout->p_module =
+        module_need( p_sys->p_vout, "opengl provider", psz, false );
+    free( psz );
+    if( p_sys->p_vout->p_module == NULL )
+    {
+        msg_Warn( p_vout, "No OpenGL provider found" );
+        vlc_object_detach( p_sys->p_vout );
+        /* no need for var_DelCallback here :-) */
+        vlc_object_release( p_sys->p_vout );
+        free( p_sys );
+        return VLC_ENOOBJ;
+    }
+
+    p_vout->pf_init = Init;
+    p_vout->pf_end = End;
+    p_vout->pf_manage = Manage;
+    p_vout->pf_render = Render;
+    p_vout->pf_display = DisplayVideo;
+    p_vout->pf_control = Control;
+
     return VLC_SUCCESS;
 }
 
@@ -386,6 +388,11 @@ static void End( vout_thread_t *p_vout )
     {
         p_sys->p_vout->pf_unlock( p_sys->p_vout );
     }
+
+    /* We must release the opengl provider here: opengl requiere init and end
+       to be done in the same thread */
+    module_unneed( p_sys->p_vout, p_sys->p_vout->p_module );
+    vlc_object_release( p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -398,9 +405,6 @@ static void DestroyVout( vlc_object_t *p_this )
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_sys_t *p_sys = p_vout->p_sys;
 
-    module_unneed( p_sys->p_vout, p_sys->p_vout->p_module );
-    vlc_object_release( p_sys->p_vout );
-
     free( p_sys );
 }