Fixed detecting the /dev/videoN devices for GRAB in case there are others before the DVB devices

This commit is contained in:
Klaus Schmidinger 2003-10-04 12:42:58 +02:00
parent 944ffee0a1
commit 3f12ebbccb
4 changed files with 44 additions and 5 deletions

View File

@ -568,6 +568,8 @@ Andreas Kool <akool@akool.de>
for his help in keeping 'channels.conf.cable' up to date
for fixing the TS to PES repacker so that it works with MPEG1 streams
for reporting a problem with empty values in setup.conf
for fixing detecting the /dev/videoN devices for GRAB in case there are others
before the DVB devices
Guy Roussin <guy.roussin@teledetection.fr>
for suggesting not to display channel group delimiters without text

View File

@ -2411,3 +2411,5 @@ Video Disk Recorder Revision History
to Andreas Trauer).
- Fixed handling a channels.conf that contains a ":@nnn" line as its last entry
(thanks to Ralf Klueber).
- Fixed detecting the /dev/videoN devices for GRAB in case there are others
before the DVB devices (thanks to Andreas Kool).

View File

@ -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);

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
* $Id: dvbdevice.h 1.22 2003/08/15 12:34:55 kls Exp $
* $Id: dvbdevice.h 1.23 2003/10/04 11:54:50 kls Exp $
*/
#ifndef __DVBDEVICE_H
@ -73,6 +73,9 @@ protected:
// Image Grab facilities
private:
static int devVideoOffset;
int devVideoIndex;
public:
virtual bool GrabImage(const char *FileName, bool Jpeg = true, int Quality = -1, int SizeX = -1, int SizeY = -1);