Skip to content

Commit

Permalink
Implement mlt_consumer.purge in multi consumer.
Browse files Browse the repository at this point in the history
  • Loading branch information
ddennedy committed Apr 28, 2013
1 parent c804370 commit 78b3b4c
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/modules/core/consumer_multi.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ static int stop( mlt_consumer consumer );
static int is_stopped( mlt_consumer consumer );
static void *consumer_thread( void *arg );
static void consumer_close( mlt_consumer consumer );
static void purge( mlt_consumer consumer );

static mlt_properties normalisers = NULL;

Expand Down Expand Up @@ -57,6 +58,7 @@ mlt_consumer consumer_multi_init( mlt_profile profile, mlt_service_type type, co
consumer->start = start;
consumer->stop = stop;
consumer->is_stopped = is_stopped;
consumer->purge = purge;
}

return consumer;
Expand Down Expand Up @@ -507,6 +509,27 @@ static int is_stopped( mlt_consumer consumer )
return !mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "running" );
}

/** Purge each of the child consumers.
*/

static void purge( mlt_consumer consumer )
{
mlt_properties properties = MLT_CONSUMER_PROPERTIES( consumer );
if ( mlt_properties_get_int( properties, "running" ) )
{
mlt_consumer nested = NULL;
char key[30];
int index = 0;

do {
snprintf( key, sizeof(key), "%d.consumer", index++ );
nested = mlt_properties_get_data( properties, key, NULL );
if ( nested )
mlt_consumer_purge( nested );
} while ( nested );
}
}

/** The main thread - the argument is simply the consumer.
*/

Expand Down

0 comments on commit 78b3b4c

Please sign in to comment.