]> git.sesse.net Git - vlc/commitdiff
Fixed filters implemented as vout (Init/End can be called multiple times
authorLaurent Aimar <fenrir@videolan.org>
Thu, 17 Jul 2008 17:58:44 +0000 (19:58 +0200)
committerLaurent Aimar <fenrir@videolan.org>
Thu, 17 Jul 2008 18:00:46 +0000 (20:00 +0200)
+ use vout_Destroy where it should be)
It closes #1722.

modules/video_filter/clone.c
modules/video_filter/crop.c
modules/video_filter/deinterlace.c
modules/video_filter/logo.c
modules/video_filter/magnify.c
modules/video_filter/opencv_wrapper.c
modules/video_filter/panoramix.c
modules/video_filter/puzzle.c
modules/video_filter/swscale.c
modules/video_filter/transform.c
modules/video_filter/wall.c

index 3b558d3b1825731414f3fe57200a6bac419e8970..368f7d5b8b58403847e94b448fa5997a1ba20e1a 100644 (file)
@@ -285,12 +285,16 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    RemoveAllVout( p_vout );
 }
 
 /*****************************************************************************
@@ -302,10 +306,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    RemoveAllVout( p_vout );
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys->pp_vout );
     free( p_vout->p_sys );
 }
@@ -387,8 +387,7 @@ static void RemoveAllVout( vout_thread_t *p_vout )
          --p_vout->p_sys->i_clones;
          DEL_CALLBACKS( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones],
                         SendEvents );
-         vlc_object_detach( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
-         vlc_object_release( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
+         vout_Destroy( p_vout->p_sys->pp_vout[p_vout->p_sys->i_clones] );
     }
 }
 
index e477c5c337d49d2a65591012b43427050a7c519a..e220268f3979ebfbe8b3e3f54ed0589caa32e5ae 100644 (file)
@@ -380,14 +380,14 @@ static int Init( vout_thread_t *p_vout )
         return VLC_EGENERIC;
     }
 
-    ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
-
-    ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
 #ifdef BEST_AUTOCROP
     var_AddCallback( p_vout, "ratio-crop", FilterCallback, NULL );
 #endif
 
+    ALLOCATE_DIRECTBUFFERS( VOUT_MAX_PICTURES );
+
+    ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     ADD_PARENT_CALLBACKS( SendEventsToChild );
 
     return VLC_SUCCESS;
@@ -400,12 +400,19 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+    if( p_vout->p_sys->p_vout )
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    if( p_vout->p_sys->p_vout )
+        vout_Destroy( p_vout->p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -417,15 +424,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys );
 }
 
@@ -455,7 +453,11 @@ static int Manage( vout_thread_t *p_vout )
     msg_Info( p_vout, "ratio %d",  p_vout->p_sys->i_aspect / 432);
 #endif
 
-    vlc_object_release( p_vout->p_sys->p_vout );
+    if( p_vout->p_sys->p_vout )
+    {
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+        vout_Destroy( p_vout->p_sys->p_vout );
+    }
 
     fmt.i_width = fmt.i_visible_width = p_vout->p_sys->i_width;
     fmt.i_height = fmt.i_visible_height = p_vout->p_sys->i_height;
@@ -473,6 +475,7 @@ static int Manage( vout_thread_t *p_vout )
                         _("VLC could not open the video output module.") );
         return VLC_EGENERIC;
     }
+    ADD_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
 
     p_vout->p_sys->b_changed = false;
     p_vout->p_sys->i_lastchange = 0;
index 26b8f0bfb3f832d2168cb50a20c6f519f917a08d..919e94e62793bfc1b9f5a6152999035929643d34 100644 (file)
@@ -420,6 +420,11 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    if( p_vout->p_sys->p_vout )
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -428,13 +433,7 @@ static void End( vout_thread_t *p_vout )
     }
 
     if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
+        vout_Destroy( p_vout->p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -2061,11 +2060,11 @@ static int FilterCallback( vlc_object_t *p_this, char const *psz_cmd,
     }
 
     /* We need to kill the old vout */
-
-    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-
-    vlc_object_detach( p_vout->p_sys->p_vout );
-    vlc_object_release( p_vout->p_sys->p_vout );
+    if( p_vout->p_sys->p_vout )
+    {
+        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+        vout_Destroy( p_vout->p_sys->p_vout );
+    }
 
     /* Try to open a new video output */
     p_vout->p_sys->p_vout = SpawnRealVout( p_vout );
index c6db247c9f0989b22eadaa64dd3f2f16e7f48a72..bf6bb52266d368e735df6fb5f87c83b05e580559 100644 (file)
@@ -475,6 +475,10 @@ static void End( vout_thread_t *p_vout )
     vout_sys_t *p_sys = p_vout->p_sys;
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    DEL_CALLBACKS( p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -485,9 +489,7 @@ static void End( vout_thread_t *p_vout )
     var_DelCallback( p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
     var_DelCallback( p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
 
-    DEL_CALLBACKS( p_sys->p_vout, SendEvents );
-    vlc_object_detach( p_sys->p_vout );
-    vlc_object_release( p_sys->p_vout );
+    vout_Destroy( p_sys->p_vout );
 
     if( p_sys->p_blend->p_module )
         module_Unneed( p_sys->p_blend, p_sys->p_blend->p_module );
@@ -503,7 +505,6 @@ static void Destroy( vlc_object_t *p_this )
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
     vout_sys_t *p_sys = p_vout->p_sys;
 
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
 
     FreeLogoList( p_sys->p_logo_list );
     free( p_sys->p_logo_list );
index 6b38557eb1ef63f1b1f6b99ddd83050490324bdc..a314050b73e804e434ae8eec9baf19d9424e0c6e 100644 (file)
@@ -186,6 +186,10 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -196,6 +200,8 @@ static void End( vout_thread_t *p_vout )
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-clicked", MouseEvent, p_vout);
+
+    vout_Destroy( p_vout->p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -205,16 +211,8 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
     image_HandlerDelete( p_vout->p_sys->p_image );
 
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
 
     free( p_vout->p_sys );
 }
index 24f1be84067548b44874bc431189aa9587c85b3b..b38e215c61ec821d04ed47fe52f7bf7709b6c161 100644 (file)
@@ -374,6 +374,10 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -391,6 +395,7 @@ static void End( vout_thread_t *p_vout )
         p_vout->p_sys->p_opencv = NULL;
     }
 
+    vout_Destroy( p_vout->p_sys->p_vout )
 }
 
 /*****************************************************************************
@@ -402,15 +407,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     ReleaseImages(p_vout);
 
     if( p_vout->p_sys->p_image )
index 91a067ff603763fa9aa26ec4cb4e918c3b1e45d7..eda2d7f07092737e780aed0b7fa0ccb4450487c9 100644 (file)
@@ -873,15 +873,20 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
-#ifdef OVERLAP
-    var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
-#endif
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    RemoveAllVout( p_vout );
+
+#ifdef OVERLAP
+    var_SetInteger( p_vout, "bz-length", p_vout->p_sys->bz_length);
+#endif
 }
 
 /*****************************************************************************
@@ -893,16 +898,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-#ifdef GLOBAL_OUTPUT
-    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents);
-    vlc_object_detach( p_vout->p_sys->p_vout );
-    vlc_object_release( p_vout->p_sys->p_vout );
-    DEL_PARENT_CALLBACKS( SendEventsToChild);
-#endif
-
-    RemoveAllVout( p_vout );
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys->pp_vout );
     free( p_vout->p_sys );
 
@@ -1908,10 +1903,7 @@ static void RemoveAllVout( vout_thread_t *p_vout )
              DEL_CALLBACKS(
                  p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
                  SendEvents );
-             vlc_object_detach(
-                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
-             vlc_object_release(
-                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
+             vout_Destroy( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
          }
     }
 }
index 3d62c771d77305b1a48be7b695fc3c055acad54c..a87c101523fe6d1feac9720d1742cbe15ac0fcde 100644 (file)
@@ -289,6 +289,10 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
@@ -299,6 +303,8 @@ static void End( vout_thread_t *p_vout )
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-x", MouseEvent, p_vout);
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-y", MouseEvent, p_vout);
     var_DelCallback( p_vout->p_sys->p_vout, "mouse-clicked", MouseEvent, p_vout);
+
+    vout_Destroy( p_vout->p_sys->p_vout );
 }
 
 #define SHUFFLE_WIDTH 81
@@ -327,18 +333,9 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
     image_HandlerDelete( p_vout->p_sys->p_image );
     free( p_vout->p_sys->pi_order );
 
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys );
 }
 
index 24d603416d741c4073c8c67f042b0c6fdcf904ad..3651b81e3aaba26346f294537f3c932fb2bdd76a 100644 (file)
@@ -191,6 +191,8 @@ static int OpenScaler( vlc_object_t *p_this )
         free( p_sys );
         return VLC_EGENERIC;
     }
+    if( p_sys->ctx ) sws_freeContext( p_sys->ctx );
+    p_sys->ctx = NULL;
 
     msg_Dbg( p_filter, "%ix%i chroma: %4.4s -> %ix%i chroma: %4.4s",
              p_filter->fmt_in.video.i_width, p_filter->fmt_in.video.i_height,
@@ -231,7 +233,8 @@ static int CheckInit( filter_t *p_filter )
     if( ( p_filter->fmt_in.video.i_width != p_sys->fmt_in.video.i_width ) ||
         ( p_filter->fmt_in.video.i_height != p_sys->fmt_in.video.i_height ) ||
         ( p_filter->fmt_out.video.i_width != p_sys->fmt_out.video.i_width ) ||
-        ( p_filter->fmt_out.video.i_height != p_sys->fmt_out.video.i_height ) )
+        ( p_filter->fmt_out.video.i_height != p_sys->fmt_out.video.i_height ) ||
+        !p_sys->ctx )
     {
         int i_fmt_in, i_fmt_out;
 
index dc880d2efc4d26464e9084986002ca1f13b81ce1..a8eee2c9b0ce0c21f58816effdad965dc7e44ab8 100644 (file)
@@ -276,12 +276,18 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
+    DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    vout_Destroy( p_vout->p_sys->p_vout );
 }
 
 /*****************************************************************************
@@ -293,15 +299,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    if( p_vout->p_sys->p_vout )
-    {
-        DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents );
-        vlc_object_detach( p_vout->p_sys->p_vout );
-        vlc_object_release( p_vout->p_sys->p_vout );
-    }
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
-
     free( p_vout->p_sys );
 }
 
index c5833bc67f85a39aae0ff29a7c24d48440f40a5a..aeec730bdc30289a3b511113f96f31b2238f1a74 100644 (file)
@@ -451,12 +451,16 @@ static void End( vout_thread_t *p_vout )
 {
     int i_index;
 
+    DEL_PARENT_CALLBACKS( SendEventsToChild );
+
     /* Free the fake output buffers we allocated */
     for( i_index = I_OUTPUTPICTURES ; i_index ; )
     {
         i_index--;
         free( PP_OUTPUTPICTURE[ i_index ]->p_data_orig );
     }
+
+    RemoveAllVout( p_vout );
 }
 
 /*****************************************************************************
@@ -468,9 +472,6 @@ static void Destroy( vlc_object_t *p_this )
 {
     vout_thread_t *p_vout = (vout_thread_t *)p_this;
 
-    RemoveAllVout( p_vout );
-
-    DEL_PARENT_CALLBACKS( SendEventsToChild );
 
     free( p_vout->p_sys->pp_vout );
     free( p_vout->p_sys );
@@ -583,10 +584,7 @@ static void RemoveAllVout( vout_thread_t *p_vout )
              DEL_CALLBACKS(
                  p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout,
                  SendEvents );
-             vlc_object_detach(
-                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
-             vlc_object_release(
-                 p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
+             vout_Destroy( p_vout->p_sys->pp_vout[ p_vout->p_sys->i_vout ].p_vout );
          }
     }
 }