]> git.sesse.net Git - mlt/commitdiff
On Windows, ensure consumer-thread-create fires on caller thread.
authorDan Dennedy <dan@dennedy.org>
Tue, 11 Feb 2014 01:29:50 +0000 (17:29 -0800)
committerDan Dennedy <dan@dennedy.org>
Tue, 11 Feb 2014 01:29:50 +0000 (17:29 -0800)
This is needed to get GPU processing working on Shotcut for Windows and
probably other Qt 5 apps. However, that causes some bad behavior with
Movit on Linux. So, this change is only on Windows for now.

src/framework/mlt_consumer.c

index 202ecc5cb40e94b494bc693376446b8b7a73a185..42148e1aff8a226c6c9ecd795f5fd94abf611943 100644 (file)
@@ -49,6 +49,7 @@ typedef struct
 {
        int real_time;
        int ahead;
+       int preroll;
        mlt_image_format format;
        mlt_deque queue;
        void *ahead_thread;
@@ -85,6 +86,7 @@ static void transmit_thread_create( mlt_listener listener, mlt_properties owner,
 static void mlt_thread_create( mlt_consumer self, thread_function_t function );
 static void transmit_thread_join( mlt_listener listener, mlt_properties owner, mlt_service self, void **args );
 static void mlt_thread_join( mlt_consumer self );
+static void consumer_read_ahead_start( mlt_consumer self );
 
 /** Initialize a consumer service.
  *
@@ -541,6 +543,12 @@ int mlt_consumer_start( mlt_consumer self )
                        priv->format = mlt_image_yuv422;
        }
 
+       priv->preroll = 1;
+#ifdef WIN32
+       if ( priv->real_time == 1 || priv->real_time == -1 )
+               consumer_read_ahead_start( self );
+#endif
+
        // Start the service
        if ( self->start != NULL )
                return self->start( self );
@@ -1492,14 +1500,16 @@ mlt_frame mlt_consumer_rt_frame( mlt_consumer self )
        {
                int size = 1;
 
-               // Is the read ahead running?
-               if ( priv->ahead == 0 )
+               if ( priv->preroll )
                {
                        int buffer = mlt_properties_get_int( properties, "buffer" );
                        int prefill = mlt_properties_get_int( properties, "prefill" );
+#ifndef WIN32
                        consumer_read_ahead_start( self );
+#endif
                        if ( buffer > 1 )
                                size = prefill > 0 && prefill < buffer ? prefill : buffer;
+                       priv->preroll = 0;
                }
 
                // Get frame from queue