]> git.sesse.net Git - mlt/commitdiff
Remove audio processing from the worker threads.
authorDan Dennedy <dan@dennedy.org>
Wed, 16 Jun 2010 04:52:30 +0000 (21:52 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 24 Jan 2011 02:09:43 +0000 (18:09 -0800)
This has a bad interaction with the avformat producer, which contains a
buffer of unused decoded samples. This shifts audio processing to the
main consumer thread, which is often light anyways. I recommend to set
the threads property to 2 or more on the avformat consumer to offload
video encoding to separate threads from the audio processing and
encoding.

src/framework/mlt_consumer.c

index 41a103086f00e191684b1ad8ed516621e03ff821..b545f336dcdb8ce3d369aab5bbd2aebcf96b64cd 100644 (file)
@@ -791,18 +791,6 @@ static void *consumer_worker_thread( void *arg )
        int preview_off = mlt_properties_get_int( properties, "preview_off" );
        int preview_format = mlt_properties_get_int( properties, "preview_format" );
 
-       // Get the audio settings
-       mlt_audio_format afmt = mlt_audio_s16;
-       int counter = 0;
-       double fps = mlt_properties_get_double( properties, "fps" );
-       int channels = mlt_properties_get_int( properties, "channels" );
-       int frequency = mlt_properties_get_int( properties, "frequency" );
-       int samples = 0;
-       void *audio = NULL;
-
-       // See if audio is turned off
-       int audio_off = mlt_properties_get_int( properties, "audio_off" );
-
        // General frame variable
        mlt_frame frame = NULL;
        uint8_t *image = NULL;
@@ -825,12 +813,6 @@ static void *consumer_worker_thread( void *arg )
                mlt_frame_get_image( frame, &image, &format, &width, &height, 0 );
        }
 
-       if ( !audio_off )
-       {
-               samples = mlt_sample_calculator( fps, frequency, counter++ );
-               mlt_frame_get_audio( frame, &audio, &afmt, &frequency, &channels, &samples );
-       }
-
        // Mark as rendered
        mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 );
 
@@ -877,13 +859,6 @@ static void *consumer_worker_thread( void *arg )
                        mlt_frame_get_image( frame, &image, &format, &width, &height, 0 );
                }
                mlt_properties_set_int( MLT_FRAME_PROPERTIES( frame ), "rendered", 1 );
-
-               // Always process audio
-               if ( !audio_off )
-               {
-                       samples = mlt_sample_calculator( fps, frequency, counter++ );
-                       mlt_frame_get_audio( frame, &audio, &afmt, &frequency, &channels, &samples );
-               }
        }
 
        // Remove the last frame