X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_filter.c;h=37f91db3b8ed7cbd63660b0a907fb42d586fcb98;hb=ebcbb3571620a43fe24b3f8fa0161096ef628dbe;hp=5aefd13b015580396ff4bc671fcb046c59d12ba1;hpb=2ff111fe322cfdea5b879dd7912a8a375af62aff;p=melted diff --git a/src/framework/mlt_filter.c b/src/framework/mlt_filter.c index 5aefd13..37f91db 100644 --- a/src/framework/mlt_filter.c +++ b/src/framework/mlt_filter.c @@ -44,6 +44,10 @@ int mlt_filter_init( mlt_filter this, void *child ) // Override the get_frame method service->get_frame = filter_get_frame; + // Define the destructor + service->close = ( mlt_destructor )mlt_filter_close; + service->close_object = this; + // Default in, out, track properties mlt_properties_set_position( properties, "in", 0 ); mlt_properties_set_position( properties, "out", 0 ); @@ -70,7 +74,7 @@ mlt_filter mlt_filter_new( ) mlt_service mlt_filter_service( mlt_filter this ) { - return &this->parent; + return this != NULL ? &this->parent : NULL; } /** Get the properties associated to this filter. @@ -192,9 +196,17 @@ static int filter_get_frame( mlt_service service, mlt_frame_ptr frame, int index void mlt_filter_close( mlt_filter this ) { - if ( this->close != NULL ) - this->close( this ); - else - mlt_service_close( &this->parent ); - free( this ); + if ( this != NULL && mlt_properties_dec_ref( mlt_filter_properties( this ) ) <= 0 ) + { + if ( this->close != NULL ) + { + this->close( this ); + } + else + { + this->parent.close = NULL; + mlt_service_close( &this->parent ); + } + free( this ); + } }