Transitions reworked (always_active capabilities); remaining audio handling switched...
[melted] / src / framework / mlt_consumer.c
index 2020096..99ca151 100644 (file)
@@ -366,7 +366,6 @@ static void *consumer_read_ahead_thread( void *arg )
        {
                samples = mlt_sample_calculator( fps, frequency, counter++ );
                mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples );
-               frame->get_audio = NULL;
        }
 
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 );
@@ -439,7 +438,6 @@ static void *consumer_read_ahead_thread( void *arg )
                {
                        samples = mlt_sample_calculator( fps, frequency, counter++ );
                        mlt_frame_get_audio( frame, &pcm, &afmt, &frequency, &channels, &samples );
-                       frame->get_audio = NULL;
                }
 
                // Increment the time take for this frame
@@ -599,6 +597,11 @@ int mlt_consumer_stop( mlt_consumer this )
 
        // Just in case...
        pthread_mutex_lock( &this->put_mutex );
+       if ( this->put != NULL )
+       {
+               mlt_frame_close( this->put );
+               this->put = NULL;
+       }
        pthread_cond_broadcast( &this->put_cond );
        pthread_mutex_unlock( &this->put_mutex );
 
@@ -609,12 +612,6 @@ int mlt_consumer_stop( mlt_consumer this )
        if ( mlt_properties_get( properties, "post" ) )
                system( mlt_properties_get( properties, "post" ) );
 
-       if ( this->put != NULL )
-       {
-               mlt_frame_close( this->put );
-               this->put = NULL;
-       }
-
        return 0;
 }
 
@@ -640,19 +637,26 @@ void mlt_consumer_close( mlt_consumer this )
                // Get the childs close function
                void ( *consumer_close )( ) = this->close;
 
-               // Make sure it only gets called once
-               this->close = NULL;
-               this->parent.close = NULL;
-
-               // Destroy the push mutex and condition
-               pthread_cond_broadcast( &this->put_cond );
-               pthread_mutex_destroy( &this->put_mutex );
-               pthread_cond_destroy( &this->put_cond );
+               if ( consumer_close )
+               {
+                       // Just in case...
+                       mlt_consumer_stop( this );
 
-               // Call the childs close if available
-               if ( consumer_close != NULL )
+                       this->close = NULL;
                        consumer_close( this );
+               }
                else
+               {
+
+                       // Make sure it only gets called once
+                       this->parent.close = NULL;
+
+                       // Destroy the push mutex and condition
+                       pthread_cond_broadcast( &this->put_cond );
+                       pthread_mutex_destroy( &this->put_mutex );
+                       pthread_cond_destroy( &this->put_cond );
+
                        mlt_service_close( &this->parent );
+               }
        }
 }