2012/2/8 Maksym Veremeyenko ve...@m1stereo.tv:
08.02.12 06:19, Dan Dennedy написав(ла):
2012/1/16 Maksym Veremeyenkove...@m1stereo.tv:
wrong test code where mlt_consumer_stop was called immediately after
mlt_consumer_start caused that sideeffect.
to resolve such condition i attached a patch that properly determinate
consumer's thread finish and avoid writing /trailer/ if no /header was
written..
My testing with sdl and decklink consumers showed that they were not
vulnerable to this, but indeed avformat was. I resolved this a little
differently, and committed it.
the goal of that patch was to disable setting/altering flag /running/ inside
thread - that could cause some leaks and some race condition i notified
about...
Well, the more critical goal was to fix a segfault, but I see your
point now about using running to cleanup thread. I did not like
your conversion of the thread property from data to a int64; do you
know how data properties provide destruction? Also, my testing
revealed some additional pointer checks required inside
consumer_thread. Comment on this applied to head:
diff --git a/src/modules/avformat/consumer_avformat.c
b/src/modules/avformat/consumer_avformat.c
index fb52df3..cd63431 100644
--- a/src/modules/avformat/consumer_avformat.c
+++ b/src/modules/avformat/consumer_avformat.c
@@ -350,18 +350,18 @@ static int consumer_stop( mlt_consumer consumer )
{
// Get the properties
mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
+ pthread_t *thread = mlt_properties_get_data( properties, thread, NULL
);
// Check that we're running
- if ( mlt_properties_get_int( properties, running ) )
+ if ( thread )
{
- // Get the thread
- pthread_t *thread = mlt_properties_get_data( properties,
thread, NULL );
-
// Stop the thread
mlt_properties_set_int( properties, running, 0 );
// Wait for termination
pthread_join( *thread, NULL );
+
+ mlt_properties_set( properties, thread, NULL );
}
return 0;
@@ -1436,12 +1436,12 @@ static void *consumer_thread( void *arg )
#endif
{
mlt_log_error( MLT_CONSUMER_SERVICE( consumer
), Could not open
'%s'\n, filename );
- mlt_properties_set_int( properties, running,
0 );
+ terminated = 1;
}
}
// Write the stream header.
- if ( mlt_properties_get_int( properties, running ) )
+ if ( !terminated mlt_properties_get_int( properties,
running ) )
#if LIBAVFORMAT_VERSION_INT = ((5316)+(28)+0)
avformat_write_header( oc, NULL );
#else
@@ -1452,7 +1452,7 @@ static void *consumer_thread( void *arg )
else
{
mlt_log_error( MLT_CONSUMER_SERVICE( consumer ), Invalid output
format parameters\n );
- mlt_properties_set_int( properties, running, 0 );
+ terminated = 1;
}
#endif
@@ -1462,7 +1462,7 @@ static void *consumer_thread( void *arg )
// Last check - need at least one stream
if ( !audio_st[0] !video_st )
- mlt_properties_set_int( properties, running, 0 );
+ terminated = 1;
// Get the starting time (can ignore the times above)
gettimeofday( ante, NULL );
@@ -1957,8 +1957,6 @@ on_fatal_error:
av_free( oc );
// Just in case we terminated on pause
- mlt_properties_set_int( properties, running, 0 );
-
mlt_consumer_stopped( consumer );
mlt_properties_close( frame_meta_properties );
--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel