Hi,

attached patch prevent start new (or additional) consumer_read_ahead_start from avformat consumer during stopping/closing consumer.

--
________________________________________
Maksym Veremeyenko
>From c2fe53f9660bdaa7d3e5589784ed5ba8105a4dda Mon Sep 17 00:00:00 2001
From: Maksym Veremeyenko <ve...@m1stereo.tv>
Date: Thu, 17 Oct 2013 09:17:29 +0300
Subject: [PATCH 1/2] race condition fix

---
 src/framework/mlt_consumer.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/framework/mlt_consumer.c b/src/framework/mlt_consumer.c
index 5c640f2..74b946d 100644
--- a/src/framework/mlt_consumer.c
+++ b/src/framework/mlt_consumer.c
@@ -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
-- 
1.7.7.6

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60135031&iu=/4140/ostg.clktrk
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel

Reply via email to