X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_filter.c;h=37f91db3b8ed7cbd63660b0a907fb42d586fcb98;hb=519393231e6ab626f19bd01d4622d1c3759fcc93;hp=f140df52658eb011bc45e0651f4a02d3180264a9;hpb=4db14da139d0cce1807d5f3530b271238786b795;p=melted diff --git a/src/framework/mlt_filter.c b/src/framework/mlt_filter.c index f140df5..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 ); @@ -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 ); + } }