Commit 3f35c517 authored by Laurent Aimar's avatar Laurent Aimar
Browse files

Fixed filters implemented as vout (Init/End can be called multiple times

+ use vout_Destroy where it should be)
It closes #1722.
parent dd066314
......@@ -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] );
}
}
......
......@@ -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;
......
......@@ -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 );
......
......@@ -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 );
......
......@@ -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 );
}
......
......@@ -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 )
......
......@@ -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 );
}
}
}
......
......@@ -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 );
}
......
......@@ -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;
......
......@@ -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 );
}
......
......@@ -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 );
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment