Build modification to ffmpeg/avformat
[melted] / src / modules / sdl / consumer_sdl_still.c
index f441352..c76740a 100644 (file)
@@ -123,7 +123,9 @@ mlt_consumer consumer_sdl_still_init( char *arg )
                this->window_height = this->height;
 
                // Set the sdl flags
-               this->sdl_flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_RESIZABLE | SDL_DOUBLEBUF;
+               //this->sdl_flags = SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL | SDL_RESIZABLE | SDL_DOUBLEBUF;
+               // Experimental settings
+               this->sdl_flags = SDL_RESIZABLE | SDL_DOUBLEBUF;
 
                // Allow thread to be started/stopped
                parent->start = consumer_start;
@@ -156,8 +158,6 @@ static int consumer_start( mlt_consumer parent )
 
        if ( !this->running )
        {
-               pthread_attr_t thread_attributes;
-
                // Attach a colour space converter
                if ( !this->filtered )
                {
@@ -183,11 +183,7 @@ static int consumer_start( mlt_consumer parent )
 
                //this->width = this->height * this->display_aspect;
 
-               // 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 );
+               pthread_create( &this->thread, NULL, consumer_thread, this );
        }
 
        return 0;
@@ -416,11 +412,10 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
        }
        else
        {
-               changed = mlt_properties_get_int( properties, "changed" ) | mlt_properties_get_int( MLT_FRAME_PROPERTIES( frame ), "refresh" );
+               changed = 1;
                mlt_properties_set_int( properties, "changed", 0 );
        }
 
-       
        if ( changed == 0 &&
                 this->last_position == mlt_frame_get_position( frame ) &&
                 this->last_producer == mlt_properties_get_data( MLT_FRAME_PROPERTIES( frame ), "_producer", NULL ) )
@@ -486,7 +481,7 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                mlt_properties_set_int( this->properties, "rect_h", this->rect.h );
        }
        
-       if ( !mlt_consumer_is_stopped( &this->parent ) && this->sdl_screen != NULL && this->sdl_screen->pixels != NULL )
+       if ( !mlt_consumer_is_stopped( &this->parent ) && SDL_GetVideoSurface( ) != NULL && this->sdl_screen != NULL && this->sdl_screen->pixels != NULL )
        {
                memset( this->sdl_screen->pixels, 0, this->window_width * this->window_height * this->sdl_screen->format->BytesPerPixel );
 
@@ -533,7 +528,6 @@ static void *consumer_thread( void *arg )
 
        // internal intialization
        mlt_frame frame = NULL;
-       struct timespec tm = { 0, 99999999 };
 
        if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "sdl_started" ) == 0 )
        {
@@ -566,10 +560,13 @@ static void *consumer_thread( void *arg )
                // Ensure that we have a frame
                if ( frame != NULL )
                {
-                       if ( consumer_play_video( this, frame ) == 0 )
-                               nanosleep( &tm, NULL );
+                       consumer_play_video( this, frame );
                        mlt_frame_close( frame );
                }
+               else
+               {
+                       this->running = 0;
+               }
        }
 
        if ( mlt_properties_get_int( MLT_CONSUMER_PROPERTIES( consumer ), "sdl_started" ) == 0 )
@@ -593,6 +590,7 @@ static int consumer_get_dimensions( int *width, int *height )
        // Get the wm structure
        if ( SDL_GetWMInfo( &wm ) == 1 )
        {
+#ifndef __DARWIN__
                // Check that we have the X11 wm
                if ( wm.subsystem == SDL_SYSWM_X11 ) 
                {
@@ -613,6 +611,7 @@ static int consumer_get_dimensions( int *width, int *height )
                        *width = attr.width;
                        *height = attr.height;
                }
+#endif
        }
 
        return changed;