From 7c7556536b242fa8fd29a9a325427339007fda03 Mon Sep 17 00:00:00 2001 From: Lars Hanisch Date: Wed, 4 Jan 2012 19:56:37 +0100 Subject: set cardindex to adapter number if no udev rule is used --- dynamicdevice.c | 17 ++++++++++------- dynamite.c | 2 +- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/dynamicdevice.c b/dynamicdevice.c index deab412..b7741ee 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -53,8 +53,6 @@ int cDynamicDevice::IndexOf(const char *DevPath, int &NextFreeIndex, int WishInd int index = -1; for (int i = 0; (i < numDynamicDevices) && ((index < 0) || (NextFreeIndex < 0) || (WishIndex >= 0)); i++) { if (dynamicdevice[i]->devpath == NULL) { - if (WishIndex >= 0) - isyslog("dynamite: device at slot %d has cardindex %d", i + 1, dynamicdevice[i]->CardIndex()); if ((NextFreeIndex < 0) || ((WishIndex >= 0) && (dynamicdevice[i]->CardIndex() == WishIndex))) { NextFreeIndex = i; if ((dynamicdevice[i]->CardIndex() == WishIndex) && (index >= 0)) @@ -201,15 +199,20 @@ eDynamicDeviceReturnCode cDynamicDevice::AttachDevice(const char *DevPath, int D return ddrcNotSupported; cMutexLock lock(&arrayMutex); + int freeIndex = -1; + int index = -1; + int adapter = -1; + int frontend = -1; int wishIndex = -1; int attachDelay = 0; GetUdevAttributesForAttach(DevPath, wishIndex, attachDelay); if (wishIndex >= 0) isyslog("dynamite: %s wants card index %d", DevPath, wishIndex); - int freeIndex = -1; - int index = IndexOf(DevPath, freeIndex, wishIndex); - int adapter = -1; - int frontend = -1; + else if (sscanf(DevPath, "/dev/dvb/adapter%d/frontend%d", &adapter, &frontend) == 2) { + wishIndex = adapter; + isyslog("dynamite: %s is a dvb adapter trying to set card index to %d", DevPath, wishIndex); + } + index = IndexOf(DevPath, freeIndex, wishIndex); if (index >= 0) { isyslog("dynamite: %s is already attached", DevPath); @@ -257,7 +260,7 @@ eDynamicDeviceReturnCode cDynamicDevice::AttachDevice(const char *DevPath, int D } // if it's a dvbdevice try the DvbDeviceProbes as a fallback for unpatched plugins - if (sscanf(DevPath, "/dev/dvb/adapter%d/frontend%d", &adapter, &frontend) == 2) { + if ((adapter >= 0) || (sscanf(DevPath, "/dev/dvb/adapter%d/frontend%d", &adapter, &frontend) == 2)) { for (cDvbDeviceProbe *dp = DvbDeviceProbes.First(); dp; dp = DvbDeviceProbes.Next(dp)) { if (dp != dvbprobe) { if (dp->Probe(adapter, frontend)) diff --git a/dynamite.c b/dynamite.c index 2709998..428ea64 100644 --- a/dynamite.c +++ b/dynamite.c @@ -11,7 +11,7 @@ #include "monitor.h" #include "status.h" -static const char *VERSION = "0.0.9"; +static const char *VERSION = "0.0.9a"; static const char *DESCRIPTION = tr("attach/detach devices on the fly"); static const char *MAINMENUENTRY = NULL; -- cgit v1.2.3