summaryrefslogtreecommitdiff
path: root/channels.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <vdr@tvdr.de>2005-09-11 13:23:49 +0200
committerKlaus Schmidinger <vdr@tvdr.de>2005-09-11 13:23:49 +0200
commit94d43abecf01f203d9dc476c09717abbc3f34664 (patch)
tree705e5f9a19f2747d1e706526485715c2e57ddca3 /channels.c
parent0c6ba1f9287584b2da1ee80ff8dcd0042f0ded46 (diff)
downloadvdr-1.3.32.tar.gz
vdr-1.3.32.tar.bz2
Implemented a hash for the channels to reduce the system load in the EIT scanning thread1.3.32
Diffstat (limited to 'channels.c')
-rw-r--r--channels.c66
1 files changed, 46 insertions, 20 deletions
diff --git a/channels.c b/channels.c
index 32770d64..3bb42f5d 100644
--- a/channels.c
+++ b/channels.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: channels.c 1.45 2005/09/04 10:49:12 kls Exp $
+ * $Id: channels.c 1.46 2005/09/11 11:17:19 kls Exp $
*/
#include "channels.h"
@@ -342,11 +342,14 @@ void cChannel::SetId(int Nid, int Tid, int Sid, int Rid)
dsyslog("changing id of channel %d from %d-%d-%d-%d to %d-%d-%d-%d", Number(), nid, tid, sid, rid, Nid, Tid, Sid, Rid);
modification |= CHANNELMOD_ID;
Channels.SetModified();
+ Channels.UnhashChannel(this);
}
nid = Nid;
tid = Tid;
sid = Sid;
rid = Rid;
+ if (Number())
+ Channels.HashChannel(this);
}
}
@@ -868,6 +871,16 @@ bool cChannels::Load(const char *FileName, bool AllowComments, bool MustExist)
return false;
}
+void cChannels::HashChannel(cChannel *Channel)
+{
+ channelsHashSid.Add(Channel, Channel->Sid());
+}
+
+void cChannels::UnhashChannel(cChannel *Channel)
+{
+ channelsHashSid.Del(Channel, Channel->Sid());
+}
+
int cChannels::GetNextGroup(int Idx)
{
cChannel *channel = Get(++Idx);
@@ -894,6 +907,7 @@ int cChannels::GetNextNormal(int Idx)
void cChannels::ReNumber( void )
{
+ channelsHashSid.Clear();
int Number = 1;
for (cChannel *channel = First(); channel; channel = Next(channel)) {
if (channel->GroupSep()) {
@@ -901,6 +915,7 @@ void cChannels::ReNumber( void )
Number = channel->Number();
}
else {
+ HashChannel(channel);
maxNumber = Number;
channel->SetNumber(Number++);
}
@@ -924,32 +939,43 @@ cChannel *cChannels::GetByNumber(int Number, int SkipGap)
cChannel *cChannels::GetByServiceID(int Source, int Transponder, unsigned short ServiceID)
{
- for (cChannel *channel = First(); channel; channel = Next(channel)) {
- if (!channel->GroupSep() && channel->Source() == Source && ISTRANSPONDER(channel->Transponder(), Transponder) && channel->Sid() == ServiceID)
- return channel;
- }
+ cList<cHashObject> *list = channelsHashSid.GetList(ServiceID);
+ if (list) {
+ for (cHashObject *hobj = list->First(); hobj; hobj = list->Next(hobj)) {
+ cChannel *channel = (cChannel *)hobj->Object();
+ if (channel->Sid() == ServiceID && channel->Source() == Source && ISTRANSPONDER(channel->Transponder(), Transponder))
+ return channel;
+ }
+ }
return NULL;
}
cChannel *cChannels::GetByChannelID(tChannelID ChannelID, bool TryWithoutRid, bool TryWithoutPolarization)
{
- for (cChannel *channel = First(); channel; channel = Next(channel)) {
- if (!channel->GroupSep() && channel->GetChannelID() == ChannelID)
- return channel;
- }
- if (TryWithoutRid) {
- ChannelID.ClrRid();
- for (cChannel *channel = First(); channel; channel = Next(channel)) {
- if (!channel->GroupSep() && channel->GetChannelID().ClrRid() == ChannelID)
- return channel;
- }
- }
- if (TryWithoutPolarization) {
- ChannelID.ClrPolarization();
- for (cChannel *channel = First(); channel; channel = Next(channel)) {
- if (!channel->GroupSep() && channel->GetChannelID().ClrPolarization() == ChannelID)
+ int sid = ChannelID.Sid();
+ cList<cHashObject> *list = channelsHashSid.GetList(sid);
+ if (list) {
+ for (cHashObject *hobj = list->First(); hobj; hobj = list->Next(hobj)) {
+ cChannel *channel = (cChannel *)hobj->Object();
+ if (channel->Sid() == sid && channel->GetChannelID() == ChannelID)
return channel;
}
+ if (TryWithoutRid) {
+ ChannelID.ClrRid();
+ for (cHashObject *hobj = list->First(); hobj; hobj = list->Next(hobj)) {
+ cChannel *channel = (cChannel *)hobj->Object();
+ if (channel->Sid() == sid && channel->GetChannelID().ClrRid() == ChannelID)
+ return channel;
+ }
+ }
+ if (TryWithoutPolarization) {
+ ChannelID.ClrPolarization();
+ for (cHashObject *hobj = list->First(); hobj; hobj = list->Next(hobj)) {
+ cChannel *channel = (cChannel *)hobj->Object();
+ if (channel->Sid() == sid && channel->GetChannelID().ClrPolarization() == ChannelID)
+ return channel;
+ }
+ }
}
return NULL;
}