changeset 4831:9153d1275b6d

do not fault if no directbuffer available (for example: ggi display-multi)
author alex
date Sun, 24 Feb 2002 02:50:02 +0000
parents 2c1dd0b15622
children 76491c4cb611
files libvo/vo_ggi.c
diffstat 1 files changed, 14 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/libvo/vo_ggi.c	Sun Feb 24 02:21:14 2002 +0000
+++ b/libvo/vo_ggi.c	Sun Feb 24 02:50:02 2002 +0000
@@ -27,7 +27,7 @@
 
 #undef GET_DB_INFO
 
-/* max buffers */
+/* maximum buffers */
 #define GGI_FRAMES 4
 
 #include "../postproc/rgb2rgb.h"
@@ -130,14 +130,12 @@
     if (ggiSetMode(ggi_conf.vis, &mode))
     {
 	mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to set mode\n");
-	uninit();
 	return(-1);
     }
 
     if (ggiGetMode(ggi_conf.vis, &mode) != 0)
     {
 	mp_msg(MSGT_VO, MSGL_ERR, "[ggi] unable to get mode\n");
-	uninit();
 	return(-1);
     }
 
@@ -183,20 +181,28 @@
 	default:
 	    mp_msg(MSGT_VO, MSGL_FATAL, "[ggi] Unknown image format: %s\n",
 		vo_format_name(ggi_conf.srcformat));
-	    uninit();
 	    return(-1);
     }
 
     vo_dwidth = ggi_conf.dstwidth = ggi_conf.gmode.virt.x;
     vo_dheight = ggi_conf.dstheight = ggi_conf.gmode.virt.y;
 
-    for (i = 0; i < GGI_FRAMES; i++)
+    ggi_conf.frames = ggiDBGetNumBuffers(ggi_conf.vis);
+    if (ggi_conf.frames > GGI_FRAMES)
+	ggi_conf.frames = GGI_FRAMES;
+    
+    ggi_conf.currframe = 0;
+    if (!ggi_conf.frames)
+    {
+	mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer unavailable\n");
+	return(-1);
+    }
+
+    for (i = 0; i < ggi_conf.frames; i++)
         ggi_conf.buffer[i] = NULL;
 
-    ggi_conf.frames = ggi_conf.currframe = 0;
-
     /* get available number of buffers */
-    for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i), i < GGI_FRAMES; i++)
+    for (i = 0; DB = ggiDBGetBuffer(ggi_conf.vis, i), i < ggi_conf.frames; i++)
     {
         if (!(DB->type & GGI_DB_SIMPLE_PLB) ||
     	    (DB->page_size != 0) ||
@@ -207,13 +213,11 @@
 	    continue;
 	
 	ggi_conf.buffer[DB->frame] = DB;
-	ggi_conf.frames++;
     }
 
     if (ggi_conf.buffer[0] == NULL)
     {
 	mp_msg(MSGT_VO, MSGL_ERR, "[ggi] direct buffer unavailable\n");
-	uninit();
 	return(-1);
     }