]> git.sesse.net Git - vlc/blobdiff - modules/video_filter/wrapper.c
Use calloc.
[vlc] / modules / video_filter / wrapper.c
index a2e351d11e69e99da21c69132e365d19b220fc2c..9271c9723788b59b18ac327a027349447ce8ef32 100644 (file)
@@ -50,7 +50,10 @@ static void Close( vlc_object_t * );
 DECLARE_OPEN(magnify, true)
 DECLARE_OPEN(puzzle, true)
 DECLARE_OPEN(logo, true)
+
 DECLARE_OPEN(clone, false)
+DECLARE_OPEN(wall, false)
+DECLARE_OPEN(panoramix, false)
 
 #undef DECLARE_OPEN
 
@@ -76,6 +79,12 @@ vlc_module_begin()
     add_submodule()
     DECLARE_MODULE(clone)
 
+    add_submodule()
+    DECLARE_MODULE(wall)
+
+    add_submodule()
+    DECLARE_MODULE(panoramix)
+
 vlc_module_end()
 
 #undef DECLARE_MODULE
@@ -136,12 +145,8 @@ static int Open( vlc_object_t *p_this, const char *psz_name, bool b_filter )
     es_format_Init( &fmt, VIDEO_ES, p_vout->render.i_chroma );
     video_format_Setup( &fmt.video, p_vout->render.i_chroma,
                         p_vout->render.i_width, p_vout->render.i_height,
-                        p_vout->render.i_aspect );
-    if( fmt.video.i_sar_num <= 0 || fmt.video.i_sar_den <= 0 )
-    {
-        fmt.video.i_sar_num = fmt.video.i_aspect * fmt.video.i_visible_height;
-        fmt.video.i_sar_den = VOUT_ASPECT_FACTOR * fmt.video.i_visible_width;
-    }
+                        p_vout->render.i_aspect * p_vout->render.i_height,
+                        VOUT_ASPECT_FACTOR      * p_vout->render.i_width );
 
     /* Try to open our real module */
     filter_chain_t   *p_chain = NULL;
@@ -274,22 +279,25 @@ static int Init( vout_thread_t *p_vout )
     {
         video_splitter_t *p_splitter = p_sys->p_splitter;
 
+        /* */
+        const int i_org_align = var_CreateGetInteger( p_vout, "align" );
+        const int i_org_x = var_CreateGetInteger( p_vout, "video-x" );
+        const int i_org_y = var_CreateGetInteger( p_vout, "video-y" );
+        const char *psz_org_vout = var_CreateGetNonEmptyString( p_vout, "vout" );
+
+        /* */
         for( int i = 0; i < p_splitter->i_output; i++ )
         {
             const video_splitter_output_t *p_cfg = &p_splitter->p_output[i];
 
             /* */
-            var_Create( p_vout, "align", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
             var_SetInteger( p_vout, "align", p_cfg->window.i_align);
 
-            var_Create( p_vout, "video-x", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-            var_SetInteger( p_vout, "video-x", p_cfg->window.i_x );
+            var_SetInteger( p_vout, "video-x", i_org_x + p_cfg->window.i_x );
+            var_SetInteger( p_vout, "video-y", i_org_y + p_cfg->window.i_y );
 
-            var_Create( p_vout, "video-y", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT );
-            var_SetInteger( p_vout, "video-y", p_cfg->window.i_y );
-
-            var_Create( p_vout, "vout", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
-            var_SetString( p_vout, "vout", p_cfg->psz_module ? p_cfg->psz_module : "" );
+            if( p_cfg->psz_module )
+                var_SetString( p_vout, "vout", p_cfg->psz_module );
 
             /* */
             video_format_t fmt = p_cfg->fmt;
@@ -300,11 +308,18 @@ static int Init( vout_thread_t *p_vout )
                 VoutsClean( p_vout, i );
                 return VLC_EGENERIC;
             }
+        }
 
+        /* Attach once pp_vout is completly field to avoid race conditions */
+        for( int i = 0; i < p_splitter->i_output; i++ )
             vout_filter_SetupChild( p_vout, p_sys->pp_vout[i],
                                     MouseEvent,
                                     FullscreenEventUp, FullscreenEventDown, true );
-        }
+        /* Restore settings */
+        var_SetInteger( p_vout, "align", i_org_align );
+        var_SetInteger( p_vout, "video-x", i_org_x );
+        var_SetInteger( p_vout, "video-y", i_org_y );
+        var_SetString( p_vout, "vout", psz_org_vout ? psz_org_vout : "" );
     }
 
     vout_filter_AllocateDirectBuffers( p_vout, VOUT_MAX_PICTURES );
@@ -375,21 +390,19 @@ static void VoutsClean( vout_thread_t *p_vout, int i_count )
 {
     vout_sys_t *p_sys = p_vout->p_sys;
 
+    /* Detach all vouts before destroying them */
     for( int i = 0; i < i_count; i++ )
     {
         if( p_sys->p_chain )
-        {
-            assert( i == 0 );
             vout_filter_DelChild( p_vout, p_sys->pp_vout[i], MouseEvent );
-        }
         else
-        {
              vout_filter_SetupChild( p_vout, p_sys->pp_vout[i],
                                      MouseEvent,
                                      FullscreenEventUp, FullscreenEventDown, false );
-        }
-        vout_CloseAndRelease( p_sys->pp_vout[i] );
     }
+
+    for( int i = 0; i < i_count; i++ )
+        vout_CloseAndRelease( p_sys->pp_vout[i] );
 }
 static int VoutsNewPicture( vout_thread_t *p_vout, picture_t *pp_dst[] )
 {
@@ -423,6 +436,7 @@ static int VoutsNewPicture( vout_thread_t *p_vout, picture_t *pp_dst[] )
 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(psz_var); VLC_UNUSED(oldval); VLC_UNUSED(newval);
     vout_thread_t *p_vout = p_data;
     vout_sys_t *p_sys = p_vout->p_sys;
     int i_index;
@@ -512,16 +526,16 @@ static int FilterAllocationInit( filter_t *p_filter, void *p_data )
 {
     VLC_UNUSED( p_data );
 
-    p_filter->pf_vout_buffer_new = VideoBufferNew;
-    p_filter->pf_vout_buffer_del = VideoBufferDelete;
+    p_filter->pf_video_buffer_new = VideoBufferNew;
+    p_filter->pf_video_buffer_del = VideoBufferDelete;
     p_filter->p_owner = p_data;
 
     return VLC_SUCCESS;
 }
 static void FilterAllocationClean( filter_t *p_filter )
 {
-    p_filter->pf_vout_buffer_new = NULL;
-    p_filter->pf_vout_buffer_del = NULL;
+    p_filter->pf_video_buffer_new = NULL;
+    p_filter->pf_video_buffer_del = NULL;
 }
 
 /* -- Splitter callbacks -- */
@@ -584,6 +598,7 @@ static int  SplitterPictureNew( video_splitter_t *p_splitter, picture_t *pp_pict
 }
 static void SplitterPictureDel( video_splitter_t *p_splitter, picture_t *pp_picture[] )
 {
+    VLC_UNUSED(p_splitter); VLC_UNUSED(pp_picture);
     /* FIXME is there anything to do ? */
 }