if ( consumer )
{
+ mlt_properties properties = MLT_CONSUMER_PROPERTIES(consumer);
+
+ // Set defaults
+ mlt_properties_set( properties, "resource", arg );
+ mlt_properties_set_int( properties, "real_time", -1 );
+ mlt_properties_set_int( properties, "terminate_on_pause", 1 );
+
+ // Init state
+ mlt_properties_set_int( properties, "joined", 1 );
+
// Assign callbacks
consumer->close = consumer_close;
consumer->start = start;
consumer->stop = stop;
consumer->is_stopped = is_stopped;
-
- mlt_properties_set( MLT_CONSUMER_PROPERTIES(consumer), "resource", arg );
- mlt_properties_set_int( MLT_CONSUMER_PROPERTIES(consumer), "real_time", -1 );
}
return consumer;
// Set the running state
mlt_properties_set_int( properties, "running", 1 );
+ mlt_properties_set_int( properties, "joined", 0 );
// Construct and start nested consumers
if ( !mlt_properties_get_data( properties, "0.consumer", NULL ) )
static int stop( mlt_consumer consumer )
{
// Check that we're running
- if ( !is_stopped( consumer ) )
+ if ( !mlt_properties_get_int( MLT_CONSUMER_PROPERTIES(consumer), "joined" ) )
{
mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
pthread_t *thread = mlt_properties_get_data( properties, "thread", NULL );
foreach_consumer_refresh( consumer );
pthread_join( *thread, NULL );
}
+ mlt_properties_set_int( properties, "joined", 1 );
// Stop nested consumers
foreach_consumer_stop( consumer );
else
{
if ( frame ) mlt_frame_close( frame );
- foreach_consumer_put( consumer, NULL );
terminated = 1;
}
}
// Indicate that the consumer is stopped
- mlt_properties_set_int( properties, "running", 0 );
mlt_consumer_stopped( consumer );
return NULL;
static void consumer_close( mlt_consumer consumer )
{
mlt_consumer_stop( consumer );
+
// Close the parent
mlt_consumer_close( consumer );
free( consumer );