]> git.sesse.net Git - mlt/commitdiff
mlt_consumer.c: added ability to set priority of the read-ahead thread through a...
authorddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 30 Jun 2008 01:50:06 +0000 (01:50 +0000)
committerddennedy <ddennedy@d19143bc-622f-0410-bfdd-b5b2a6649095>
Mon, 30 Jun 2008 01:50:06 +0000 (01:50 +0000)
git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1153 d19143bc-622f-0410-bfdd-b5b2a6649095

src/framework/mlt_consumer.c

index 7d1d4af60016bf1e6256d26e5bd51f05d5cd654e..de126e0825b4ca6d312285df6276b6f593c4c145 100644 (file)
@@ -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 )