From 59d8632607ffe5caa49c83f8209be627557a1474 Mon Sep 17 00:00:00 2001 From: Maksym Veremeyenko Date: Thu, 19 Jul 2012 13:23:09 +0300 Subject: [PATCH] move mutex and deque initialization to producer init method --- src/modules/avformat/producer_avformat.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index 8b327c37..d93ed29f 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -191,6 +191,16 @@ mlt_producer producer_avformat_init( mlt_profile profile, const char *service, c // Register our get_frame implementation producer->get_frame = producer_get_frame; + // init mutexes + pthread_mutex_init( &self->audio_mutex, NULL ); + pthread_mutex_init( &self->video_mutex, NULL ); + pthread_mutex_init( &self->packets_mutex, NULL ); + pthread_mutex_init( &self->open_mutex, NULL ); + + // init queues + self->apackets = mlt_deque_init(); + self->vpackets = mlt_deque_init(); + if ( strcmp( service, "avformat-novalidate" ) ) { // Open the file @@ -828,10 +838,6 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha // Lock the service if ( take_lock ) { - pthread_mutex_init( &self->audio_mutex, NULL ); - pthread_mutex_init( &self->video_mutex, NULL ); - pthread_mutex_init( &self->packets_mutex, NULL ); - pthread_mutex_init( &self->open_mutex, NULL ); pthread_mutex_lock( &self->audio_mutex ); pthread_mutex_lock( &self->video_mutex ); } @@ -948,11 +954,6 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha } if ( filename ) free( filename ); - if ( !error ) - { - self->apackets = mlt_deque_init(); - self->vpackets = mlt_deque_init(); - } if ( self->dummy_context ) { -- 2.39.2