-/*
- * mlt_consumer.c -- abstraction for all consumer services
- * Copyright (C) 2003-2004 Ushodaya Enterprises Limited
- * Author: Charles Yates <charles.yates@pandora.be>
+/**
+ * \file mlt_consumer.c
+ * \brief abstraction for all consumer services
+ *
+ * Copyright (C) 2003-2008 Ushodaya Enterprises Limited
+ * \author Charles Yates <charles.yates@pandora.be>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
static void mlt_consumer_property_changed( mlt_service owner, mlt_consumer this, char *name );
static void apply_profile_properties( mlt_consumer this, mlt_profile profile, mlt_properties properties );
-/** Public final methods
-*/
-
int mlt_consumer_init( mlt_consumer this, void *child, mlt_profile profile )
{
int error = 0;
{
// Get the properties from the service
mlt_properties properties = MLT_SERVICE_PROPERTIES( &this->parent );
-
+
// Apply profile to properties
if ( profile == NULL )
{
int frame_duration = 1000000 / mlt_properties_get_int( properties, "frame_rate_num" ) *
mlt_properties_get_int( properties, "frame_rate_den" );
mlt_properties_set_int( properties, "frame_duration", frame_duration );
-
+
// Check and run an ante command
if ( mlt_properties_get( properties, "ante" ) )
system( mlt_properties_get( properties, "ante" ) );
// Create the condition
pthread_cond_init( &this->cond, NULL );
- // Create the read ahead
- pthread_create( &this->ahead_thread, NULL, consumer_read_ahead_thread, this );
+ // Create the read ahead
+ 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 )
if ( buffer > 1 )
size = prefill > 0 && prefill < buffer ? prefill : buffer;
}
-
+
// Get frame from queue
pthread_mutex_lock( &this->mutex );
while( this->ahead && mlt_deque_count( this->queue ) < size )