Fixes threaded pixbuf usage and removes flash when swicthing between sdl preview...
[melted] / src / modules / sdl / consumer_sdl_preview.c
index 4b7e116..84a2c30 100644 (file)
@@ -80,6 +80,7 @@ mlt_consumer consumer_sdl_preview_init( char *arg )
                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;
@@ -138,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;
@@ -189,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." );
@@ -204,9 +219,6 @@ static void *consumer_thread( void *arg )
        mlt_properties_set_data( play, "app_unlock", mlt_properties_get_data( properties, "app_unlock", NULL ), 0, NULL, NULL );
        mlt_properties_set_data( still, "app_unlock", mlt_properties_get_data( properties, "app_unlock", NULL ), 0, NULL, NULL );
 
-       mlt_properties_set_int( play, "progressive", 1 );
-       mlt_properties_set_int( still, "progressive", 1 );
-
        mlt_properties_set_int( play, "put_mode", 1 );
        mlt_properties_set_int( still, "put_mode", 1 );