From 263dc295089a2accc385c87c23b177314d65acea Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Mon, 13 Jun 2011 14:48:41 +0200 Subject: [PATCH] The initial channel is now stored by the channel ID in the setup.conf file --- CONTRIBUTORS | 2 ++ HISTORY | 5 ++++- MANUAL | 4 ++-- config.c | 7 ++++--- config.h | 4 ++-- menuitems.c | 16 +++++++++++++++- menuitems.h | 5 ++++- vdr.c | 10 +++++++--- 8 files changed, 40 insertions(+), 13 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index adaf862a..77ecaa32 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -1028,6 +1028,8 @@ Marc Rovira Vall , Ramon Roca and Lars Bläser for reporting a bug in EPG bugfix statistics which made log entries for undefined channels + for reporting a problem with the initial channel in case channels are reordered or + deleted Niko Tarnanen for translating OSD texts to the Finnish language diff --git a/HISTORY b/HISTORY index 4af1a59f..e3b932d6 100644 --- a/HISTORY +++ b/HISTORY @@ -6607,7 +6607,7 @@ Video Disk Recorder Revision History - Avoiding an unecessary call to Recordings.ResetResume() (thanks to Reinhard Nissl). -2011-06-12: Version 1.7.19 +2011-06-13: Version 1.7.19 - Fixed cString's operator=(const char *String) in case the given string is the same as the existing one (thanks to Dirk Leber). @@ -6644,3 +6644,6 @@ Video Disk Recorder Revision History that new value is not the default value (thanks to Derek Kelly for reporting a problem with the fps value being overwritten in case a recording was interrupted and resumed, and the fps value could not be determined after resuming recording). +- The initial channel is now stored by the channel ID in the setup.conf file, in + order to avoid problems in case channels are reordered or deleted (reported by + Lars Bläser). diff --git a/MANUAL b/MANUAL index 7fae53bb..352cc10c 100644 --- a/MANUAL +++ b/MANUAL @@ -885,8 +885,8 @@ Version 1.6 key. Note that the total maximum is also limited by the "OSD/Channel info time" parameter. - Initial channel = 0 The number of the channel that shall be tuned to when - VDR starts. Default is 0, which means that it will + Initial channel = The channel ID of the channel that shall be tuned to when + VDR starts. Default is empty, which means that it will tune to the channel that was on before VDR was stopped. Initial volume = -1 The volume that shall be set when VDR starts. Default diff --git a/config.c b/config.c index 73b11b18..6767b5c6 100644 --- a/config.c +++ b/config.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.c 2.13 2010/06/06 10:06:43 kls Exp $ + * $Id: config.c 2.14 2011/06/13 14:41:01 kls Exp $ */ #include "config.h" @@ -395,7 +395,7 @@ cSetup::cSetup(void) CurrentChannel = -1; CurrentVolume = MAXVOLUME; CurrentDolby = 0; - InitialChannel = 0; + // InitialChannel is initialized by constructor InitialVolume = -1; ChannelsWrap = 0; EmergencyExit = 1; @@ -404,6 +404,7 @@ cSetup::cSetup(void) cSetup& cSetup::operator= (const cSetup &s) { memcpy(&__BeginData__, &s.__BeginData__, (char *)&s.__EndData__ - (char *)&s.__BeginData__); + InitialChannel = s.InitialChannel; return *this; } @@ -586,7 +587,7 @@ bool cSetup::Parse(const char *Name, const char *Value) else if (!strcasecmp(Name, "CurrentChannel")) CurrentChannel = atoi(Value); else if (!strcasecmp(Name, "CurrentVolume")) CurrentVolume = atoi(Value); else if (!strcasecmp(Name, "CurrentDolby")) CurrentDolby = atoi(Value); - else if (!strcasecmp(Name, "InitialChannel")) InitialChannel = atoi(Value); + else if (!strcasecmp(Name, "InitialChannel")) InitialChannel = Value; else if (!strcasecmp(Name, "InitialVolume")) InitialVolume = atoi(Value); else if (!strcasecmp(Name, "ChannelsWrap")) ChannelsWrap = atoi(Value); else if (!strcasecmp(Name, "EmergencyExit")) EmergencyExit = atoi(Value); diff --git a/config.h b/config.h index 0d76e939..f3421f7a 100644 --- a/config.h +++ b/config.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: config.h 2.31 2011/05/15 11:46:30 kls Exp $ + * $Id: config.h 2.32 2011/06/13 14:24:40 kls Exp $ */ #ifndef __CONFIG_H @@ -287,11 +287,11 @@ public: int CurrentChannel; int CurrentVolume; int CurrentDolby; - int InitialChannel; int InitialVolume; int ChannelsWrap; int EmergencyExit; int __EndData__; + cString InitialChannel; cSetup(void); cSetup& operator= (const cSetup &s); bool Load(const char *FileName); diff --git a/menuitems.c b/menuitems.c index 3a5a086b..bc04e72c 100644 --- a/menuitems.c +++ b/menuitems.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menuitems.c 2.8 2010/12/12 13:41:09 kls Exp $ + * $Id: menuitems.c 2.9 2011/06/13 14:48:41 kls Exp $ */ #include "menuitems.h" @@ -713,7 +713,19 @@ void cMenuEditStraItem::Set(void) cMenuEditChanItem::cMenuEditChanItem(const char *Name, int *Value, const char *NoneString) :cMenuEditIntItem(Name, Value, NoneString ? 0 : 1, Channels.MaxNumber()) { + channelID = NULL; noneString = NoneString; + dummyValue = 0; + Set(); +} + +cMenuEditChanItem::cMenuEditChanItem(const char *Name, cString *ChannelID, const char *NoneString) +:cMenuEditIntItem(Name, &dummyValue, NoneString ? 0 : 1, Channels.MaxNumber()) +{ + channelID = ChannelID; + noneString = NoneString; + cChannel *channel = Channels.GetByChannelID(tChannelID::FromString(*ChannelID)); + dummyValue = channel ? channel->Number() : 0; Set(); } @@ -744,6 +756,8 @@ eOSState cMenuEditChanItem::ProcessKey(eKeys Key) *value = channel->Number(); else if (delta < 0 && noneString) *value = 0; + if (channelID) + *channelID = channel ? channel->GetChannelID().ToString() : ""; Set(); } break; diff --git a/menuitems.h b/menuitems.h index 6e8f1082..a6f27438 100644 --- a/menuitems.h +++ b/menuitems.h @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: menuitems.h 2.4 2010/06/06 10:32:38 kls Exp $ + * $Id: menuitems.h 2.5 2011/06/13 13:46:03 kls Exp $ */ #ifndef __MENUITEMS_H @@ -133,9 +133,12 @@ public: class cMenuEditChanItem : public cMenuEditIntItem { protected: const char *noneString; + int dummyValue; + cString *channelID; virtual void Set(void); public: cMenuEditChanItem(const char *Name, int *Value, const char *NoneString = NULL); + cMenuEditChanItem(const char *Name, cString *ChannelID, const char *NoneString = NULL); virtual eOSState ProcessKey(eKeys Key); }; diff --git a/vdr.c b/vdr.c index 34560e75..ad86f5a8 100644 --- a/vdr.c +++ b/vdr.c @@ -22,7 +22,7 @@ * * The project's page is at http://www.tvdr.de * - * $Id: vdr.c 2.20 2010/12/12 13:42:00 kls Exp $ + * $Id: vdr.c 2.21 2011/06/13 14:40:12 kls Exp $ */ #include @@ -704,8 +704,12 @@ int main(int argc, char *argv[]) if (!cDevice::WaitForAllDevicesReady(DEVICEREADYTIMEOUT)) dsyslog("not all devices ready after %d seconds", DEVICEREADYTIMEOUT); - if (Setup.InitialChannel > 0) - Setup.CurrentChannel = Setup.InitialChannel; + if (isnumber(Setup.InitialChannel)) { // for compatibility with old setup.conf files + if (cChannel *Channel = Channels.GetByNumber(atoi(Setup.InitialChannel))) + Setup.InitialChannel = Channel->GetChannelID().ToString(); + } + if (cChannel *Channel = Channels.GetByChannelID(tChannelID::FromString(Setup.InitialChannel))) + Setup.CurrentChannel = Channel->Number(); if (Setup.InitialVolume >= 0) Setup.CurrentVolume = Setup.InitialVolume; Channels.SwitchTo(Setup.CurrentChannel);