diff options
Diffstat (limited to 'device.c')
-rw-r--r-- | device.c | 58 |
1 files changed, 35 insertions, 23 deletions
@@ -4,13 +4,14 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: device.c 1.22 2002/09/28 12:20:22 kls Exp $ + * $Id: device.c 1.25 2002/10/06 13:49:38 kls Exp $ */ #include "device.h" #include <errno.h> #include <sys/ioctl.h> #include <sys/mman.h> +#include "channels.h" #include "eit.h" #include "i18n.h" #include "player.h" @@ -143,7 +144,7 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDe || !d->Receiving() // ...the one we have is not receiving... && (device[i]->Priority() < d->Priority() // ...this one has an even lower Priority, or... || device[i]->Priority() == d->Priority() // ...same Priority... - && device[i]->ProvidesCa(Channel->ca) < d->ProvidesCa(Channel->ca) // ...but this one provides fewer Ca values + && device[i]->ProvidesCa(Channel->Ca()) < d->ProvidesCa(Channel->Ca()) // ...but this one provides fewer Ca values ) ) ) { @@ -275,6 +276,11 @@ bool cDevice::SetPid(cPidHandle *Handle, int Type, bool On) return false; } +bool cDevice::ProvidesSource(int Source) const +{ + return false; +} + bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const { return false; @@ -283,11 +289,13 @@ bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *Needs bool cDevice::SwitchChannel(const cChannel *Channel, bool LiveView) { if (LiveView) - isyslog("switching to channel %d", Channel->number); + isyslog("switching to channel %d", Channel->Number()); for (int i = 3; i--;) { switch (SetChannel(Channel, LiveView)) { case scrOk: return true; - case scrNotAvailable: return false; + case scrNotAvailable: if (Interface) + Interface->Error(tr("Channel not available!")); + return false; case scrNoTransfer: if (Interface) Interface->Error(tr("Can't start Transfer Mode!")); return false; @@ -305,21 +313,25 @@ bool cDevice::SwitchChannel(int Direction) if (Direction) { int n = CurrentChannel() + Direction; int first = n; - for (;;) { - cChannel *channel = Channels.GetByNumber(n); - if (!channel) - break; - if (PrimaryDevice()->SwitchChannel(channel, true)) { - result = true; - break; - } - n += Direction; - } - int d = n - first; - if (abs(d) == 1) - dsyslog("skipped channel %d", first); - else if (d) - dsyslog("skipped channels %d..%d", first, n - sgn(d)); + PrimaryDevice()->StopReplay(); // otherwise a running Transfer Mode would block channels + cChannel *channel; + while ((channel = Channels.GetByNumber(n)) != NULL) { + // try only channels which are currently available + if (PrimaryDevice()->ProvidesChannel(channel, Setup.PrimaryLimit) || GetDevice(channel, 0)) + break; + n += Direction; + } + if (channel) { + int d = n - first; + if (abs(d) == 1) + dsyslog("skipped channel %d", first); + else if (d) + dsyslog("skipped channels %d..%d", first, n - sgn(d)); + if (PrimaryDevice()->SwitchChannel(channel, true)) + result = true; + } + else if (n != first && Interface) + Interface->Error(tr("Channel not available!")); } return result; } @@ -344,7 +356,7 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView) if (CaDevice) { cStatus::MsgChannelSwitch(this, 0); // only report status if we are actually going to switch the channel if (CaDevice->SetChannel(Channel, false) == scrOk) // calling SetChannel() directly, not SwitchChannel()! - cControl::Launch(new cTransferControl(CaDevice, Channel->vpid, Channel->apid1, 0, 0, 0));//XXX+ + cControl::Launch(new cTransferControl(CaDevice, Channel->Vpid(), Channel->Apid1(), 0, 0, 0));//XXX+ else Result = scrNoTransfer; } @@ -359,10 +371,10 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView) if (Result == scrOk) { if (LiveView && IsPrimaryDevice()) { - cSIProcessor::SetCurrentServiceID(Channel->pnr); - currentChannel = Channel->number; + cSIProcessor::SetCurrentServiceID(Channel->Sid()); + currentChannel = Channel->Number(); } - cStatus::MsgChannelSwitch(this, Channel->number); // only report status if channel switch successfull + cStatus::MsgChannelSwitch(this, Channel->Number()); // only report status if channel switch successfull } return Result; |