1
0
mirror of https://github.com/VDR4Arch/vdr.git synced 2023-10-10 13:36:52 +02:00

Improved channel switching when repeat function kicks in; updating channel display before switching channel; added a missing initialization of 'timeout' in the cDisplayChannel constructor

This commit is contained in:
Klaus Schmidinger 2006-01-22 14:27:53 +01:00
parent ac9f4bb48f
commit 6cd9124d08
4 changed files with 113 additions and 66 deletions

View File

@ -4190,7 +4190,7 @@ Video Disk Recorder Revision History
- No longer displaying color buttons in the recording info menu if it has been - No longer displaying color buttons in the recording info menu if it has been
invoked from a player (reported by Jürgen Schilling). invoked from a player (reported by Jürgen Schilling).
2006-01-21: Version 1.3.40 2006-01-22: Version 1.3.40
- Fixed a second place where a message should be given when an instant recording - Fixed a second place where a message should be given when an instant recording
is started (reported by Jesus Bravo Alvarez). is started (reported by Jesus Bravo Alvarez).
@ -4216,3 +4216,9 @@ Video Disk Recorder Revision History
really need it - it will be completely removed in the next version. If you are really need it - it will be completely removed in the next version. If you are
experiencing problems with a/v running out of sync, try the latest driver and experiencing problems with a/v running out of sync, try the latest driver and
firmware (if you are using a full featured DVB card). firmware (if you are using a full featured DVB card).
- Switching channels with the Up/Down or Channel+/Channel- keys now works a lot
faster when the repeat function kicks in, by not actually switching the
channel every time, but rather only displaying the channel info and doing
the final switch when the key is released.
- The channel display is now updated _before_ the channel is switched.
- Added a missing initialization of 'timeout' in the cDisplayChannel constructor.

147
menu.c
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.c 1.399 2006/01/21 10:02:19 kls Exp $ * $Id: menu.c 1.400 2006/01/22 14:24:02 kls Exp $
*/ */
#include "menu.h" #include "menu.h"
@ -2998,9 +2998,12 @@ static void SetTrackDescriptions(bool Live)
#define DIRECTCHANNELTIMEOUT 1000 //ms #define DIRECTCHANNELTIMEOUT 1000 //ms
cDisplayChannel *cDisplayChannel::currentDisplayChannel = NULL;
cDisplayChannel::cDisplayChannel(int Number, bool Switched) cDisplayChannel::cDisplayChannel(int Number, bool Switched)
:cOsdObject(true) :cOsdObject(true)
{ {
currentDisplayChannel = this;
group = -1; group = -1;
withInfo = !Switched || Setup.ShowInfoOnChSwitch; withInfo = !Switched || Setup.ShowInfoOnChSwitch;
displayChannel = Skins.Current()->DisplayChannel(withInfo); displayChannel = Skins.Current()->DisplayChannel(withInfo);
@ -3013,18 +3016,19 @@ cDisplayChannel::cDisplayChannel(int Number, bool Switched)
DisplayInfo(); DisplayInfo();
displayChannel->Flush(); displayChannel->Flush();
} }
lastTime.Set();
} }
cDisplayChannel::cDisplayChannel(eKeys FirstKey) cDisplayChannel::cDisplayChannel(eKeys FirstKey)
:cOsdObject(true) :cOsdObject(true)
{ {
currentDisplayChannel = this;
group = -1; group = -1;
number = 0; number = 0;
timeout = true;
lastPresent = lastFollowing = NULL; lastPresent = lastFollowing = NULL;
lastTime.Set();
withInfo = Setup.ShowInfoOnChSwitch; withInfo = Setup.ShowInfoOnChSwitch;
displayChannel = Skins.Current()->DisplayChannel(withInfo); displayChannel = Skins.Current()->DisplayChannel(withInfo);
channel = Channels.GetByNumber(cDevice::CurrentChannel());
ProcessKey(FirstKey); ProcessKey(FirstKey);
} }
@ -3032,6 +3036,7 @@ cDisplayChannel::~cDisplayChannel()
{ {
delete displayChannel; delete displayChannel;
cStatus::MsgOsdClear(); cStatus::MsgOsdClear();
currentDisplayChannel = NULL;
} }
void cDisplayChannel::DisplayChannel(void) void cDisplayChannel::DisplayChannel(void)
@ -3065,14 +3070,27 @@ void cDisplayChannel::DisplayInfo(void)
void cDisplayChannel::Refresh(void) void cDisplayChannel::Refresh(void)
{ {
channel = Channels.GetByNumber(cDevice::CurrentChannel());
DisplayChannel(); DisplayChannel();
displayChannel->SetEvents(NULL, NULL); displayChannel->SetEvents(NULL, NULL);
lastTime.Set(); }
cChannel *cDisplayChannel::NextAvailableChannel(cChannel *Channel, int Direction)
{
if (Direction) {
while (Channel) {
Channel = Direction > 0 ? Channels.Next(Channel) : Channels.Prev(Channel);
if (Channel && !Channel->GroupSep() && cDevice::GetDevice(Channel, 0))
return Channel;
}
}
return NULL;
} }
eOSState cDisplayChannel::ProcessKey(eKeys Key) eOSState cDisplayChannel::ProcessKey(eKeys Key)
{ {
cChannel *NewChannel = NULL;
if (Key != kNone)
lastTime.Set();
switch (Key) { switch (Key) {
case k0: case k0:
if (number == 0) { if (number == 0) {
@ -3083,31 +3101,29 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
case k1 ... k9: case k1 ... k9:
if (number >= 0) { if (number >= 0) {
number = number * 10 + Key - k0; number = number * 10 + Key - k0;
if (number > 0) { channel = Channels.GetByNumber(number);
channel = Channels.GetByNumber(number); displayChannel->SetEvents(NULL, NULL);
displayChannel->SetEvents(NULL, NULL); withInfo = false;
withInfo = false; DisplayChannel();
DisplayChannel(); // Lets see if there can be any useful further input:
lastTime.Set(); int n = channel ? number * 10 : 0;
// Lets see if there can be any useful further input: cChannel *ch = channel;
int n = channel ? number * 10 : 0; while (ch && (ch = Channels.Next(ch)) != NULL) {
cChannel *ch = channel; if (!ch->GroupSep()) {
while (ch && (ch = Channels.Next(ch)) != NULL) { if (n <= ch->Number() && ch->Number() <= n + 9) {
if (!ch->GroupSep()) { n = 0;
if (n <= ch->Number() && ch->Number() <= n + 9) { break;
n = 0;
break;
}
if (ch->Number() > n)
n *= 10;
} }
if (ch->Number() > n)
n *= 10;
} }
if (n > 0) {
// This channel is the only one that fits the input, so let's take it right away:
displayChannel->Flush(); // makes sure the user sees his last input
Channels.SwitchTo(number);
return osEnd;
} }
if (n > 0) {
// This channel is the only one that fits the input, so let's take it right away:
displayChannel->Flush(); // makes sure the user sees his last input
NewChannel = channel;
withInfo = true;
number = 0;
} }
} }
break; break;
@ -3138,18 +3154,27 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
group = -1; group = -1;
} }
} }
lastTime.Set();
break; break;
case kUp|k_Repeat: case kUp|k_Repeat:
case kUp: case kUp:
case kDown|k_Repeat: case kDown|k_Repeat:
case kDown: case kDown:
cDevice::SwitchChannel(NORMALKEY(Key) == kUp ? 1 : -1);
// no break here
case kChanUp|k_Repeat: case kChanUp|k_Repeat:
case kChanUp: case kChanUp:
case kChanDn|k_Repeat: case kChanDn|k_Repeat:
case kChanDn: case kChanDn: {
eKeys k = NORMALKEY(Key);
cChannel *ch = NextAvailableChannel(channel, (k == kUp || k == kChanUp) ? 1 : -1);
if (ch)
channel = ch;
}
// no break here
case kUp|k_Release:
case kDown|k_Release:
case kChanUp|k_Release:
case kChanDn|k_Release:
if (!(Key & k_Repeat) && channel)
NewChannel = channel;
withInfo = true; withInfo = true;
group = -1; group = -1;
number = 0; number = 0;
@ -3157,43 +3182,51 @@ eOSState cDisplayChannel::ProcessKey(eKeys Key)
break; break;
case kNone: case kNone:
if (number && lastTime.Elapsed() > DIRECTCHANNELTIMEOUT) { if (number && lastTime.Elapsed() > DIRECTCHANNELTIMEOUT) {
if (Channels.GetByNumber(number)) channel = Channels.GetByNumber(number);
Channels.SwitchTo(number); if (channel)
else { NewChannel = channel;
number = 0; withInfo = true;
channel = NULL; number = 0;
DisplayChannel(); Refresh();
lastTime.Set(); lastTime.Set();
return osContinue;
}
return osEnd;
} }
break; break;
//TODO //TODO
//XXX case kGreen: return osEventNow; //XXX case kGreen: return osEventNow;
//XXX case kYellow: return osEventNext; //XXX case kYellow: return osEventNext;
case kOk: if (group >= 0) { case kOk:
channel = Channels.Get(Channels.GetNextNormal(group)); if (group >= 0) {
if (channel) channel = Channels.Get(Channels.GetNextNormal(group));
Channels.SwitchTo(channel->Number()); if (channel)
withInfo = true; NewChannel = channel;
group = -1; withInfo = true;
Refresh(); group = -1;
break; Refresh();
} }
else if (number > 0 && channel) else if (number > 0) {
Channels.SwitchTo(number); channel = Channels.GetByNumber(number);
return osEnd; if (channel)
default: if ((Key & (k_Repeat | k_Release)) == 0) { NewChannel = channel;
cRemote::Put(Key); withInfo = true;
return osEnd; number = 0;
} Refresh();
}
else
return osEnd;
break;
default:
if ((Key & (k_Repeat | k_Release)) == 0) {
cRemote::Put(Key);
return osEnd;
}
}; };
if (!timeout || lastTime.Elapsed() < (uint64)(Setup.ChannelInfoTime * 1000)) { if (!timeout || lastTime.Elapsed() < (uint64)(Setup.ChannelInfoTime * 1000)) {
if (!number && group < 0 && channel && channel->Number() != cDevice::CurrentChannel()) if (!number && group < 0 && channel && channel->Number() != cDevice::CurrentChannel())
Refresh(); // makes sure a channel switch through the SVDRP CHAN command is displayed Refresh(); // makes sure a channel switch through the SVDRP CHAN command is displayed
DisplayInfo(); DisplayInfo();
displayChannel->Flush(); displayChannel->Flush();
if (NewChannel)
Channels.SwitchTo(NewChannel->Number());
return osContinue; return osContinue;
} }
return osEnd; return osEnd;

5
menu.h
View File

@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and * See the main source file 'vdr.c' for copyright information and
* how to reach the author. * how to reach the author.
* *
* $Id: menu.h 1.81 2006/01/06 11:30:38 kls Exp $ * $Id: menu.h 1.82 2006/01/22 14:24:31 kls Exp $
*/ */
#ifndef __MENU_H #ifndef __MENU_H
@ -82,14 +82,17 @@ private:
cChannel *channel; cChannel *channel;
const cEvent *lastPresent; const cEvent *lastPresent;
const cEvent *lastFollowing; const cEvent *lastFollowing;
static cDisplayChannel *currentDisplayChannel;
void DisplayChannel(void); void DisplayChannel(void);
void DisplayInfo(void); void DisplayInfo(void);
void Refresh(void); void Refresh(void);
cChannel *NextAvailableChannel(cChannel *Channel, int Direction);
public: public:
cDisplayChannel(int Number, bool Switched); cDisplayChannel(int Number, bool Switched);
cDisplayChannel(eKeys FirstKey); cDisplayChannel(eKeys FirstKey);
virtual ~cDisplayChannel(); virtual ~cDisplayChannel();
virtual eOSState ProcessKey(eKeys Key); virtual eOSState ProcessKey(eKeys Key);
static bool IsOpen(void) { return currentDisplayChannel != NULL; }
}; };
class cDisplayVolume : public cOsdObject { class cDisplayVolume : public cOsdObject {

19
vdr.c
View File

@ -22,7 +22,7 @@
* *
* The project's page is at http://www.cadsoft.de/vdr * The project's page is at http://www.cadsoft.de/vdr
* *
* $Id: vdr.c 1.242 2006/01/20 16:12:39 kls Exp $ * $Id: vdr.c 1.243 2006/01/22 13:32:41 kls Exp $
*/ */
#include <getopt.h> #include <getopt.h>
@ -822,6 +822,7 @@ int main(int argc, char *argv[])
} }
} }
break; break;
// Direct main menu functions:
#define DirectMainFunction(function)\ #define DirectMainFunction(function)\
DELETE_MENU;\ DELETE_MENU;\
if (cControl::Control())\ if (cControl::Control())\
@ -855,7 +856,15 @@ int main(int argc, char *argv[])
case kChanUp: case kChanUp:
case kChanDn|k_Repeat: case kChanDn|k_Repeat:
case kChanDn: case kChanDn:
cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1); if (!Interact)
Menu = new cDisplayChannel(NORMALKEY(key));
else if (cDisplayChannel::IsOpen()) {
Interact->ProcessKey(key);
continue;
}
else
cDevice::SwitchChannel(NORMALKEY(key) == kChanUp ? 1 : -1);
key = kNone; // nobody else needs to see these keys
break; break;
// Volume control: // Volume control:
case kVolUp|k_Repeat: case kVolUp|k_Repeat:
@ -995,21 +1004,17 @@ int main(int argc, char *argv[])
} }
// Direct Channel Select: // Direct Channel Select:
case k1 ... k9: case k1 ... k9:
Menu = new cDisplayChannel(key);
break;
// Left/Right rotates trough channel groups: // Left/Right rotates trough channel groups:
case kLeft|k_Repeat: case kLeft|k_Repeat:
case kLeft: case kLeft:
case kRight|k_Repeat: case kRight|k_Repeat:
case kRight: case kRight:
Menu = new cDisplayChannel(NORMALKEY(key));
break;
// Up/Down Channel Select: // Up/Down Channel Select:
case kUp|k_Repeat: case kUp|k_Repeat:
case kUp: case kUp:
case kDown|k_Repeat: case kDown|k_Repeat:
case kDown: case kDown:
cDevice::SwitchChannel(NORMALKEY(key) == kUp ? 1 : -1); Menu = new cDisplayChannel(NORMALKEY(key));
break; break;
// Viewing Control: // Viewing Control:
case kOk: LastChannel = -1; break; // forces channel display case kOk: LastChannel = -1; break; // forces channel display