cDvbDevice::Initialize

Message ID 8762xt520c.874odd520c@8739sx520c.message.id
State New
Headers

Commit Message

syrius.ml@no-log.org Sept. 25, 2010, 2:38 p.m. UTC
  Hi,

I'm having a setup with 4 dvb cards, and I'm running 3 vdr instances.
I'm using an udev rules to make sure adapter numbers don't change.
I'm using the -D option the assign cards to vdr instances.

I've just discovered that vdr -D 3 would not use the adapter 3 if
adapter2 was missing from /dev/dvb/.

Here is the patch i'm testing to correct this issue, feel free to
comment.
--
  

Comments

Udo Richter Sept. 25, 2010, 9:58 p.m. UTC | #1
Am 25.09.2010 16:38, schrieb syrius.ml@no-log.org:
> I'm having a setup with 4 dvb cards, and I'm running 3 vdr instances.
> I'm using an udev rules to make sure adapter numbers don't change.
> I'm using the -D option the assign cards to vdr instances.
> 
> I've just discovered that vdr -D 3 would not use the adapter 3 if
> adapter2 was missing from /dev/dvb/.
> 
> Here is the patch i'm testing to correct this issue, feel free to
> comment.


This would still be wrong if adapter 2 is a dual or more frontend
device, because if adapter 2 has two frontends, then -D 2 and -D 3 refer
to adapter 2 and -D 4 is adapter 3.

IMHO the -D numbers are a bit outdated anyway, and I would prefer a way
to use /dev/dvb paths directly. Some concept ideas:

vdr -D /dev/dvb/adapter0
- use only adapter 0

vdr -D /dev/dvb/adapter0/frontend1
- use only frontend 1 of adapter 0 - this could be tricky

vdr -D /dev/dvb/adapter1 -D /dev/dvb/adapter0
- Swap ordering of devices

vdr -D /dev/dvb/primary
- follow a symlink primary -> adapter0, like generated by udev

vdr -D "/dev/dvb/*"
- use all DVB devices

vdr -D /dev/dvb/primary -D "/dev/dvb/adapter*"
- Use primary first, then use all remaining devices. No duplicates.

Implementing this needs some API changes, esp. since device plugins can
decide to override the default receiver of VDR, and this interface just
has adapter and frontend number. (dvbsddevice replaces the receive-only
receiver that way.)

Also, frontend numbers are more than parts of file names. If you swap
frontend 0 and 1 in the file system, VDR cannot receive any more. (been
there, done that.)


Cheers,

Udo
  
syrius.ml@no-log.org Sept. 25, 2010, 11:50 p.m. UTC | #2
Udo Richter <udo_richter@gmx.de> writes:

Hi !
Thanks for your answer !

> Am 25.09.2010 16:38, schrieb syrius.ml@no-log.org:
>> I'm having a setup with 4 dvb cards, and I'm running 3 vdr instances.
>> I'm using an udev rules to make sure adapter numbers don't change.
>> I'm using the -D option the assign cards to vdr instances.
>> 
>> I've just discovered that vdr -D 3 would not use the adapter 3 if
>> adapter2 was missing from /dev/dvb/.
>> 
>> Here is the patch i'm testing to correct this issue, feel free to
>> comment.
>
>
> This would still be wrong if adapter 2 is a dual or more frontend
> device, because if adapter 2 has two frontends, then -D 2 and -D 3 refer
> to adapter 2 and -D 4 is adapter 3.
>
> IMHO the -D numbers are a bit outdated anyway, and I would prefer a way
> to use /dev/dvb paths directly. Some concept ideas:

sure,
man page says:
       -D num, --device=num
              Use  only the given DVB device (num = 0, 1, 2...).
              There may be
              several -D options (by default all DVB devices will be
              used).

I was thinking adapter == device.
i think you're right, it's kind of outdated.

> vdr -D /dev/dvb/adapter0
> - use only adapter 0

agreed,
or -D 666
or -D /dev/dvb/adapter666
(lol@useDevice)

> vdr -D /dev/dvb/adapter0/frontend1
> - use only frontend 1 of adapter 0 - this could be tricky
>
> vdr -D /dev/dvb/adapter1 -D /dev/dvb/adapter0
> - Swap ordering of devices

i've stopped trying to understand how GetDevice decides... i guess
it's outdated as well.

> vdr -D /dev/dvb/primary
> - follow a symlink primary -> adapter0, like generated by udev
>
> vdr -D "/dev/dvb/*"
> - use all DVB devices
>
> vdr -D /dev/dvb/primary -D "/dev/dvb/adapter*"
> - Use primary first, then use all remaining devices. No duplicates.
>
> Implementing this needs some API changes, esp. since device plugins can
> decide to override the default receiver of VDR, and this interface just
> has adapter and frontend number. (dvbsddevice replaces the receive-only
> receiver that way.)
>
> Also, frontend numbers are more than parts of file names. If you swap
> frontend 0 and 1 in the file system, VDR cannot receive any more. (been
> there, done that.)

ok, it's not going to change anytime soon.
If we consider a device (man page) == an adapter, am I breaking things
down ?

--
  

Patch

--- dvbdevice.c.orig	2010-09-25 16:29:09.341396415 +0200
+++ dvbdevice.c	2010-09-25 16:25:37.087849316 +0200
@@ -786,29 +786,18 @@ 
   new cDvbSourceParam('C', "DVB-C");
   new cDvbSourceParam('S', "DVB-S");
   new cDvbSourceParam('T', "DVB-T");
-  int Checked = 0;
   int Found = 0;
-  for (int Adapter = 0; ; Adapter++) {
-      for (int Frontend = 0; ; Frontend++) {
-          if (Exists(Adapter, Frontend)) {
-             if (Checked++ < MAXDVBDEVICES) {
-                if (UseDevice(NextCardIndex())) {
-                   if (Probe(Adapter, Frontend))
-                      Found++;
-                   }
-                else
-                   NextCardIndex(1); // skips this one
-                }
-             }
-          else if (Frontend == 0)
-             goto LastAdapter;
-          else
-             goto NextAdapter;
-          }
-      NextAdapter: ;
-      }
-LastAdapter:
-  NextCardIndex(MAXDVBDEVICES - Checked); // skips the rest
+  for (int Adapter = 0; Adapter <= MAXDVBDEVICES; Adapter++) {
+     if (UseDevice(NextCardIndex())) {
+        for (int Frontend = 0; Exists(Adapter, Frontend); Frontend++) {
+           if (Probe(Adapter, Frontend)) {
+              Found++;
+           }
+        }
+     } else {
+        NextCardIndex(1); // skips this one
+     }
+  }
   if (Found > 0)
      isyslog("found %d DVB device%s", Found, Found > 1 ? "s" : "");
   else