diff options
author | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-06-21 23:22:38 +0000 |
---|---|---|
committer | alex <alex@b3059339-0415-0410-9bf9-f77b7e298cf2> | 2003-06-21 23:22:38 +0000 |
commit | b6a67e53780b1fdd8c5900bb99ae9a31f17d5e97 (patch) | |
tree | 52331bdc5a3eee68e6134725a7f6b41db46852af /libvo | |
parent | f6979cf4204b2a8a228fa168786c9e27338c6851 (diff) | |
download | mpv-b6a67e53780b1fdd8c5900bb99ae9a31f17d5e97.tar.bz2 mpv-b6a67e53780b1fdd8c5900bb99ae9a31f17d5e97.tar.xz |
more flexible device name guessing
git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@10320 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libvo')
-rw-r--r-- | libvo/vo_zr.c | 54 |
1 files changed, 26 insertions, 28 deletions
diff --git a/libvo/vo_zr.c b/libvo/vo_zr.c index 55719963c6..2d4dd39b2f 100644 --- a/libvo/vo_zr.c +++ b/libvo/vo_zr.c @@ -109,39 +109,37 @@ static zr_info_t zr_info[ZR_MAX_DEVICES] = { 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; - -#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; + 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); + + 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); |