diff -Nru vdr-1.6.0/config.c vdr-1.6.0-ShareLNB/config.c --- vdr-1.6.0/config.c 2008-04-12 22:30:07.000000000 +0200 +++ vdr-1.6.0-ShareLNB/config.c 2008-04-12 22:30:39.000000000 +0200 @@ -225,6 +225,10 @@ MarkInstantRecord = 1; strcpy(NameInstantRecord, "TITLE EPISODE"); InstantRecordTime = 180; +//ML + VerboseLNBlog = 0; + for (int i = 0; i < MAXDEVICES; i++) CardUsesLNBnr[i] = i + 1; +//ML-End LnbSLOF = 11700; LnbFrequLo = 9750; LnbFrequHi = 10600; @@ -489,7 +493,21 @@ else if (!strcasecmp(Name, "ShowProgressBar")) ShowProgressBar = atoi(Value); else if (!strcasecmp(Name, "MenuCmdPosition")) MenuCmdPosition = atoi(Value); else - return false; +//ML + if (!strcasecmp(Name, "VerboseLNBlog")) VerboseLNBlog = atoi(Value); + else { + char tmp[20]; + bool result = false; + for (int i = 1; i <= MAXDEVICES; i++) { + sprintf(tmp, "Card%dusesLNBnr", i); + if (!strcasecmp(Name, tmp)) { + CardUsesLNBnr[i - 1] = atoi(Value); + result = true; + } + } + return result; + } +//ML-End return true; } @@ -507,6 +525,16 @@ Store("MarkInstantRecord", MarkInstantRecord); Store("NameInstantRecord", NameInstantRecord); Store("InstantRecordTime", InstantRecordTime); +//ML + Store("VerboseLNBlog", VerboseLNBlog); + char tmp[20]; + if (cDevice::NumDevices() > 1) { + for (int i = 1; i <= cDevice::NumDevices(); i++) { + sprintf(tmp, "Card%dusesLNBnr", i); + Store(tmp, CardUsesLNBnr[i - 1]); + } + } +//ML-End Store("LnbSLOF", LnbSLOF); Store("LnbFrequLo", LnbFrequLo); Store("LnbFrequHi", LnbFrequHi); diff -Nru vdr-1.6.0/config.h vdr-1.6.0-ShareLNB/config.h --- vdr-1.6.0/config.h 2008-04-12 22:30:07.000000000 +0200 +++ vdr-1.6.0-ShareLNB/config.h 2008-04-12 22:30:39.000000000 +0200 @@ -48,6 +48,10 @@ #define MINOSDHEIGHT 324 #define MAXOSDHEIGHT 567 +#define MAXDEVICES 16 // Since VDR 1.3.32 we can not #include "device.h" for MAXDEVICES anymore. + // With this workaround a warning will be shown during compilation if + // MAXDEVICES changes in device.h. + #define MaxFileName 256 #define MaxSkinName 16 #define MaxThemeName 16 @@ -215,6 +219,10 @@ int MarkInstantRecord; char NameInstantRecord[MaxFileName]; int InstantRecordTime; +//ML + int VerboseLNBlog; + int CardUsesLNBnr[MAXDEVICES]; +//ML-End int LnbSLOF; int LnbFrequLo; int LnbFrequHi; diff -Nru vdr-1.6.0/device.c vdr-1.6.0-ShareLNB/device.c --- vdr-1.6.0/device.c 2008-04-12 22:30:06.000000000 +0200 +++ vdr-1.6.0-ShareLNB/device.c 2008-04-12 22:30:39.000000000 +0200 @@ -18,6 +18,9 @@ #include "receiver.h" #include "status.h" #include "transfer.h" +//ML +#include "diseqc.h" +//ML-End // --- cLiveSubtitle --------------------------------------------------------- @@ -228,6 +231,12 @@ SetVideoFormat(Setup.VideoFormat); +//ML + LNBstate = -1; + LNBnr = Setup.CardUsesLNBnr[cardIndex]; + LNBsource = NULL; +//ML-End + mute = false; volume = Setup.CurrentVolume; @@ -290,6 +299,16 @@ useDevice |= (1 << n); } +//ML +void cDevice::SetLNBnr(void) +{ + for (int i = 0; i < numDevices; i++) { + device[i]->LNBnr = Setup.CardUsesLNBnr[i]; + isyslog("LNB-sharing: setting device %d to use LNB %d", i, device[i]->LNBnr); + } +} +//ML-End + int cDevice::NextCardIndex(int n) { if (n > 0) { @@ -350,6 +369,98 @@ return d; } +//ML +cDevice *cDevice::GetBadDevice(const cChannel *Channel) +{ + if (!cSource::IsSat(Channel->Source())) return NULL; + if (Setup.DiSEqC) { + cDiseqc *diseqc; + diseqc = Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()); + + for (int i = 0; i < numDevices; i++) { + if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBsource() != (int*) diseqc) { + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Device check for channel %d on device %d. LNB or DiSEq conflict with device %d", LNBnr, Channel->Number(), this->DeviceNumber(), i); + } + return device[i]; + } + } + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Device check for for channel %d on device %d. OK", LNBnr, Channel->Number(), this->DeviceNumber()); + } + } else { + char requiredState; + if (Channel->Frequency() >= Setup.LnbSLOF) { + requiredState = 1 ; + } else { + requiredState = 0; + } + if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2; + + for (int i = 0; i < numDevices; i++) { + if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBconf() != requiredState) { + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Device check for channel %d, LNBstate %d on device %d, current LNBstate %d. Conflict with device %d, LNBstate %d", LNBnr, Channel->Number(), requiredState, this->DeviceNumber(), LNBstate, i, device[i]->GetLNBconf()); + } + return device[i]; + } + } + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Device check for channel %d, LNBstate %d on device %d, current LNBstate %d. No other devices affected", LNBnr, Channel->Number(), requiredState, this->DeviceNumber(), LNBstate); + } + } + return NULL; +} + +int cDevice::GetMaxBadPriority(const cChannel *Channel) +{ + if (!cSource::IsSat(Channel->Source())) return -2; + bool PrimaryIsBad = false; + int maxBadPriority = -2; + if (Setup.DiSEqC) { + cDiseqc *diseqc; + diseqc = Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()); + + for (int i = 0; i < numDevices; i++) { + if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBsource() != (int*) diseqc) { + if (device[i]->Receiving() && device[i]->Priority() > maxBadPriority) { + maxBadPriority = device[i]->Priority(); + } + if (device[i]->IsPrimaryDevice()) { + PrimaryIsBad = true; + } + } + } + } else { + char requiredState; + if (Channel->Frequency() >= Setup.LnbSLOF) { + requiredState = 1 ; + } else { + requiredState = 0; + } + if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2; + + for (int i = 0; i < numDevices; i++) { + if (this != device[i] && device[i]->GetLNBnr() == LNBnr && device[i]->GetLNBconf() != requiredState) { + if (device[i]->Receiving() && device[i]->Priority() > maxBadPriority) { + maxBadPriority = device[i]->Priority(); + } + if (device[i]->IsPrimaryDevice()) { + PrimaryIsBad = true; + } + } + } + } + if (PrimaryIsBad && maxBadPriority == -2) { + maxBadPriority = -1; + } + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Request for channel %d on device %d. MaxBadPriority is %d", LNBnr, Channel->Number(), this->DeviceNumber(), maxBadPriority); + } + return maxBadPriority; +} +//ML-End + cDevice *cDevice::GetDevice(int Index) { return (0 <= Index && Index < numDevices) ? device[Index] : NULL; @@ -384,6 +495,10 @@ cCamSlot *s = NULL; uint32_t Impact = 0xFFFFFFFF; // we're looking for a device with the least impact +//ML + int badPriority; + uint imp2; +//ML-End for (int j = 0; j < NumCamSlots || !NumUsableSlots; j++) { if (NumUsableSlots && SlotPriority[j] > MAXPRIORITY) continue; // there is no CAM available in this slot @@ -416,7 +531,28 @@ imp <<= 1; imp |= NumUsableSlots ? 0 : device[i]->HasCi(); // avoid cards with Common Interface for FTA channels imp <<= 1; imp |= device[i]->HasDecoder(); // avoid full featured cards imp <<= 1; imp |= NumUsableSlots ? !ChannelCamRelations.CamDecrypt(Channel->GetChannelID(), j + 1) : 0; // prefer CAMs that are known to decrypt this channel - if (imp < Impact) { +//ML + badPriority = device[i]->GetMaxBadPriority(Channel); + if (badPriority >= Priority || (badPriority == -1 && Priority < Setup.PrimaryLimit)) { + // channel is not available for the requested prioity + imp = 0xFFFFFFFF; + } else { + switch (badPriority) { + case -2: // not affected by LNB-sharing + imp2 = 0; + break; + case -1: // the primary device would need a channel switch + imp += 1 << 17; + imp2 = 0xFFFFFFFF | 1 << 17; + break; + default: // a device receiving with lower priority would need to be stopped + imp += badPriority << 8; + imp2 = 0xFFFFFFFF | badPriority << 8; + break; + } + } + if (imp < Impact && imp2 < Impact) { +//ML-End // This device has less impact than any previous one, so we take it. Impact = imp; d = device[i]; @@ -701,7 +837,9 @@ bool cDevice::ProvidesTransponderExclusively(const cChannel *Channel) const { for (int i = 0; i < numDevices; i++) { - if (device[i] && device[i] != this && device[i]->ProvidesTransponder(Channel)) +//ML + if (device[i] && device[i] != this && device[i]->ProvidesTransponder(Channel) && device[i]->GetLNBnr() != LNBnr) +//ML-End return false; } return true; @@ -724,6 +862,24 @@ bool cDevice::SwitchChannel(const cChannel *Channel, bool LiveView) { +//ML + cDevice *tmpDevice; + if (this->GetMaxBadPriority(Channel) >= 0) { + Skins.Message(mtInfo, tr("Channel locked by LNB!")); + return false; + } + while ((tmpDevice = GetBadDevice(Channel)) != NULL) { + if (tmpDevice->IsPrimaryDevice() && LiveView) + tmpDevice->SwitchChannelForced(Channel, true); + else + tmpDevice->SwitchChannelForced(Channel, false); + } + return SwitchChannelForced(Channel, LiveView); +} + +bool cDevice::SwitchChannelForced(const cChannel *Channel, bool LiveView) +{ +//ML-End if (LiveView) { isyslog("switching to channel %d", Channel->Number()); cControl::Shutdown(); // prevents old channel from being shown too long if GetDevice() takes longer @@ -753,7 +909,9 @@ cChannel *channel; while ((channel = Channels.GetByNumber(n, Direction)) != NULL) { // try only channels which are currently available - if (GetDevice(channel, 0, true)) +//ML + if (PrimaryDevice()->GetMaxBadPriority(channel) < 0 && (GetDevice(channel, 0, true))) +//ML-End break; n = channel->Number() + Direction; } @@ -786,11 +944,37 @@ eSetChannelResult Result = scrOk; +//ML + char requiredState; + if (Channel->Frequency() >= Setup.LnbSLOF) { + requiredState = 1; + } else { + requiredState = 0; + } + if (Channel->Polarization() == 'v' || Channel->Polarization() == 'V') requiredState += 2; + if (Setup.VerboseLNBlog) { + isyslog("LNB %d: Switching device %d to channel %d", LNBnr, this->DeviceNumber(), Channel->Number()); + } +//ML-End + // If this DVB card can't receive this channel, let's see if we can // use the card that actually can receive it and transfer data from there: if (NeedsTransferMode) { if (Device && CanReplay()) { +//ML + if (Device->GetLNBnr() == LNBnr) { + if (LNBstate != requiredState || (Setup.DiSEqC && LNBsource != (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization())) ) { + if (IsPrimaryDevice()) { + SetChannelDevice(Channel, true); + } else { + SetChannelDevice(Channel, false); + } + LNBstate = requiredState; + LNBsource = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()); + } + } +//ML-End cStatus::MsgChannelSwitch(this, 0); // only report status if we are actually going to switch the channel if (Device->SetChannel(Channel, false) == scrOk) // calling SetChannel() directly, not SwitchChannel()! cControl::Launch(new cTransferControl(Device, Channel->GetChannelID(), Channel->Vpid(), Channel->Apids(), Channel->Dpids(), Channel->Spids())); @@ -808,6 +992,10 @@ sectionHandler->SetStatus(false); sectionHandler->SetChannel(NULL); } +//ML + LNBstate = requiredState; + LNBsource = (int*) Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization()); +//ML-End // Tell the camSlot about the channel switch and add all PIDs of this // channel to it, for possible later decryption: if (camSlot) diff -Nru vdr-1.6.0/device.h vdr-1.6.0-ShareLNB/device.h --- vdr-1.6.0/device.h 2008-02-23 14:13:04.000000000 +0100 +++ vdr-1.6.0-ShareLNB/device.h 2008-04-12 22:30:39.000000000 +0200 @@ -146,6 +146,31 @@ ///< this device/CAM combination will be skipped in the next call to ///< GetDevice(). ///< See also ProvidesChannel(). +//ML +private: + char LNBstate; // Current frequency band and polarization of the DVB-tuner +// cDiseqc *LNBsource; // can not #include "diseqc.h". A workaround follows: + int *LNBsource; // [DiSEqC] DiSEqC-Source + int LNBnr; // Number of LNB used +public: + char GetLNBconf(void) { return LNBstate; } + int *GetLNBsource(void) { return LNBsource; } + int GetLNBnr(void) { return LNBnr; } + static void SetLNBnr(void); + cDevice *GetBadDevice(const cChannel *Channel); + ///< Returns NULL if there is no device which uses the same LNB or if + ///< all of those devices are tuned to the same frequency band and + ///< polarization as of the requested channel. + ///< Otherwise returns the first device found. + int GetMaxBadPriority(const cChannel *Channel); + ///< Returns the highest priority of all receiving devices which use + ///< the same LNB and are tuned to a different frequency band or + ///< polarization as of the requested channel. + ///< Returns -1 if there are no such devices, but the primary device + ///< would be affected by switching to the requested channel. + ///< Returns -2 if there are no such devices and the primary device + ///< would not be affected by switching to the requested channel. +//ML-End static void SetAvoidDevice(cDevice *Device) { avoidDevice = Device; } ///< Sets the given Device to be temporarily avoided in the next call to ///< GetDevice(const cChannel, int, bool). @@ -237,6 +262,11 @@ bool SwitchChannel(const cChannel *Channel, bool LiveView); ///< Switches the device to the given Channel, initiating transfer mode ///< if necessary. +//ML + bool SwitchChannelForced(const cChannel *Channel, bool LiveView); + ///< Switches the device to the given channel, initiating transfer mode + ///< if necessary. Forces the switch without taking care of the LNB configuration. +//ML-End static bool SwitchChannel(int Direction); ///< Switches the primary device to the next available channel in the given ///< Direction (only the sign of Direction is evaluated, positive values diff -Nru vdr-1.6.0/eitscan.c vdr-1.6.0-ShareLNB/eitscan.c --- vdr-1.6.0/eitscan.c 2006-01-07 15:10:17.000000000 +0100 +++ vdr-1.6.0-ShareLNB/eitscan.c 2008-04-12 22:30:39.000000000 +0200 @@ -151,9 +151,13 @@ if (Device->ProvidesTransponder(Channel)) { if (!Device->Receiving()) { bool MaySwitchTransponder = Device->MaySwitchTransponder(); - if (MaySwitchTransponder || Device->ProvidesTransponderExclusively(Channel) && now - lastActivity > Setup.EPGScanTimeout * 3600) { +//ML + if (MaySwitchTransponder && Device->GetMaxBadPriority(Channel) == -2 || Device->ProvidesTransponderExclusively(Channel) && Device->GetMaxBadPriority(Channel) <= -1 && now - lastActivity > Setup.EPGScanTimeout * 3600) { +//ML-End if (!MaySwitchTransponder) { - if (Device == cDevice::ActualDevice() && !currentChannel) { +//ML + if ((Device == cDevice::ActualDevice() || Device->GetMaxBadPriority(Channel) == -1) && !currentChannel) { +//ML-End cDevice::PrimaryDevice()->StopReplay(); // stop transfer mode currentChannel = Device->CurrentChannel(); Skins.Message(mtInfo, tr("Starting EPG scan")); diff -Nru vdr-1.6.0/menu.c vdr-1.6.0-ShareLNB/menu.c --- vdr-1.6.0/menu.c 2008-04-12 22:30:09.000000000 +0200 +++ vdr-1.6.0-ShareLNB/menu.c 2008-04-12 22:30:39.000000000 +0200 @@ -2941,6 +2941,22 @@ Clear(); +//ML + int numSatDevices = 0; + for (int i = 0; i < cDevice::NumDevices(); i++) { + if (cDevice::GetDevice(i)->ProvidesSource(cSource::stSat)) numSatDevices++; + } + if (numSatDevices > 1) { + char tmp[30]; + for (int i = 1; i <= cDevice::NumDevices(); i++) { + if (cDevice::GetDevice(i - 1)->ProvidesSource(cSource::stSat)) { + sprintf( tmp, tr("Setup.LNB$DVB device %d uses LNB No."), i); + Add(new cMenuEditIntItem( tmp, &data.CardUsesLNBnr[i - 1], 1, numSatDevices )); + } + } + } + Add(new cMenuEditBoolItem(tr("Setup.LNB$Log LNB usage"), &data.VerboseLNBlog)); +//ML-End Add(new cMenuEditBoolItem(tr("Setup.LNB$Use DiSEqC"), &data.DiSEqC)); if (!data.DiSEqC) { Add(new cMenuEditIntItem( tr("Setup.LNB$SLOF (MHz)"), &data.LnbSLOF)); @@ -2957,6 +2973,10 @@ int oldDiSEqC = data.DiSEqC; eOSState state = cMenuSetupBase::ProcessKey(Key); +//ML + if (Key == kOk) cDevice::SetLNBnr(); +//ML-End + if (Key != kNone && data.DiSEqC != oldDiSEqC) Setup(); return state; @@ -3694,7 +3714,9 @@ if (Direction) { while (Channel) { Channel = Direction > 0 ? Channels.Next(Channel) : Channels.Prev(Channel); - if (Channel && !Channel->GroupSep() && cDevice::GetDevice(Channel, 0, true)) +//ML + if (Channel && !Channel->GroupSep() && cDevice::GetDevice(Channel, 0, true) && cDevice::PrimaryDevice()->GetMaxBadPriority(Channel) < 0) +//ML-End return Channel; } } @@ -4319,6 +4341,18 @@ int Priority = Timer ? Timer->Priority() : Pause ? Setup.PausePriority : Setup.DefaultPriority; cDevice *device = cDevice::GetDevice(channel, Priority, false); if (device) { +//ML + cDevice *tmpDevice; + while ((tmpDevice = device->GetBadDevice(channel))) { + if (tmpDevice->Replaying() == false) { + if (tmpDevice->IsPrimaryDevice() ) + tmpDevice->SwitchChannelForced(channel, true); + else + tmpDevice->SwitchChannelForced(channel, false); + } else + tmpDevice->SwitchChannelForced(channel, false); + } +//ML-End dsyslog("switching device %d to channel %d", device->DeviceNumber() + 1, channel->Number()); if (!device->SwitchChannel(channel, false)) { ShutdownHandler.RequestEmergencyExit(); diff -Nru vdr-1.6.0/po/de_DE.po vdr-1.6.0-ShareLNB/po/de_DE.po --- vdr-1.6.0/po/de_DE.po 2008-04-12 22:30:07.000000000 +0200 +++ vdr-1.6.0-ShareLNB/po/de_DE.po 2008-04-12 22:30:39.000000000 +0200 @@ -665,6 +665,12 @@ msgid "Setup.DVB$Subtitle background transparency" msgstr "Untertitel-Transparenz Hintergrund" +msgid "Setup.LNB$DVB device %d uses LNB No." +msgstr "DVB-Empfänger %d nutzt LNB Nr." + +msgid "Setup.LNB$Log LNB usage" +msgstr "LNB-Nutzung protokollieren" + msgid "LNB" msgstr "LNB" diff -Nru vdr-1.6.0/po/fr_FR.po vdr-1.6.0-ShareLNB/po/fr_FR.po --- vdr-1.6.0/po/fr_FR.po 2008-04-12 22:30:07.000000000 +0200 +++ vdr-1.6.0-ShareLNB/po/fr_FR.po 2008-04-12 22:30:39.000000000 +0200 @@ -674,6 +674,12 @@ msgid "Setup.DVB$Use Sync Early Patch" msgstr "Utiliser le Patch Sync Early" +msgid "Setup.LNB$DVB device %d uses LNB No." +msgstr "La carte DVB %d utilise la LNB No." + +msgid "Setup.LNB$Log LNB usage" +msgstr "Enregistrer l'utilisation de la LNB" + msgid "LNB" msgstr "LNB"