Fixes threaded pixbuf usage and removes flash when swicthing between sdl preview...
[melted] / src / modules / sdl / consumer_sdl_preview.c
index ddb3ddf..84a2c30 100644 (file)
@@ -61,9 +61,26 @@ mlt_consumer consumer_sdl_preview_init( char *arg )
        {
                // Get the parent consumer object
                mlt_consumer parent = &this->parent;
+
+               // Get the properties
+               mlt_properties properties = mlt_consumer_properties( parent );
+
+               // Get the width and height
+               int width = mlt_properties_get_int( properties, "width" );
+               int height = mlt_properties_get_int( properties, "height" );
+
+               // Process actual param
+               if ( arg == NULL || sscanf( arg, "%dx%d", &width, &height ) == 2 )
+               {
+                       mlt_properties_set_int( properties, "width", width );
+                       mlt_properties_set_int( properties, "height", height );
+               }
+
+               // Create child consumers
                this->play = mlt_factory_consumer( "sdl", arg );
                this->still = mlt_factory_consumer( "sdl_still", arg );
                mlt_properties_set( mlt_consumer_properties( parent ), "real_time", "0" );
+               mlt_properties_set( mlt_consumer_properties( parent ), "rescale", "nearest" );
                parent->close = consumer_close;
                parent->start = consumer_start;
                parent->stop = consumer_stop;
@@ -122,11 +139,20 @@ static int consumer_stop( mlt_consumer parent )
 
        if ( this->joined == 0 )
        {
+               mlt_properties properties = mlt_consumer_properties( parent );
+               int app_locked = mlt_properties_get_int( properties, "app_locked" );
+               void ( *lock )( void ) = mlt_properties_get_data( properties, "app_lock", NULL );
+               void ( *unlock )( void ) = mlt_properties_get_data( properties, "app_unlock", NULL );
+
+               if ( app_locked && unlock ) unlock( );
+
                // Kill the thread and clean up
                this->running = 0;
 
                pthread_join( this->thread, NULL );
                this->joined = 1;
+
+               if ( app_locked && lock ) lock( );
        }
 
        return 0;
@@ -173,12 +199,17 @@ static void *consumer_thread( void *arg )
        mlt_properties_set_data( still, "transport_producer", mlt_properties_get_data( properties, "transport_producer", NULL ), 0, NULL, NULL );
        mlt_properties_set_data( play, "transport_callback", mlt_properties_get_data( properties, "transport_callback", NULL ), 0, NULL, NULL );
        mlt_properties_set_data( still, "transport_callback", mlt_properties_get_data( properties, "transport_callback", NULL ), 0, NULL, NULL );
+       mlt_properties_set_int( play, "resize", mlt_properties_get_int( properties, "resize" ) );
+       mlt_properties_set_int( still, "resize", mlt_properties_get_int( properties, "resize" ) );
        mlt_properties_set( play, "rescale", mlt_properties_get( properties, "rescale" ) );
        mlt_properties_set( still, "rescale", mlt_properties_get( properties, "rescale" ) );
-       mlt_properties_set( play, "width", mlt_properties_get( properties, "width" ) );
-       mlt_properties_set( still, "width", mlt_properties_get( properties, "width" ) );
-       mlt_properties_set( play, "height", mlt_properties_get( properties, "height" ) );
-       mlt_properties_set( still, "height", mlt_properties_get( properties, "height" ) );
+       mlt_properties_set_int( play, "width", mlt_properties_get_int( properties, "width" ) );
+       mlt_properties_set_int( still, "width", mlt_properties_get_int( properties, "width" ) );
+       mlt_properties_set_int( play, "height", mlt_properties_get_int( properties, "height" ) );
+       mlt_properties_set_int( still, "height", mlt_properties_get_int( properties, "height" ) );
+
+       mlt_properties_set_int( play, "progressive", 1 );
+       mlt_properties_set_int( still, "progressive", 1 );
 
        mlt_properties_pass( play, mlt_consumer_properties( consumer ), "play." );
        mlt_properties_pass( still, mlt_consumer_properties( consumer ), "still." );
@@ -243,7 +274,6 @@ static void *consumer_thread( void *arg )
                                {
                                        this->last_speed = use_speed;
                                        this->active = this->still;
-                                       this->ignore_change = 5;
                                        mlt_consumer_start( this->still );
                                }
                                mlt_properties_set_int( still, "changed", changed );