summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2002-09-08 11:46:53 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2002-09-08 11:46:53 +0200
commit1b396902e488e093234ac181bbc0e514dd098942 (patch)
treecbd726e2b26c8280ac4ae4bdbae58c0b05ebae27 /device.c
parentf47655ef0f1836be0d92a7fa57e3c300922a81ee (diff)
downloadvdr-1b396902e488e093234ac181bbc0e514dd098942.tar.gz
vdr-1b396902e488e093234ac181bbc0e514dd098942.tar.bz2
Skipping unavailable channels when switching with 'Up' and 'Down' keys
Diffstat (limited to 'device.c')
-rw-r--r--device.c39
1 files changed, 31 insertions, 8 deletions
diff --git a/device.c b/device.c
index d7db99b3..ab1067d0 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 1.17 2002/09/08 09:36:16 kls Exp $
+ * $Id: device.c 1.18 2002/09/08 11:46:53 kls Exp $
*/
#include "device.h"
@@ -30,6 +30,7 @@
int cDevice::numDevices = 0;
int cDevice::useDevice = 0;
int cDevice::nextCardIndex = 0;
+int cDevice::currentChannel = 0;
cDevice *cDevice::device[MAXDEVICES] = { NULL };
cDevice *cDevice::primaryDevice = NULL;
@@ -41,8 +42,6 @@ cDevice::cDevice(void)
active = false;
- currentChannel = 0;
-
mute = false;
volume = Setup.CurrentVolume;
@@ -285,6 +284,32 @@ bool cDevice::SwitchChannel(const cChannel *Channel, bool LiveView)
return false;
}
+bool cDevice::SwitchChannel(int Direction)
+{
+ bool result = false;
+ Direction = sgn(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));
+ }
+ return result;
+}
+
eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
{
cStatus::MsgChannelSwitch(this, 0);
@@ -292,10 +317,6 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
if (LiveView)
StopReplay();
- // Must set this anyway to avoid getting stuck when switching through
- // channels with 'Up' and 'Down' keys:
- currentChannel = Channel->number;
-
// If this card can't receive this channel, we must not actually switch
// the channel here, because that would irritate the driver when we
// start replaying in Transfer Mode immediately after switching the channel:
@@ -320,8 +341,10 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
else if (!SetChannelDevice(Channel, LiveView))
Result = scrFailed;
- if (IsPrimaryDevice())
+ if (Result == scrOk && LiveView && IsPrimaryDevice()) {
cSIProcessor::SetCurrentServiceID(Channel->pnr);
+ currentChannel = Channel->number;
+ }
cStatus::MsgChannelSwitch(this, Channel->number);