# HG changeset patch # User alex # Date 1056237758 0 # Node ID 2e9b7465d24243a1d18d1020e801898f1854108d # Parent 2b3ef078e819975f33f4c8da99f3f95bf24da312 more flexible device name guessing diff -r 2b3ef078e819 -r 2e9b7465d242 libvo/vo_zr.c --- a/libvo/vo_zr.c Sat Jun 21 20:01:35 2003 +0000 +++ b/libvo/vo_zr.c Sat Jun 21 23:22:38 2003 +0000 @@ -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);