]> git.sesse.net Git - mlt/commitdiff
Qualify queue, mutex, and cond vars with frame_queue_.
authorDan Dennedy <dan@dennedy.org>
Wed, 17 Feb 2010 06:48:15 +0000 (22:48 -0800)
committerDan Dennedy <dan@dennedy.org>
Mon, 24 Jan 2011 02:09:43 +0000 (18:09 -0800)
src/framework/mlt_consumer.c
src/framework/mlt_consumer.h

index bcd44896e7bca37c43263bf20e5cfa505f692c03..f393b8e8614a8ebf4ad479030ace8f62a2749711 100644 (file)
@@ -681,12 +681,12 @@ static void *consumer_read_ahead_thread( void *arg )
                height = mlt_properties_get_int( properties, "height" );
 
                // Put the current frame into the queue
-               pthread_mutex_lock( &this->mutex );
-               while( this->ahead && mlt_deque_count( this->queue ) >= buffer )
-                       pthread_cond_wait( &this->cond, &this->mutex );
-               mlt_deque_push_back( this->queue, frame );
-               pthread_cond_broadcast( &this->cond );
-               pthread_mutex_unlock( &this->mutex );
+               pthread_mutex_lock( &this->frame_queue_mutex );
+               while( this->ahead && mlt_deque_count( this->frame_queue ) >= buffer )
+                       pthread_cond_wait( &this->frame_queue_cond, &this->frame_queue_mutex );
+               mlt_deque_push_back( this->frame_queue, frame );
+               pthread_cond_broadcast( &this->frame_queue_cond );
+               pthread_mutex_unlock( &this->frame_queue_mutex );
 
                time_wait += time_difference( &ante );
 
@@ -760,7 +760,7 @@ static void *consumer_read_ahead_thread( void *arg )
                time_process += time_difference( &ante );
 
                // Determine if the next frame should be skipped
-               if ( mlt_deque_count( this->queue ) <= 5 )
+               if ( mlt_deque_count( this->frame_queue ) <= 5 )
                {
                        int frame_duration = mlt_properties_get_int( properties, "frame_duration" );
                        if ( ( ( time_wait + time_frame + time_process ) / count ) > frame_duration )
@@ -789,13 +789,13 @@ static void consumer_read_ahead_start( mlt_consumer this )
        this->ahead = 1;
 
        // Create the frame queue
-       this->queue = mlt_deque_init( );
+       this->frame_queue = mlt_deque_init( );
 
-       // Create the mutex
-       pthread_mutex_init( &this->mutex, NULL );
+       // Create the frame_queue mutex
+       pthread_mutex_init( &this->frame_queue_mutex, NULL );
 
        // Create the condition
-       pthread_cond_init( &this->cond, NULL );
+       pthread_cond_init( &this->frame_queue_cond, NULL );
 
        // Create the read ahead
        if ( mlt_properties_get( MLT_CONSUMER_PROPERTIES( this ), "priority" ) )
@@ -833,9 +833,9 @@ static void consumer_read_ahead_stop( mlt_consumer this )
                this->ahead = 0;
 
                // Broadcast to the condition in case it's waiting
-               pthread_mutex_lock( &this->mutex );
-               pthread_cond_broadcast( &this->cond );
-               pthread_mutex_unlock( &this->mutex );
+               pthread_mutex_lock( &this->frame_queue_mutex );
+               pthread_cond_broadcast( &this->frame_queue_cond );
+               pthread_mutex_unlock( &this->frame_queue_mutex );
 
                // Broadcast to the put condition in case it's waiting
                pthread_mutex_lock( &this->put_mutex );
@@ -845,18 +845,18 @@ static void consumer_read_ahead_stop( mlt_consumer this )
                // Join the thread
                pthread_join( this->ahead_thread, NULL );
 
-               // Destroy the mutex
-               pthread_mutex_destroy( &this->mutex );
+               // Destroy the frame queue mutex
+               pthread_mutex_destroy( &this->frame_queue_mutex );
 
                // Destroy the condition
-               pthread_cond_destroy( &this->cond );
+               pthread_cond_destroy( &this->frame_queue_cond );
 
                // Wipe the queue
-               while ( mlt_deque_count( this->queue ) )
-                       mlt_frame_close( mlt_deque_pop_back( this->queue ) );
+               while ( mlt_deque_count( this->frame_queue ) )
+                       mlt_frame_close( mlt_deque_pop_back( this->frame_queue ) );
 
                // Close the queue
-               mlt_deque_close( this->queue );
+               mlt_deque_close( this->frame_queue );
        }
 }
 
@@ -870,11 +870,11 @@ void mlt_consumer_purge( mlt_consumer this )
 {
        if ( this->ahead )
        {
-               pthread_mutex_lock( &this->mutex );
-               while ( mlt_deque_count( this->queue ) )
-                       mlt_frame_close( mlt_deque_pop_back( this->queue ) );
-               pthread_cond_broadcast( &this->cond );
-               pthread_mutex_unlock( &this->mutex );
+               pthread_mutex_lock( &this->frame_queue_mutex );
+               while ( mlt_deque_count( this->frame_queue ) )
+                       mlt_frame_close( mlt_deque_pop_back( this->frame_queue ) );
+               pthread_cond_broadcast( &this->frame_queue_cond );
+               pthread_mutex_unlock( &this->frame_queue_mutex );
        }
 }
 
@@ -913,12 +913,12 @@ mlt_frame mlt_consumer_rt_frame( mlt_consumer this )
                }
 
                // Get frame from queue
-               pthread_mutex_lock( &this->mutex );
-               while( this->ahead && mlt_deque_count( this->queue ) < size )
-                       pthread_cond_wait( &this->cond, &this->mutex );
-               frame = mlt_deque_pop_front( this->queue );
-               pthread_cond_broadcast( &this->cond );
-               pthread_mutex_unlock( &this->mutex );
+               pthread_mutex_lock( &this->frame_queue_mutex );
+               while( this->ahead && mlt_deque_count( this->frame_queue ) < size )
+                       pthread_cond_wait( &this->frame_queue_cond, &this->frame_queue_mutex );
+               frame = mlt_deque_pop_front( this->frame_queue );
+               pthread_cond_broadcast( &this->frame_queue_cond );
+               pthread_mutex_unlock( &this->frame_queue_mutex );
        }
        else
        {
index acd3916baedbfe9074899adae331d537bf6749b9..db0594d91fb318edacafa16b923456cc9c33713c 100644 (file)
@@ -103,10 +103,10 @@ struct mlt_consumer_s
        int real_time;
        int ahead;
        mlt_image_format format;
-       mlt_deque queue;
+       mlt_deque frame_queue;
        pthread_t ahead_thread;
-       pthread_mutex_t mutex;
-       pthread_cond_t cond;
+       pthread_mutex_t frame_queue_mutex;
+       pthread_cond_t frame_queue_cond;
        pthread_mutex_t put_mutex;
        pthread_cond_t put_cond;
        mlt_frame put;