New command line option -D

This commit is contained in:
Klaus Schmidinger 2001-02-02 15:49:46 +01:00
parent 495f8b0669
commit b79ccf2292
5 changed files with 55 additions and 26 deletions

View File

@ -362,3 +362,5 @@ Video Disk Recorder Revision History
- The new compile time option REMOTE=NONE can be used to compile VDR without - The new compile time option REMOTE=NONE can be used to compile VDR without
any remote control support (for applications where it shall be controlled any remote control support (for applications where it shall be controlled
exclusively via SVDRP). exclusively via SVDRP).
- The new command line option -D can be used to define which DVB interfaces
a certain instance of VDR shall use.

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: config.h 1.38 2001/01/14 15:29:27 kls Exp $ * $Id: config.h 1.39 2001/02/02 15:22:47 kls Exp $
*/ */
#ifndef __CONFIG_H #ifndef __CONFIG_H
@ -19,7 +19,7 @@
#include "eit.h" #include "eit.h"
#include "tools.h" #include "tools.h"
#define VDRVERSION "0.70" #define VDRVERSION "0.71"
#define MaxBuffer 10000 #define MaxBuffer 10000

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbapi.c 1.54 2001/02/02 13:10:39 kls Exp $ * $Id: dvbapi.c 1.55 2001/02/02 15:35:44 kls Exp $
*/ */
#include "dvbapi.h" #include "dvbapi.h"
@ -1570,6 +1570,7 @@ bool cVideoCutter::Active(void)
// --- cDvbApi --------------------------------------------------------------- // --- cDvbApi ---------------------------------------------------------------
int cDvbApi::NumDvbApis = 0; int cDvbApi::NumDvbApis = 0;
int cDvbApi::useDvbApi = 0;
cDvbApi *cDvbApi::dvbApi[MAXDVBAPI] = { NULL }; cDvbApi *cDvbApi::dvbApi[MAXDVBAPI] = { NULL };
cDvbApi *cDvbApi::PrimaryDvbApi = NULL; cDvbApi *cDvbApi::PrimaryDvbApi = NULL;
@ -1639,6 +1640,12 @@ cDvbApi::~cDvbApi()
#endif #endif
} }
void cDvbApi::SetUseDvbApi(int n)
{
if (n < MAXDVBAPI)
useDvbApi |= (1 << n);
}
bool cDvbApi::SetPrimaryDvbApi(int n) bool cDvbApi::SetPrimaryDvbApi(int n)
{ {
n--; n--;
@ -1685,33 +1692,34 @@ bool cDvbApi::Init(void)
{ {
NumDvbApis = 0; NumDvbApis = 0;
for (int i = 0; i < MAXDVBAPI; i++) { for (int i = 0; i < MAXDVBAPI; i++) {
char fileName[strlen(VIDEODEVICE) + 10]; if (useDvbApi == 0 || (useDvbApi & (1 << i)) != 0) {
sprintf(fileName, "%s%d", VIDEODEVICE, i); char fileName[strlen(VIDEODEVICE) + 10];
if (access(fileName, F_OK | R_OK | W_OK) == 0) { sprintf(fileName, "%s%d", VIDEODEVICE, i);
dsyslog(LOG_INFO, "probing %s", fileName); if (access(fileName, F_OK | R_OK | W_OK) == 0) {
int f = open(fileName, O_RDWR); dsyslog(LOG_INFO, "probing %s", fileName);
if (f >= 0) { int f = open(fileName, O_RDWR);
struct video_capability cap; if (f >= 0) {
int r = ioctl(f, VIDIOCGCAP, &cap); struct video_capability cap;
close(f); int r = ioctl(f, VIDIOCGCAP, &cap);
if (r == 0 && (cap.type & VID_TYPE_DVB)) { close(f);
char vbiFileName[strlen(VBIDEVICE) + 10]; if (r == 0 && (cap.type & VID_TYPE_DVB)) {
sprintf(vbiFileName, "%s%d", VBIDEVICE, i); char vbiFileName[strlen(VBIDEVICE) + 10];
dvbApi[i] = new cDvbApi(fileName, vbiFileName); sprintf(vbiFileName, "%s%d", VBIDEVICE, i);
NumDvbApis++; dvbApi[NumDvbApis++] = new cDvbApi(fileName, vbiFileName);
}
}
else {
if (errno != ENODEV)
LOG_ERROR_STR(fileName);
break;
} }
} }
else { else {
if (errno != ENODEV) if (errno != ENOENT)
LOG_ERROR_STR(fileName); LOG_ERROR_STR(fileName);
break; break;
} }
} }
else {
if (errno != ENOENT)
LOG_ERROR_STR(fileName);
break;
}
} }
PrimaryDvbApi = dvbApi[0]; PrimaryDvbApi = dvbApi[0];
if (NumDvbApis > 0) { if (NumDvbApis > 0) {

View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: dvbapi.h 1.30 2001/01/07 15:56:10 kls Exp $ * $Id: dvbapi.h 1.31 2001/02/02 15:21:30 kls Exp $
*/ */
#ifndef __DVBAPI_H #ifndef __DVBAPI_H
@ -73,8 +73,13 @@ public:
static int NumDvbApis; static int NumDvbApis;
private: private:
static cDvbApi *dvbApi[MAXDVBAPI]; static cDvbApi *dvbApi[MAXDVBAPI];
static int useDvbApi;
public: public:
static cDvbApi *PrimaryDvbApi; static cDvbApi *PrimaryDvbApi;
static void SetUseDvbApi(int n);
// Sets the 'useDvbApi' flag of the given DVB device.
// If this function is not called before Init(), all DVB devices
// will be used.
static bool SetPrimaryDvbApi(int n); static bool SetPrimaryDvbApi(int n);
// Sets the primary DVB device to 'n' (which must be in the range // Sets the primary DVB device to 'n' (which must be in the range
// 1...NumDvbApis) and returns true if this was possible. // 1...NumDvbApis) and returns true if this was possible.

18
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/people/kls/vdr * The project's page is at http://www.cadsoft.de/people/kls/vdr
* *
* $Id: vdr.c 1.49 2001/01/14 15:29:51 kls Exp $ * $Id: vdr.c 1.50 2001/02/02 15:48:11 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -66,6 +66,7 @@ int main(int argc, char *argv[])
static struct option long_options[] = { static struct option long_options[] = {
{ "config", required_argument, NULL, 'c' }, { "config", required_argument, NULL, 'c' },
{ "daemon", no_argument, NULL, 'd' }, { "daemon", no_argument, NULL, 'd' },
{ "device", required_argument, NULL, 'D' },
{ "help", no_argument, NULL, 'h' }, { "help", no_argument, NULL, 'h' },
{ "log", required_argument, NULL, 'l' }, { "log", required_argument, NULL, 'l' },
{ "port", required_argument, NULL, 'p' }, { "port", required_argument, NULL, 'p' },
@ -75,16 +76,29 @@ int main(int argc, char *argv[])
int c; int c;
int option_index = 0; int option_index = 0;
while ((c = getopt_long(argc, argv, "c:dhl:p:v:", long_options, &option_index)) != -1) { while ((c = getopt_long(argc, argv, "c:dD:hl:p:v:", long_options, &option_index)) != -1) {
switch (c) { switch (c) {
case 'c': ConfigDirectory = optarg; case 'c': ConfigDirectory = optarg;
break; break;
case 'd': DaemonMode = true; break; case 'd': DaemonMode = true; break;
case 'D': if (isnumber(optarg)) {
int n = atoi(optarg);
if (0 <= n && n < MAXDVBAPI) {
cDvbApi::SetUseDvbApi(n);
break;
}
}
fprintf(stderr, "vdr: invalid DVB device number: %s\n", optarg);
abort();
break;
case 'h': printf("Usage: vdr [OPTION]\n\n" // for easier orientation, this is column 80| case 'h': printf("Usage: vdr [OPTION]\n\n" // for easier orientation, this is column 80|
" -c DIR, --config=DIR read config files from DIR (default is to read them\n" " -c DIR, --config=DIR read config files from DIR (default is to read them\n"
" from the video directory)\n" " from the video directory)\n"
" -h, --help display this help and exit\n" " -h, --help display this help and exit\n"
" -d, --daemon run in daemon mode\n" " -d, --daemon run in daemon mode\n"
" -D NUM, --device=NUM use only the given DVB device (NUM = 0, 1, 2...)\n"
" there may be several -D options (default: all DVB\n"
" devices will be used)\n"
" -l LEVEL, --log=LEVEL set log level (default: 3)\n" " -l LEVEL, --log=LEVEL set log level (default: 3)\n"
" 0 = no logging, 1 = errors only,\n" " 0 = no logging, 1 = errors only,\n"
" 2 = errors and info, 3 = errors, info and debug\n" " 2 = errors and info, 3 = errors, info and debug\n"