From: ddennedy Date: Mon, 30 Jun 2008 01:50:06 +0000 (+0000) Subject: mlt_consumer.c: added ability to set priority of the read-ahead thread through a... X-Git-Url: http://research.m1stereo.tv/gitweb?a=commitdiff_plain;h=1664eeeaf8535e2b65f8715fc8ebd09c941fdee8;p=melted mlt_consumer.c: added ability to set priority of the read-ahead thread through a new "priority" property. This only works if you have permission; fails to execute properly otherwise - not sure how to make it fail over gracefully. Do not set this property if you do not have permission. git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1153 d19143bc-622f-0410-bfdd-b5b2a6649095 --- diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c index 7d1d4af..de126e0 100644 --- a/src/framework/mlt_consumer.c +++ b/src/framework/mlt_consumer.c @@ -659,7 +659,24 @@ static void consumer_read_ahead_start( mlt_consumer this ) pthread_cond_init( &this->cond, NULL ); // Create the read ahead - pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( this ), "priority" ) ) + { + struct sched_param priority; + priority.sched_priority = mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( this ), "priority" ); + pthread_attr_t thread_attributes; + pthread_attr_init( &thread_attributes ); + pthread_attr_setschedpolicy( &thread_attributes, SCHED_OTHER ); + pthread_attr_setschedparam( &thread_attributes, &priority ); + pthread_attr_setinheritsched( &thread_attributes, PTHREAD_EXPLICIT_SCHED ); + pthread_attr_setscope( &thread_attributes, PTHREAD_SCOPE_SYSTEM ); + if ( pthread_create( &this->ahead_thread, &thread_attributes, consumer_read_ahead_thread, this ) < 0 ) + pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + pthread_attr_destroy( &thread_attributes ); + } + else + { + pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this ); + } } static void consumer_read_ahead_stop( mlt_consumer this )