]> git.sesse.net Git - vlc/commitdiff
- fixed pitch bug;
authorArnaud de Bossoreille de Ribou <bozo@videolan.org>
Thu, 4 Jan 2001 23:18:21 +0000 (23:18 +0000)
committerArnaud de Bossoreille de Ribou <bozo@videolan.org>
Thu, 4 Jan 2001 23:18:21 +0000 (23:18 +0000)
  - fixed segfault, it was probably a memory corruption but I'm not sure :) ;
  - video_output.c : compute picture size even if b_need_render == 0;

plugins/sdl/intf_sdl.c
plugins/sdl/vout_sdl.c
src/video_output/video_output.c

index 27366d39b2bb92d086ba086422bccc6f9ddcb7b4..274585b37f14dd8fac14e988cfb83a2eddf2b410 100644 (file)
@@ -63,6 +63,8 @@ typedef struct intf_sys_s
 
 typedef struct vout_sys_s
 {
+    int i_width;
+    int i_height;
     SDL_Surface *   p_display;                             /* display device */
     SDL_Overlay *   p_overlay;
     boolean_t   b_fullscreen;
@@ -192,18 +194,19 @@ void intf_SDL_Resize( intf_thread_t * p_intf, int width, int height )
 {
     intf_Msg( "Video display resized (%dx%d)", width, height ); 
     vlc_mutex_lock( &p_intf->p_vout->change_lock );
-    p_intf->p_vout->i_width = width/* & 0xffffffe*/;
-    p_intf->p_vout->i_height = height;
+    p_intf->p_vout->p_sys->i_width = width;
+    p_intf->p_vout->p_sys->i_height = height;
     p_intf->p_vout->p_sys->b_reopen_display = 1;
-    p_intf->p_vout->i_changes |= VOUT_YUV_CHANGE;
     vlc_mutex_unlock( &p_intf->p_vout->change_lock );
 }
 
 void intf_SDL_YUVSwitch(intf_thread_t * p_intf)
 {
     vlc_mutex_lock( &p_intf->p_vout->change_lock );
+    p_intf->p_vout->p_sys->b_must_acquire = 0;
     p_intf->p_vout->b_need_render = 1 - p_intf->p_vout->b_need_render;
     intf_DbgMsg( "need render now : '%d'",p_intf->p_vout->b_need_render); 
+    p_intf->p_vout->p_sys->b_reopen_display = 1;
     vlc_mutex_unlock( &p_intf->p_vout->change_lock );
 }
 void intf_SDL_Fullscreen(intf_thread_t * p_intf)
index 1deacc1719ab0355b1ed193e1afa352d0e1bdf14..c8d722ccc5c8a2db4ee87d54b9fec379a0e09dea 100644 (file)
@@ -50,6 +50,8 @@
  *****************************************************************************/
 typedef struct vout_sys_s
 {
+    int i_width;
+    int i_height;
     SDL_Surface *   p_display;                             /* display device */
     SDL_Overlay *   p_overlay;                             /* overlay device */
     boolean_t   b_fullscreen;
@@ -110,7 +112,10 @@ int vout_SDLCreate( vout_thread_t *p_vout, char *psz_display,
         p_vout->p_sys->b_fullscreen = 0;
     }
 
-    p_vout->p_sys->b_reopen_display = 1;
+    p_vout->p_sys->i_width = VOUT_WIDTH_DEFAULT;
+    p_vout->p_sys->i_height = VOUT_HEIGHT_DEFAULT;
+
+    p_vout->p_sys->b_reopen_display = 0;
 
     if( SDLOpenDisplay(p_vout) )
     {
@@ -281,91 +286,104 @@ void vout_SDLDisplay( vout_thread_t *p_vout )
 static int SDLOpenDisplay( vout_thread_t *p_vout )
 {
     SDL_Rect    clipping_rect;
-    
+    Uint32      flags;
+    int bpp;
     /* Open display 
      * TODO: Check that we can request for a DOUBLEBUF HWSURFACE display
      */
+
+    /* init flags and cursor */
+    flags = SDL_ANYFORMAT;
+
     if( p_vout->p_sys->b_fullscreen )
+        flags |= SDL_FULLSCREEN;
+    else
+        flags |= SDL_RESIZABLE;
+
+    if( p_vout->b_need_render )
+        flags |= SDL_HWSURFACE | SDL_DOUBLEBUF;
+    else
+        flags |= SDL_SWSURFACE; /* save video memory */
+
+    bpp = SDL_VideoModeOK(p_vout->p_sys->i_width,
+                          p_vout->p_sys->i_height,
+                          p_vout->i_screen_depth, flags);
+
+    if(bpp == 0)
     {
-        p_vout->p_sys->p_display = SDL_SetVideoMode(p_vout->i_width, 
-            p_vout->i_height, 
-            0, 
-            SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_FULLSCREEN );
-        SDL_ShowCursor( 0 );
-    } else {
-        p_vout->p_sys->p_display = SDL_SetVideoMode(p_vout->i_width, 
-            p_vout->i_height, 
-            0, 
-            SDL_ANYFORMAT | SDL_HWSURFACE | SDL_DOUBLEBUF | SDL_RESIZABLE );
-        SDL_ShowCursor( 1 );
+        intf_ErrMsg( "error: can't open DISPLAY default display" );
+        return( 1 );
     }
-       
+
+    p_vout->p_sys->p_display = SDL_SetVideoMode(p_vout->p_sys->i_width,
+                                                p_vout->p_sys->i_height,
+                                                bpp, flags);
+
     if( p_vout->p_sys->p_display == NULL )
     {
         intf_ErrMsg( "error: can't open DISPLAY default display" );
         return( 1 );
     }
-    intf_DbgMsg( "sdl display size : %dx%d - pitch : %d",
-                 p_vout->p_sys->p_display->w,
-                 p_vout->p_sys->p_display->h,
-                 p_vout->p_sys->p_display->pitch);
+
+    if( p_vout->p_sys->b_fullscreen )
+        SDL_ShowCursor( 0 );
+    else
+        SDL_ShowCursor( 1 );
 
     SDL_WM_SetCaption( VOUT_TITLE , VOUT_TITLE );
     SDL_EventState(SDL_KEYUP , SDL_IGNORE);    /* ignore keys up */
 
-    /* Check buffers properties */     
-    p_vout->p_sys->b_must_acquire = 1;         /* always acquire */
-    p_vout->p_sys->p_buffer[ 0 ] =
-         p_vout->p_sys->p_display->pixels;
-
-    SDL_Flip(p_vout->p_sys->p_display);
-    p_vout->p_sys->p_buffer[ 1 ] =
-         p_vout->p_sys->p_display->pixels;
-    SDL_Flip(p_vout->p_sys->p_display);
-
-    /* Set graphic context colors */
-
-/*
-    col_fg.r = col_fg.g = col_fg.b = -1;
-    col_bg.r = col_bg.g = col_bg.b = 0;
-    if( ggiSetGCForeground(p_vout->p_sys->p_display,
-                           ggiMapColor(p_vout->p_sys->p_display,&col_fg)) ||
-        ggiSetGCBackground(p_vout->p_sys->p_display,
-                           ggiMapColor(p_vout->p_sys->p_display,&col_bg)) )
+    if( p_vout->b_need_render )
     {
-        intf_ErrMsg("error: can't set colors");
-        ggiClose( p_vout->p_sys->p_display );
-        ggiExit();
-        return( 1 );
+        p_vout->p_sys->p_buffer[ 0 ] = p_vout->p_sys->p_display->pixels;
+        SDL_Flip(p_vout->p_sys->p_display);
+        p_vout->p_sys->p_buffer[ 1 ] = p_vout->p_sys->p_display->pixels;
+        SDL_Flip(p_vout->p_sys->p_display);
+
+        /* Set clipping for text */
+        clipping_rect.x = 0;
+        clipping_rect.y = 0;
+        clipping_rect.w = p_vout->p_sys->p_display->w;
+        clipping_rect.h = p_vout->p_sys->p_display->h;
+        SDL_SetClipRect(p_vout->p_sys->p_display, &clipping_rect);
+
+        /* Set thread information */
+        p_vout->i_width =           p_vout->p_sys->p_display->w;
+        p_vout->i_height =          p_vout->p_sys->p_display->h;
+        p_vout->i_bytes_per_line =  p_vout->p_sys->p_display->pitch;
+
+        p_vout->i_screen_depth =
+            p_vout->p_sys->p_display->format->BitsPerPixel;
+        p_vout->i_bytes_per_pixel =
+            p_vout->p_sys->p_display->format->BytesPerPixel;
+
+        p_vout->i_red_mask =        p_vout->p_sys->p_display->format->Rmask;
+        p_vout->i_green_mask =      p_vout->p_sys->p_display->format->Gmask;
+        p_vout->i_blue_mask =       p_vout->p_sys->p_display->format->Bmask;
+
+        /* FIXME: palette in 8bpp ?? */
+        /* Set and initialize buffers */
+        vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer[ 0 ],
+                                 p_vout->p_sys->p_buffer[ 1 ] );
     }
-*/
-               
-    /* Set clipping for text */
-    clipping_rect.x = 0;
-    clipping_rect.y = 0;
-    clipping_rect.w = p_vout->p_sys->p_display->w;
-    clipping_rect.h = p_vout->p_sys->p_display->h;
-    SDL_SetClipRect(p_vout->p_sys->p_display, &clipping_rect);
-
-
-       
-    /* Set thread information */
-    p_vout->i_width =           p_vout->p_sys->p_display->w;
-    p_vout->i_height =          p_vout->p_sys->p_display->h;
-
-    p_vout->i_bytes_per_line = p_vout->p_sys->p_display->format->BytesPerPixel *
-                               p_vout->p_sys->p_display->w ;
-               
-    p_vout->i_screen_depth =    p_vout->p_sys->p_display->format->BitsPerPixel;
-    p_vout->i_bytes_per_pixel = p_vout->p_sys->p_display->format->BytesPerPixel;
-    p_vout->i_red_mask =        p_vout->p_sys->p_display->format->Rmask;
-    p_vout->i_green_mask =      p_vout->p_sys->p_display->format->Gmask;
-    p_vout->i_blue_mask =       p_vout->p_sys->p_display->format->Bmask;
-
-    /* FIXME: palette in 8bpp ?? */
-    /* Set and initialize buffers */
-    vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer[ 0 ],
-                             p_vout->p_sys->p_buffer[ 1 ] );
+    else
+    {
+        p_vout->p_sys->p_buffer[ 0 ] = p_vout->p_sys->p_display->pixels;
+        p_vout->p_sys->p_buffer[ 1 ] = p_vout->p_sys->p_display->pixels;
+
+        /* Set thread information */
+        p_vout->i_width =           p_vout->p_sys->p_display->w;
+        p_vout->i_height =          p_vout->p_sys->p_display->h;
+        p_vout->i_bytes_per_line =  p_vout->p_sys->p_display->pitch;
+
+        vout_SetBuffers( p_vout, p_vout->p_sys->p_buffer[ 0 ],
+                                 p_vout->p_sys->p_buffer[ 1 ] );
+    }
+
+    p_vout->i_changes |= VOUT_YUV_CHANGE;
+
+    /* Check buffers properties */     
+    p_vout->p_sys->b_must_acquire = 1;         /* always acquire */
 
     return( 0 );
 }
@@ -386,6 +404,7 @@ static void SDLCloseDisplay( vout_thread_t *p_vout )
             SDL_FreeYUVOverlay(p_vout->p_sys->p_overlay);
             p_vout->p_sys->p_overlay = NULL;
         }
+        SDL_UnlockSurface(p_vout->p_sys->p_display);
         SDL_FreeSurface( p_vout->p_sys->p_display );
         p_vout->p_sys->p_display = NULL;
     }
index c95229fa3022af8e9c06348dd9fc6fd398e92a9d..533e9243c26f3b929ad75a9ecfc582e67b445550 100644 (file)
@@ -1064,17 +1064,18 @@ static void RunThread( vout_thread_t *p_vout)
             b_display = p_vout->b_active;
             p_vout->last_display_date = display_date;
             p_vout->p_rendered_pic = p_pic;
-            
 
 
 
+
+            /* Set picture dimensions and clear buffer */
+            SetBufferPicture( p_vout, p_pic );
+
             /* FIXME: if b_need_render == 0 we need to do something with
              * the subpictures one day. */
+
             if( p_vout->b_need_render && b_display )
             {
-                /* Set picture dimensions and clear buffer */
-                SetBufferPicture( p_vout, p_pic );
-
                 /* Render picture and information */
                 RenderPicture( p_vout, p_pic );
                 if( p_vout->b_info )