X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fvideo_filter%2Fcrop.c;h=67f0e5c3b8678fb0efcd87721b15418f891cccf1;hb=b5277240aa78e2515cc4f32ca4b582160b2ee8d8;hp=36881371d61b4663f0ea6393504d1a61698ef1e2;hpb=27d483e9ef7a451397d7857251c8d67097661f1d;p=vlc diff --git a/modules/video_filter/crop.c b/modules/video_filter/crop.c index 36881371d6..67f0e5c3b8 100644 --- a/modules/video_filter/crop.c +++ b/modules/video_filter/crop.c @@ -31,7 +31,7 @@ # include "config.h" #endif -#include +#include #include #include #include @@ -101,8 +101,8 @@ static int FilterCallback ( vlc_object_t *, char const *, #endif vlc_module_begin(); - set_description( _("Crop video filter") ); - set_shortname( _("Crop" )); + set_description( N_("Crop video filter") ); + set_shortname( N_("Crop" )); set_category( CAT_VIDEO ); set_subcategory( SUBCAT_VIDEO_VFILTER ); set_capability( "video filter", 0 ); @@ -183,10 +183,7 @@ static int Create( vlc_object_t *p_this ) /* Allocate structure */ p_vout->p_sys = malloc( sizeof( vout_sys_t ) ); if( p_vout->p_sys == NULL ) - { - msg_Err( p_vout, "out of memory" ); return VLC_ENOMEM; - } p_vout->pf_init = Init; p_vout->pf_end = End; @@ -383,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; @@ -403,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_CloseAndRelease( p_vout->p_sys->p_vout ); } /***************************************************************************** @@ -420,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 ); - vout_Destroy( p_vout->p_sys->p_vout ); - } - - DEL_PARENT_CALLBACKS( SendEventsToChild ); - free( p_vout->p_sys ); } @@ -458,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 - vout_Destroy( p_vout->p_sys->p_vout ); + if( p_vout->p_sys->p_vout ) + { + DEL_CALLBACKS( p_vout->p_sys->p_vout, SendEvents ); + vout_CloseAndRelease( 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; @@ -476,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; @@ -504,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;