changeset 9170:bcf4bf10f9c7

hopefully better uninit check
author arpi
date Wed, 29 Jan 2003 23:28:55 +0000
parents f49a2bf04229
children 898e5270a46e
files libvo/vo_vesa.c
diffstat 1 files changed, 6 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_vesa.c	Wed Jan 29 22:45:07 2003 +0000
+++ b/libvo/vo_vesa.c	Wed Jan 29 23:28:55 2003 +0000
@@ -98,7 +98,7 @@
 static SwsContext * sws = NULL;
 
 static int32_t x_offset,y_offset; /* to center image on screen */
-static unsigned init_mode; /* mode before run of mplayer */
+static unsigned init_mode=0; /* mode before run of mplayer */
 static void *init_state = NULL; /* state before run of mplayer */
 static struct win_frame win; /* real-mode window to video memory */
 static uint8_t *dga_buffer = NULL; /* for yuv2rgb and sw_scaling */
@@ -154,12 +154,15 @@
 #ifdef CONFIG_VIDIX
   else if(vidix_name) vidix_term();
 #endif
-  if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err);
-  if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
+  if(init_state) if((err=vbeRestoreState(init_state)) != VBE_OK) PRINT_VBE_ERR("vbeRestoreState",err);
+  init_state=NULL;
+  if(init_mode) if((err=vbeSetMode(init_mode,NULL)) != VBE_OK) PRINT_VBE_ERR("vbeSetMode",err);
+  init_mode=0;
   if(HAS_DGA()) vbeUnmapVideoBuffer((unsigned long)win.ptr,win.high);
   if(dga_buffer && !HAS_DGA()) free(dga_buffer);
   vbeDestroy();
   if(sws) freeSwsContext(sws);
+  sws=NULL;
 }
 
 #define VALID_WIN_FRAME(offset) (offset >= win.low && offset < win.high)
@@ -993,7 +996,6 @@
 uninit(void)
 {
     // not inited
-    if (!init_state) return;
     vesa_term();
     if(verbose > 2)
         printf("vo_vesa: uninit was called\n");