X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fframework%2Fmlt_consumer.c;h=29f248eed10825bf6de7dfab9871cac731f3ed1e;hb=431b31b728b23fe9b35bf79a5d165876d581e6b8;hp=e353f63daba0e547948e23274f918e122f767aba;hpb=f00476101550ec7d8e863f6516aa83bc1b524570;p=melted diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index e353f63..29f248e 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -222,7 +222,7 @@ int mlt_consumer_put_frame( mlt_consumer this, mlt_frame frame ) tm.tv_nsec = now.tv_usec * 1000; pthread_cond_timedwait( &this->put_cond, &this->put_mutex, &tm ); } - if ( this->put == NULL ) + if ( !mlt_consumer_is_stopped( this ) && this->put == NULL ) this->put = frame; else mlt_frame_close( frame ); @@ -599,6 +599,11 @@ int mlt_consumer_stop( mlt_consumer this ) // Just in case... pthread_mutex_lock( &this->put_mutex ); + if ( this->put != NULL ) + { + mlt_frame_close( this->put ); + this->put = NULL; + } pthread_cond_broadcast( &this->put_cond ); pthread_mutex_unlock( &this->put_mutex ); @@ -609,12 +614,6 @@ int mlt_consumer_stop( mlt_consumer this ) if ( mlt_properties_get( properties, "post" ) ) system( mlt_properties_get( properties, "post" ) ); - if ( this->put != NULL ) - { - mlt_frame_close( this->put ); - this->put = NULL; - } - return 0; } @@ -640,19 +639,26 @@ void mlt_consumer_close( mlt_consumer this ) // Get the childs close function void ( *consumer_close )( ) = this->close; - // Make sure it only gets called once - this->close = NULL; - this->parent.close = NULL; - - // Destroy the push mutex and condition - pthread_cond_broadcast( &this->put_cond ); - pthread_mutex_destroy( &this->put_mutex ); - pthread_cond_destroy( &this->put_cond ); + if ( consumer_close ) + { + // Just in case... + mlt_consumer_stop( this ); - // Call the childs close if available - if ( consumer_close != NULL ) + this->close = NULL; consumer_close( this ); + } else + { + + // Make sure it only gets called once + this->parent.close = NULL; + + // Destroy the push mutex and condition + pthread_cond_broadcast( &this->put_cond ); + pthread_mutex_destroy( &this->put_mutex ); + pthread_cond_destroy( &this->put_cond ); + mlt_service_close( &this->parent ); + } } }