From: ddennedy Date: Wed, 4 Jun 2008 08:16:54 +0000 (+0000) Subject: mlt_playlist.c: added an "autoclose" property for sequential processing of very large... X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=467f981c523481500c5df1a12c4cf6f586c11ace;hp=ae6bde093802eb711b3f54c3f20e93d03fd04bed;p=melted mlt_playlist.c: added an "autoclose" property for sequential processing of very large playlists. If set, it automatically closes previous producers to reduce resources (file handles and threads if using producer_avformat with threads). git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1134 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_playlist.c b/src/framework/mlt_playlist.c index e2adc63..4183506 100644 --- a/src/framework/mlt_playlist.c +++ b/src/framework/mlt_playlist.c @@ -333,6 +333,36 @@ static mlt_service mlt_playlist_virtual_seek( mlt_playlist this, int *progressiv // Get the properties mlt_properties properties = MLT_PLAYLIST_PROPERTIES( this ); + // Automatically close previous producers if requested + if ( i > 1 // keep immediate previous in case app wants to get info about what just finished + && position < 2 // tolerate off-by-one error on going to next clip + && mlt_properties_get_int( properties, "autoclose" ) ) + { + int j; + // They might have jumped ahead! + for ( j = 0; j < i - 1; j++ ) + { + mlt_service_lock( MLT_PRODUCER_SERVICE( this->list[ j ]->producer ) ); + mlt_producer p = this->list[ j ]->producer; + if ( p ) + { + mlt_properties p_properties = MLT_PRODUCER_PROPERTIES( p ); + // Prevent closing previously autoclosed to maintain integrity of references + if ( ! mlt_properties_get_int( p_properties, "_autoclosed" ) ) + { + mlt_properties_set_int( p_properties, "_autoclosed", 1 ); + mlt_service_unlock( MLT_PRODUCER_SERVICE( p ) ); + mlt_producer_close( p ); + this->list[ j ]->producer = NULL; + } + else + { + mlt_service_unlock( MLT_PRODUCER_SERVICE( p ) ); + } + } + } + } + // Get the eof handling char *eof = mlt_properties_get( properties, "eof" );