diff options
author | Klaus Schmidinger <vdr@tvdr.de> | 2003-10-04 12:42:58 +0200 |
---|---|---|
committer | Klaus Schmidinger <vdr@tvdr.de> | 2003-10-04 12:42:58 +0200 |
commit | 3f12ebbccb3c23b5722d591fe21d65134ff87f93 (patch) | |
tree | 7e1754dd6b9b3a9af11cd0e0ce4bd48e40a64c85 /dvbdevice.c | |
parent | 944ffee0a18e1a33770ef35f12bbe0e77850476c (diff) | |
download | vdr-3f12ebbccb3c23b5722d591fe21d65134ff87f93.tar.gz vdr-3f12ebbccb3c23b5722d591fe21d65134ff87f93.tar.bz2 |
Fixed detecting the /dev/videoN devices for GRAB in case there are others before the DVB devices
Diffstat (limited to 'dvbdevice.c')
-rw-r--r-- | dvbdevice.c | 40 |
1 files changed, 36 insertions, 4 deletions
diff --git a/dvbdevice.c b/dvbdevice.c index f29745b2..8c4c7264 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.64 2003/09/06 13:19:33 kls Exp $ + * $Id: dvbdevice.c 1.65 2003/10/04 12:31:15 kls Exp $ */ #include "dvbdevice.h" @@ -307,6 +307,8 @@ void cDvbTuner::Action(void) // --- cDvbDevice ------------------------------------------------------------ +int cDvbDevice::devVideoOffset = -1; + cDvbDevice::cDvbDevice(int n) { dvbTuner = NULL; @@ -317,8 +319,7 @@ cDvbDevice::cDvbDevice(int n) // Devices that are present on all card types: - int fd_frontend = DvbOpen(DEV_DVB_FRONTEND, n, O_RDWR | O_NONBLOCK); - + int fd_frontend = DvbOpen(DEV_DVB_FRONTEND, n, O_RDWR | O_NONBLOCK); // Devices that are only present on cards with decoders: fd_osd = DvbOpen(DEV_DVB_OSD, n, O_RDWR); @@ -329,6 +330,35 @@ cDvbDevice::cDvbDevice(int n) fd_dvr = -1; + // The offset of the /dev/video devices: + + if (devVideoOffset < 0) { // the first one checks this + FILE *f = NULL; + char buffer[PATH_MAX]; + for (int ofs = 0; ofs < 100; ofs++) { + snprintf(buffer, sizeof(buffer), "/proc/video/dev/video%d", ofs); + if ((f = fopen(buffer, "r")) != NULL) { + if (fgets(buffer, sizeof(buffer), f)) { + if (strstr(buffer, "DVB Board")) { // found the _first_ DVB card + devVideoOffset = ofs; + dsyslog("video device offset is %d", devVideoOffset); + break; + } + } + else + break; + fclose(f); + } + else + break; + } + if (devVideoOffset < 0) + devVideoOffset = 0; + if (f) + fclose(f); + } + devVideoIndex = (devVideoOffset >= 0 && HasDecoder()) ? devVideoOffset++ : -1; + // Video format: SetVideoFormat(Setup.VideoFormat ? VIDEO_FORMAT_16_9 : VIDEO_FORMAT_4_3); @@ -427,8 +457,10 @@ cSpuDecoder *cDvbDevice::GetSpuDecoder(void) bool cDvbDevice::GrabImage(const char *FileName, bool Jpeg, int Quality, int SizeX, int SizeY) { + if (devVideoIndex < 0) + return false; char buffer[PATH_MAX]; - snprintf(buffer, sizeof(buffer), "%s%d", DEV_VIDEO, CardIndex()); + snprintf(buffer, sizeof(buffer), "%s%d", DEV_VIDEO, devVideoIndex); int videoDev = open(buffer, O_RDWR); if (videoDev < 0) LOG_ERROR_STR(buffer); |