]> git.sesse.net Git - mlt/commitdiff
race condition fix
authorMaksym Veremeyenko <verem@m1stereo.tv>
Thu, 17 Oct 2013 06:17:29 +0000 (09:17 +0300)
committerDan Dennedy <dan@dennedy.org>
Fri, 25 Oct 2013 06:07:58 +0000 (23:07 -0700)
src/framework/mlt_consumer.c

index 5c640f29d128a68350b9557931a7275816dd341d..74b946d403641d0f5a48d4633dd26c743fb43580 100644 (file)
@@ -1044,6 +1044,9 @@ static void consumer_read_ahead_start( mlt_consumer self )
 {
        consumer_private *priv = self->local;
 
+       if ( priv->started )
+               return;
+
        // We're running now
        priv->ahead = 1;
 
@@ -1088,7 +1091,12 @@ static void consumer_work_start( mlt_consumer self )
 {
        consumer_private *priv = self->local;
        int n = abs( priv->real_time );
-       pthread_t *thread = calloc( 1, sizeof( pthread_t ) * n );
+       pthread_t *thread;
+
+       if ( priv->started )
+               return;
+
+       thread = calloc( 1, sizeof( pthread_t ) * n );
 
        // We're running now
        priv->ahead = 1;
@@ -1568,7 +1576,6 @@ int mlt_consumer_stop( mlt_consumer self )
        mlt_log( MLT_CONSUMER_SERVICE( self ), MLT_LOG_DEBUG, "stopping consumer\n" );
        
        // Cancel the read ahead threads
-       priv->ahead = 0;
        if ( priv->started )
        {
                // Unblock the consumer calling mlt_consumer_rt_frame