From 41adafa231a3130288c7140449c02a3608c6599c Mon Sep 17 00:00:00 2001 From: Lars Hanisch Date: Wed, 15 Jun 2011 23:01:54 +0200 Subject: add udev property dynamite_cardindex to attach a device at a preferred slot (if free) --- dynamite.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'dynamite.c') diff --git a/dynamite.c b/dynamite.c index 29f87bb..aeaf513 100644 --- a/dynamite.c +++ b/dynamite.c @@ -10,7 +10,7 @@ #include "menu.h" #include "monitor.h" -static const char *VERSION = "0.0.6c"; +static const char *VERSION = "0.0.6d"; static const char *DESCRIPTION = tr("attach/detach devices on the fly"); static const char *MAINMENUENTRY = NULL; @@ -20,9 +20,15 @@ private: public: virtual bool Probe(int Adapter, int Frontend) { + if (firstProbe) { + firstProbe = false; + isyslog("dynamite: preparing %d dynamic device slots for dvb devices", MAXDVBDEVICES); + while (cDevice::NumDevices() < MAXDVBDEVICES) + new cDynamicDevice; + } cString devpath = cString::sprintf("/dev/dvb/adapter%d/frontend%d", Adapter, Frontend); int freeIndex = -1; - if (cDynamicDevice::IndexOf(*devpath, freeIndex) >= 0) // already attached - should not happen + if (cDynamicDevice::IndexOf(*devpath, freeIndex, -1) >= 0) // already attached - should not happen return true; if (freeIndex < 0) { if ((cDevice::NumDevices() >= MAXDEVICES) || (cDynamicDevice::NumDynamicDevices() >= MAXDEVICES)) { @@ -209,7 +215,7 @@ bool cPluginDynamite::Initialize(void) int dummy = 0; for (cUdevDevice *d = devices->First(); d; d = devices->Next(d)) { const char *devpath = d->GetDevnode(); - if ((devpath != NULL) && (cDynamicDevice::IndexOf(devpath, dummy) < 0)) { + if ((devpath != NULL) && (cDynamicDevice::IndexOf(devpath, dummy, -1) < 0)) { isyslog("dynamite: probing %s", devpath); cDynamicDeviceProbe::QueueDynamicDeviceCommand(ddpcAttach, devpath); } -- cgit v1.2.3