X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fcrop.c;h=e220268f3979ebfbe8b3e3f54ed0589caa32e5ae;hb=3f35c5171d9181434ebb16ffbdec7f7d62c28b8d;hp=cb5fd1d525b6c76dba60df7f114d500958bff0da;hpb=42bb236284b09355d8bfde47fb4915dd1f07aa68;p=vlc diff --git a/modules/video_filter/crop.c b/modules/video_filter/crop.c index cb5fd1d525..e220268f39 100644 --- a/modules/video_filter/crop.c +++ b/modules/video_filter/crop.c @@ -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; @@ -501,7 +504,7 @@ static void Render( vout_thread_t *p_vout, picture_t *p_pic ) vout_CreatePicture( p_vout->p_sys->p_vout, 0, 0, 0 ) ) == NULL ) { - if( p_vout->b_die || p_vout->b_error ) + if( !vlc_object_alive (p_vout) || p_vout->b_error ) { vout_DestroyPicture( p_vout->p_sys->p_vout, p_outpic ); return;