diff options
author | Lars Hanisch <dvb@flensrocker.de> | 2011-12-11 17:54:49 +0100 |
---|---|---|
committer | Lars Hanisch <dvb@flensrocker.de> | 2011-12-11 17:54:49 +0100 |
commit | 6f64fef48bf1223288d530fc243b0bbfce689ffe (patch) | |
tree | 46fdc5f77fc83648cb15664684bfb56b86717c28 | |
parent | e5899689c72ef8b583d08f79290739abafe2d7a2 (diff) | |
download | vdr-plugin-dynamite-6f64fef48bf1223288d530fc243b0bbfce689ffe.tar.gz vdr-plugin-dynamite-6f64fef48bf1223288d530fc243b0bbfce689ffe.tar.bz2 |
if the initial channel is empty, the current channel is the startup channelv0.0.8g
-rw-r--r-- | HISTORY | 4 | ||||
-rw-r--r-- | dynamicdevice.c | 2 | ||||
-rw-r--r-- | dynamite.c | 2 | ||||
-rw-r--r-- | status.c | 44 | ||||
-rw-r--r-- | status.h | 8 |
5 files changed, 35 insertions, 25 deletions
@@ -214,3 +214,7 @@ VDR Plugin 'dynamite' Revision History - try to set the initial channel on device-attach if it hasn't been set so far and the user or a timer hasn't selected another channel (giving up 60 seconds after startup) + +2011-12-11: Version 0.0.8g + +- if the initial channel is empty, the "current channel" is the "startup channel" diff --git a/dynamicdevice.c b/dynamicdevice.c index 3a499fc..bf643ca 100644 --- a/dynamicdevice.c +++ b/dynamicdevice.c @@ -227,7 +227,7 @@ attach: cString osdMsg = cString::sprintf(tr("attached %s"), DevPath); Skins.QueueMessage(mtInfo, *osdMsg); } - cDynamiteStatus::SetInitialChannel(); + cDynamiteStatus::SetStartupChannel(); return ddrcSuccess; } @@ -11,7 +11,7 @@ #include "monitor.h" #include "status.h" -static const char *VERSION = "0.0.8f"; +static const char *VERSION = "0.0.8g"; static const char *DESCRIPTION = tr("attach/detach devices on the fly"); static const char *MAINMENUENTRY = NULL; @@ -2,30 +2,30 @@ cDynamiteStatus *cDynamiteStatus::status = NULL; -#define SETINITIALCHANNELTIMEOUT 60 // 60 seconds +#define SETSTARTUPCHANNELTIMEOUT 60 // 60 seconds -cDynamiteStatus::cDynamiteStatus(int InitialChannel) +cDynamiteStatus::cDynamiteStatus(int StartupChannel) { init = time(NULL); - initialChannel = InitialChannel; - initialChannelSet = false; + startupChannel = StartupChannel; + startupChannelSet = false; switchCount = 0; - isyslog("dynamite: initial channel is %d", initialChannel); + isyslog("dynamite: startup channel is %d", startupChannel); } void cDynamiteStatus::ChannelSwitch(const cDevice *Device, int ChannelNumber) { - if ((ChannelNumber == 0) || initialChannelSet || (initialChannel < 0) || (switchCount > 1)) + if ((ChannelNumber == 0) || startupChannelSet || (startupChannel < 0) || (switchCount > 1)) return; if ((cDevice::PrimaryDevice() != cDevice::ActualDevice()) && (cDevice::PrimaryDevice() == Device)) return; - if (ChannelNumber == initialChannel) { - initialChannelSet = true; + if (ChannelNumber == startupChannel) { + startupChannelSet = true; return; } - if ((time(NULL) - init) > SETINITIALCHANNELTIMEOUT) { - isyslog("dynamite: no devices within %d seconds for receiving initial channel %d, giving up", SETINITIALCHANNELTIMEOUT, initialChannel); - initialChannelSet = true; + if ((time(NULL) - init) > SETSTARTUPCHANNELTIMEOUT) { + isyslog("dynamite: no devices within %d seconds for receiving initial channel %d, giving up", SETSTARTUPCHANNELTIMEOUT, startupChannel); + startupChannelSet = true; return; } isyslog("dynamite: device %d switches channel to %d", Device->DeviceNumber() + 1, ChannelNumber); @@ -38,15 +38,20 @@ void cDynamiteStatus::Init(void) { if (status) return; + int startupChannel = Setup.CurrentChannel; if (*Setup.InitialChannel) { cString cid = Setup.InitialChannel; - if (isnumber(cid)) { // for compatibility with old setup.conf files - if (cChannel *Channel = Channels.GetByNumber(atoi(cid))) - cid = Channel->GetChannelID().ToString(); + if (isnumber(cid)) // for compatibility with old setup.conf files + startupChannel = atoi(cid); + else { + if (cChannel *Channel = Channels.GetByChannelID(tChannelID::FromString(cid))) { + status = new cDynamiteStatus(Channel->Number()); + return; + } } - if (cChannel *Channel = Channels.GetByChannelID(tChannelID::FromString(cid))) - status = new cDynamiteStatus(Channel->Number()); } + if (cChannel *Channel = Channels.GetByNumber(startupChannel)) + status = new cDynamiteStatus(Channel->Number()); } void cDynamiteStatus::DeInit(void) @@ -57,14 +62,15 @@ void cDynamiteStatus::DeInit(void) status = NULL; } -void cDynamiteStatus::SetInitialChannel(void) +void cDynamiteStatus::SetStartupChannel(void) { if (status == NULL) return; - if (status->initialChannelSet) { + if (status->startupChannelSet) { DeInit(); return; } - if (!Channels.SwitchTo(status->initialChannel)) + isyslog("dynamite: new device attached, retry switching to startup channel %d", status->startupChannel); + if (!Channels.SwitchTo(status->startupChannel)) status->switchCount--; } @@ -8,18 +8,18 @@ private: static cDynamiteStatus *status; time_t init; - int initialChannel; - bool initialChannelSet; + int startupChannel; + bool startupChannelSet; int switchCount; - cDynamiteStatus(int InitialChannel); + cDynamiteStatus(int StartupChannel); virtual void ChannelSwitch(const cDevice *Device, int ChannelNumber); public: static void Init(void); static void DeInit(void); - static void SetInitialChannel(void); + static void SetStartupChannel(void); }; #endif // __DYNAMITESTATUS_H |