- // Inherit the scheduling priority
- pthread_attr_init( &thread_attributes );
- pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED );
-
- pthread_create( &this->thread, &thread_attributes, consumer_thread, this );
+ self->bpp = mlt_properties_get_int( self->properties, "bpp" );
+
+ if ( sdl_started == 0 && display_off == 0 )
+ {
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ int ret = SDL_Init( SDL_INIT_VIDEO | SDL_INIT_NOPARACHUTE );
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+ if ( ret < 0 )
+ {
+ mlt_log_error( MLT_CONSUMER_SERVICE(parent), "Failed to initialize SDL: %s\n", SDL_GetError() );
+ return -1;
+ }
+
+ SDL_EnableKeyRepeat( SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL );
+ SDL_EnableUNICODE( 1 );
+ }
+
+ if ( audio_off == 0 )
+ SDL_InitSubSystem( SDL_INIT_AUDIO );
+
+ // Default window size
+ if ( mlt_properties_get_int( self->properties, "_arg_size" ) )
+ {
+ self->window_width = self->width;
+ self->window_height = self->height;
+ }
+ else
+ {
+ double display_ratio = mlt_properties_get_double( self->properties, "display_ratio" );
+ self->window_width = ( double )self->height * display_ratio + 0.5;
+ self->window_height = self->height;
+ }
+
+ pthread_mutex_lock( &mlt_sdl_mutex );
+ if ( !SDL_GetVideoSurface() && display_off == 0 )
+ {
+ if ( mlt_properties_get_int( self->properties, "fullscreen" ) )
+ {
+ const SDL_VideoInfo *vi;
+ vi = SDL_GetVideoInfo();
+ self->window_width = vi->current_w;
+ self->window_height = vi->current_h;
+ self->sdl_flags |= SDL_FULLSCREEN;
+ SDL_ShowCursor( SDL_DISABLE );
+ }
+ SDL_SetVideoMode( self->window_width, self->window_height, 0, self->sdl_flags );
+ }
+ pthread_mutex_unlock( &mlt_sdl_mutex );
+
+ pthread_create( &self->thread, NULL, consumer_thread, self );