// 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 );
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 );
+ }
}