[Mplayer-cvslog] CVS: main/libvo vo_zr.c,1.23,1.24

Alex Beregszaszi alex at mplayerhq.hu
Sun Jun 22 01:23:08 CEST 2003


Update of /cvsroot/mplayer/main/libvo
In directory mail:/var/tmp.root/cvs-serv5830

Modified Files:
	vo_zr.c 
Log Message:
more flexible device name guessing

Index: vo_zr.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/vo_zr.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- vo_zr.c	24 Apr 2003 17:17:57 -0000	1.23
+++ vo_zr.c	21 Jun 2003 23:22:38 -0000	1.24
@@ -109,39 +109,37 @@
 
 
 int zoran_getcap(zr_info_t *zr) {
-	char* dev;
+	char* dev = NULL;
 
 	if (zr->device)
 		dev = zr->device;
-	else {  /* code borrowed from mjpegtools lavplay.c // 20020416 too */
+	else {
 		struct stat vstat;
+		const char *devs[] = {
+		    "/dev/video",
+		    "/dev/video0",
+		    "/dev/v4l/video0",
+		    "/dev/v4l0",
+		    "/dev/v4l",
+		    NULL
+		};
+		int i = 0;
+		
+		do
+		{
+		    if ((stat(devs[i], &vstat) == 0) && S_ISCHR(vstat.st_mode))
+		    {
+			dev = devs[i];
+			mp_msg(MSGT_VO, MSGL_V, "zr: found video device %s\n", dev);
+			break;
+		    }
+		} while (devs[++i] != NULL);
 
-#undef VIDEV		
-#define VIDEV "/dev/video"		
-		if (stat(VIDEV, &vstat) == 0 && S_ISCHR(vstat.st_mode))
-			dev = VIDEV;
-#undef VIDEV		
-#define VIDEV "/dev/video0"		
-		else if (stat(VIDEV, &vstat) == 0 && S_ISCHR(vstat.st_mode))
-			dev = VIDEV;
-#undef VIDEV		
-#define VIDEV "/dev/v4l/video0"		
-		else if (stat(VIDEV, &vstat) == 0 && S_ISCHR(vstat.st_mode))
-			dev = VIDEV;
-#undef VIDEV		
-#define VIDEV "/dev/v4l0"		
-		else if (stat(VIDEV, &vstat) == 0 && S_ISCHR(vstat.st_mode))
-			dev = VIDEV;
-#undef VIDEV		
-#define VIDEV "/dev/v4l"		
-		else if (stat(VIDEV, &vstat) == 0 && S_ISCHR(vstat.st_mode))
-			dev = VIDEV;
-#undef VIDEV		
-		else {
-			mp_msg(MSGT_VO, MSGL_ERR, "zr: unable to find video device\n");
-			return 1;
+		if (!dev)
+		{
+		    mp_msg(MSGT_VO, MSGL_ERR, "zr: unable to find video device\n");
+		    return 1;
 		}
-		mp_msg(MSGT_VO, MSGL_V, "zr: found video device %s\n", dev);
 	}
 			
 	zr->vdes = open(dev, O_RDWR);



More information about the MPlayer-cvslog mailing list