diff options
| author | Martin Schirrmacher <vdr.neutrinoepg@schirrmacher.eu> | 2013-04-17 07:55:44 +0200 |
|---|---|---|
| committer | Martin Schirrmacher <vdr.neutrinoepg@schirrmacher.eu> | 2013-04-17 07:55:44 +0200 |
| commit | 6b786dcad09fec3a8f9d3a6b52fe4ddf13f93658 (patch) | |
| tree | 170b4cade6dd4fe877d6c4ed1b925ff499e235cb | |
| parent | 82cd0612fb95fe8b5ca26903b81b652cc4bffc19 (diff) | |
| download | vdr-plugin-neutrinoepg-6b786dcad09fec3a8f9d3a6b52fe4ddf13f93658.tar.gz vdr-plugin-neutrinoepg-6b786dcad09fec3a8f9d3a6b52fe4ddf13f93658.tar.bz2 | |
extremly faster load of plugin, especially at large channels.conf with many groups
| -rw-r--r-- | HISTORY | 4 | ||||
| -rw-r--r-- | neutrinoepg.c | 43 | ||||
| -rw-r--r-- | osditem.c | 2 | ||||
| -rw-r--r-- | osdmenu.c | 135 | ||||
| -rw-r--r-- | osdmenu.h | 9 |
5 files changed, 117 insertions, 76 deletions
@@ -1,5 +1,9 @@ VDR Plugin 'neutrinoepg' Revision History +2013-XX-XX: Version 0.3.4 +- [Fix] Bufferoverflow bei Tastendruck 0 +- [Feature] Beschleunigter Start des Plugin, besonders bei großen channels.conf mit vielen Gruppen + 2013-04-12: Version 0.3.3 - [Fix] komplette Neuimplementierung der Kanal- und Gruppenbehandlung innerhalb des Plugins. weniger Speicherverbrauch, schneller, keine SegFaults mehr! diff --git a/neutrinoepg.c b/neutrinoepg.c index 74237c8..19b96fd 100644 --- a/neutrinoepg.c +++ b/neutrinoepg.c @@ -99,31 +99,11 @@ bool cPluginNeutrinoEpg::Start(void) { Icons::InitCharSet(); - // Count the groups and channels - int GroupCount = 0; - for(cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) - { - if( Channel->GroupSep() ) - GroupCount++; - } - MaxGroup = GroupCount; - - if( !Channels.First()->GroupSep() ) - MaxGroup++; - - // store max group count and add a little reserve - CurrentGroupChannel = new int[MaxGroup+10]; - FirstGroupChannel = new int[MaxGroup+10]; - LastGroupChannel = new int[MaxGroup+10]; - - // initialize CurrentGroupChannel - // to store the current channel by the groups globaly - for( int i = 0; i < MaxGroup; i++) - { - CurrentGroupChannel[i] = -1; - FirstGroupChannel[i] = -1; - LastGroupChannel[i] = -1; - } + GroupIndex = NULL; + CurrentGroupChannel = NULL; + FirstGroupChannel = NULL; + LastGroupChannel = NULL; + ReloadFilters = true; return true; @@ -131,9 +111,14 @@ bool cPluginNeutrinoEpg::Start(void) void cPluginNeutrinoEpg::Stop(void) { - delete[] CurrentGroupChannel; - delete[] FirstGroupChannel; - delete[] LastGroupChannel; + if( GroupIndex != NULL ) + delete[] GroupIndex; + if( CurrentGroupChannel != NULL ) + delete[] CurrentGroupChannel; + if( FirstGroupChannel != NULL ) + delete[] FirstGroupChannel; + if( LastGroupChannel != NULL ) + delete[] LastGroupChannel; } void cPluginNeutrinoEpg::Housekeeping(void) @@ -142,6 +127,8 @@ void cPluginNeutrinoEpg::Housekeeping(void) cOsdObject *cPluginNeutrinoEpg::MainMenuAction(void) { + syslog(LOG_ERR, "neutrinoepg MainMenuAction"); + return new myOsdMenu; } @@ -53,7 +53,7 @@ void myOsdItem::Set() const char *m = " "; // look for timers - for(cTimer *ti = Timers.First();ti;ti = Timers.Next(ti)) + for(cTimer *ti = Timers.First(); ti; ti = Timers.Next(ti)) { if(ti->Matches(t) && (ti->Channel() == channel)) { @@ -2,9 +2,11 @@ #include "osditem.h" #include "menuevent.h" +#include <time.h> + time_t t; -int MaxGroup; +int *GroupIndex; int *CurrentGroupChannel; int *FirstGroupChannel; int *LastGroupChannel; @@ -13,10 +15,19 @@ int ChannelsShown; int ChannelsBefore; int ChannelsAfter; +double diffclock(clock_t clock1,clock_t clock2) +{ + double diffticks = clock1 - clock2; + double diffs = diffticks / CLOCKS_PER_SEC; + return diffs; +} + myOsdMenu::myOsdMenu() : cOsdMenu("") { jumpto = false; + syslog(LOG_ERR, "neutrinoepg OsdMenu Init"); + if( Setup.UseSmallFont == 2 ) { if(showchannelnumbers) @@ -53,7 +64,8 @@ myOsdMenu::myOsdMenu() : cOsdMenu("") cOsdItem *tItem = Get(Current()); ChannelsShown = atoi((const char *)tItem->Text()); Clear(); - + //ChannelsShown = Skins.Current()->DisplayMenu()->MaxItems(); + // how many items are before and after the middle item if( (ChannelsShown % 2) != 0 ) { @@ -66,15 +78,83 @@ myOsdMenu::myOsdMenu() : cOsdMenu("") ChannelsAfter = (ChannelsShown / 2)-1; } - if( ReloadFilters ) + int chan_edited = Channels.BeingEdited(); + syslog(LOG_ERR, "neutrinoepg chan_edited: %d", chan_edited); + + if( ReloadFilters || chan_edited ) { + clock_t begin = clock(); + clock_t end = clock(); ReloadFilters = false; + + // Count the groups and channels + int GroupCount = 0; + for(cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel)) + { + if( Channel->GroupSep() ) + GroupCount++; + } + MaxGroup = GroupCount; + + if( !Channels.First()->GroupSep() ) + MaxGroup++; + + if( GroupIndex != NULL ) + delete[] GroupIndex; + if( CurrentGroupChannel != NULL ) + delete[] CurrentGroupChannel; + if( FirstGroupChannel != NULL ) + delete[] FirstGroupChannel; + if( LastGroupChannel != NULL ) + delete[] LastGroupChannel; + + // store max group count and add a little reserve + GroupIndex = new int[MaxGroup+1]; + CurrentGroupChannel = new int[MaxGroup+1]; + FirstGroupChannel = new int[MaxGroup+1]; + LastGroupChannel = new int[MaxGroup+1]; + for( int i = 0; i < MaxGroup; i++) { CurrentGroupChannel[i] = -1; FirstGroupChannel[i] = -1; LastGroupChannel[i] = -1; } + + int index = 0; + if( FirstChannelsHasGroup() == false ) + { + GroupIndex[0] = -1; + index = 1; + } + for( cChannel *Channel = Channels.First(); Channel; Channel = Channels.Next(Channel) ) + { + if( Channel->GroupSep() ) + { + GroupIndex[index] = Channel->Index(); + index++; + } + } + + end = clock(); + for( int Group = 0; Group < MaxGroup; Group++) + { + if( CurrentGroupChannel[Group] == -1 ) + { + CurrentGroupChannel[Group] = GetFirstChannelOfGroup(Group); + } + if( FirstGroupChannel[Group] == -1 ) + { + FirstGroupChannel[Group] = GetFirstChannelOfGroup(Group); + } + if( LastGroupChannel[Group] == -1 ) + { + LastGroupChannel[Group] = GetLastChannelOfGroup(Group); + } + end = clock(); + } + end = clock(); + syslog(LOG_ERR, "neutrinoepg time last for get channels: %.3f s", diffclock(end, begin)); } // what is the current watching channel? @@ -92,22 +172,6 @@ myOsdMenu::myOsdMenu() : cOsdMenu("") //syslog(LOG_ERR, "neutrinoepg: Group %d Channel %d", CurrentGroup, CurrentGroupChannel[CurrentGroup]); - for( int Group = 0; Group < MaxGroup; Group++) - { - if( CurrentGroupChannel[Group] == -1 ) - { - CurrentGroupChannel[Group] = GetFirstChannelOfGroup(Group); - } - if( FirstGroupChannel[Group] == -1 ) - { - FirstGroupChannel[Group] = GetFirstChannelOfGroup(Group); - } - if( LastGroupChannel[Group] == -1 ) - { - LastGroupChannel[Group] = GetLastChannelOfGroup(Group); - } - } - LoadSchedules(0); } @@ -117,35 +181,22 @@ myOsdMenu::~myOsdMenu() int myOsdMenu::GetGroupIndex(int Group) { - if( Group < 0 ) - return -1; - - if( FirstChannelsHasGroup() == false && Group == 0) + if( Group < 0 || Group > MaxGroup) return -1; - if( FirstChannelsHasGroup() == false ) - Group--; - - int GroupIndex = -1; - GroupIndex = GetFirstGroupIndex(); - while( Group-- ) - GroupIndex = Channels.GetNextGroup(GroupIndex); - - return GroupIndex; + return GroupIndex[Group]; } -int myOsdMenu::GetGroupByGroupIndex(int GroupIndex) +int myOsdMenu::GetGroupByGroupIndex(int groupIndex) { - if( ChannelsHasGroup() == false || GroupIndex == -1 ) + if( ChannelsHasGroup() == false || groupIndex == -1 ) return 0; - int GroupIndexSearch = GetFirstGroupIndex(); - - int Group = 0; - for(; GroupIndexSearch != GroupIndex && GroupIndexSearch != -1; Group++) - GroupIndexSearch = Channels.GetNextGroup(GroupIndexSearch); - if( FirstChannelsHasGroup() == false ) - return Group+1; - return Group; + for(int index = 0; index < MaxGroup; index++) + { + if( GroupIndex[index] == groupIndex ) + return index; + } + return -1; } int myOsdMenu::GetGroupFromChannel(int ChanIndex) { @@ -5,7 +5,7 @@ #include "neutrinoepg.h" extern time_t t; -extern int MaxGroup; +extern int *GroupIndex; extern int *CurrentGroupChannel; extern int *FirstGroupChannel; extern int *LastGroupChannel; @@ -16,9 +16,8 @@ class myOsdMenu : public cOsdMenu private: bool next, jumpto; char tmp[64]; - - int GroupCount; - int ChannelCount; + + int MaxGroup; int ChannelsShown; int ChannelsBefore; @@ -34,7 +33,7 @@ class myOsdMenu : public cOsdMenu void JumpTo(int hh,int mm); void SetMyTitle(void); eOSState Switch(); - int Tab(){if(Setup.UseSmallFont==2)return 5;else return 6;} + int Tab(){ return Setup.UseSmallFont == 2 ? 5 : 6; } int GetGroupIndex(int Group); int GetGroupByGroupIndex(int GroupIndex); |
