config mods; avformat static or shared build; corrections to sdl
[melted] / src / modules / sdl / consumer_sdl.c
index bf7e3fd..6b9ad0c 100644 (file)
@@ -169,7 +169,14 @@ int consumer_start( mlt_consumer parent )
                pthread_attr_t thread_attributes;
                
                this->running = 1;
-               
+
+               // Allow the user to force resizing to window size
+               if ( mlt_properties_get_int( this->properties, "resize" ) )
+               {
+                       mlt_properties_set_int( this->properties, "width", this->width );
+                       mlt_properties_set_int( this->properties, "height", this->height );
+               }
+
                // Inherit the scheduling priority
                pthread_attr_init( &thread_attributes );
                pthread_attr_setinheritsched( &thread_attributes, PTHREAD_INHERIT_SCHED );
@@ -397,6 +404,8 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        changed = 1;
                }
 
+               if ( this->sdl_screen == NULL || changed )
+               {
                        SDL_Rect rect;
                        
                        // Determine frame's display aspect ratio
@@ -451,8 +460,6 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        rect.x = ( this->window_width - rect.w ) / 2;
                        rect.y = ( this->window_height - rect.h ) / 2;
                        
-               if ( this->sdl_screen == NULL || changed )
-               {
                        // Force an overlay recreation
                        if ( this->sdl_overlay != NULL )
                                SDL_FreeYUVOverlay( this->sdl_overlay );
@@ -463,23 +470,19 @@ static int consumer_play_video( consumer_sdl this, mlt_frame frame )
                        if ( this->sdl_screen != NULL )
                        {
                                SDL_SetClipRect( this->sdl_screen, &rect );
-                       
                                sdl_lock_display();
-                               this->sdl_overlay = SDL_CreateYUVOverlay( this->width - (this->width % 4), this->height - (this->height % 2 ), SDL_YUY2_OVERLAY, this->sdl_screen );
+                               this->sdl_overlay = SDL_CreateYUVOverlay( this->width, this->height, SDL_YUY2_OVERLAY, this->sdl_screen );
                                sdl_unlock_display();
                        }
                }
-               else
-               {
-                       SDL_SetClipRect( this->sdl_screen, &rect );
-               }
-
+                       
                if ( this->sdl_screen != NULL && this->sdl_overlay != NULL )
                {
                        this->buffer = this->sdl_overlay->pixels[ 0 ];
                        if ( SDL_LockYUVOverlay( this->sdl_overlay ) >= 0 )
                        {
-                               memcpy( this->buffer, image, width * height * 2 );
+                               if ( image != NULL )
+                                       memcpy( this->buffer, image, width * height * 2 );
                                SDL_UnlockYUVOverlay( this->sdl_overlay );
                                SDL_DisplayYUVOverlay( this->sdl_overlay, &this->sdl_screen->clip_rect );
                        }
@@ -662,6 +665,9 @@ static void consumer_close( mlt_consumer parent )
        // Stop the consumer
        mlt_consumer_stop( parent );
 
+       // Close the queue
+       mlt_deque_close( this->queue );
+
        // Destroy mutexes
        pthread_mutex_destroy( &this->audio_mutex );
        pthread_cond_destroy( &this->audio_cond );