X-Git-Url: http://research.m1stereo.tv/gitweb?a=blobdiff_plain;f=src%2Fmodules%2Fsdl%2Fconsumer_sdl_preview.c;h=fc04af9a48a10dfe87eb13ffe1efc9aa06b52ce5;hb=65e8ac86ee6e17a12892954ff4a8d46c4766fe0d;hp=295a2cd559f80b76e18a912f4acf06732915b454;hpb=5941e41209b87a8ed26f273f170abbd484113938;p=melted diff --git a/src/modules/sdl/consumer_sdl_preview.c b/src/modules/sdl/consumer_sdl_preview.c index 295a2cd..fc04af9 100644 --- a/src/modules/sdl/consumer_sdl_preview.c +++ b/src/modules/sdl/consumer_sdl_preview.c @@ -135,12 +135,31 @@ static int consumer_start( mlt_consumer parent ) if ( !this->running ) { + mlt_properties properties = MLT_CONSUMER_PROPERTIES( parent ); + char *window_id = mlt_properties_get( properties, "window_id" ); + char *audio_driver = mlt_properties_get( properties, "audio_driver" ); + consumer_stop( parent ); this->running = 1; this->joined = 0; this->last_speed = 1; + if ( window_id != NULL ) + setenv( "SDL_WINDOWID", window_id, 1 ); + + if ( audio_driver != NULL ) + setenv( "SDL_AUDIODRIVER", audio_driver, 1 ); + + if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 ) + { + fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() ); + return -1; + } + + SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); + SDL_EnableUNICODE( 1 ); + pthread_create( &this->thread, NULL, consumer_thread, this ); } @@ -172,6 +191,8 @@ static int consumer_stop( mlt_consumer parent ) this->joined = 1; if ( app_locked && lock ) lock( ); + + SDL_Quit( ); } return 0; @@ -203,15 +224,6 @@ static void *consumer_thread( void *arg ) int progressive = mlt_properties_get_int( properties, "progressive" ) | mlt_properties_get_int( properties, "deinterlace" ); - if ( SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE ) < 0 ) - { - fprintf( stderr, "Failed to initialize SDL: %s\n", SDL_GetError() ); - return NULL; - } - - SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL ); - SDL_EnableUNICODE( 1 ); - // Inform child consumers that we control the sdl mlt_properties_set_int( play, "sdl_started", 1 ); mlt_properties_set_int( still, "sdl_started", 1 ); @@ -372,8 +384,6 @@ static void *consumer_thread( void *arg ) if ( this->play ) mlt_consumer_stop( this->play ); if ( this->still ) mlt_consumer_stop( this->still ); - //SDL_Quit( ); - return NULL; }