]> git.pld-linux.org Git - packages/mythtv.git/blob - myth_eit-ratelimit_r10247.diff
- partial cleanup
[packages/mythtv.git] / myth_eit-ratelimit_r10247.diff
1 Index: libs/libmythtv/eithelper.h
2 ===================================================================
3 --- libs/libmythtv/eithelper.h.orig     2006-06-20 17:31:09.000000000 -0400
4 +++ libs/libmythtv/eithelper.h  2006-06-20 17:36:06.000000000 -0400
5 @@ -20,7 +20,10 @@
6  {
7      Q_OBJECT
8    public:
9 -    EITHelper() : QObject(NULL, "EITHelper") { ; }
10 +    EITHelper() : QObject(NULL, "EITHelper") 
11 +    { 
12 +        events_full = false; 
13 +    }
14  
15      void ClearList(void);
16      uint GetListSize(void) const;
17 @@ -28,6 +31,8 @@
18  
19    public slots:
20      void HandleEITs(QMap_Events* events);
21 +  signals:
22 +    void StopParsing(bool);
23  
24    private:
25      int GetChanID(int tid_db, const Event &event) const;
26 @@ -39,6 +44,12 @@
27  
28      /// Maximum number of DB inserts per ProcessEvents call.
29      static const uint kChunkSize;
30 +
31 +    // Max event list size before we stop parsing incoming events
32 +    // allowing us to try and catchup.
33 +    static const uint kMAXChunkSize;
34 +
35 +    bool events_full;
36  };
37  
38  #endif // USING_DVB
39 Index: libs/libmythtv/siparser.cpp
40 ===================================================================
41 --- libs/libmythtv/siparser.cpp.orig    2006-06-20 17:36:06.000000000 -0400
42 +++ libs/libmythtv/siparser.cpp 2006-06-20 17:37:04.000000000 -0400
43 @@ -64,6 +64,8 @@
44      ParserInReset(false),           standardChange(false),
45      PrivateTypesLoaded(false)
46  {
47 +    events_full = false;
48 +
49      /* Set the PrivateTypes to default values */
50      PrivateTypes.reset();
51  
52 @@ -571,6 +573,12 @@
53      (void) pid;
54  #endif
55  
56 +    if (events_full)
57 +    {
58 +        pmap_lock.unlock();
59 +        return;
60 +    }
61 +
62      if (!(buffer[1] & 0x80))
63      {
64          VERBOSE(VB_SIPARSER, LOC + 
65 Index: libs/libmythtv/eithelper.cpp
66 ===================================================================
67 --- libs/libmythtv/eithelper.cpp.orig   2006-06-20 17:31:09.000000000 -0400
68 +++ libs/libmythtv/eithelper.cpp        2006-06-20 17:36:06.000000000 -0400
69 @@ -4,7 +4,11 @@
70  #include "eithelper.h"
71  #include "mythdbcon.h"
72  
73 -const uint EITHelper::kChunkSize = 20;
74 +
75 +// TODO: Should these be configurable values based on how much ram a 
76 +// backend has available?
77 +const uint EITHelper::kChunkSize = 50;
78 +const uint EITHelper::kMAXChunkSize = 1000;
79  
80  static int get_chan_id_from_db(int tid_db, const Event&);
81  static uint update_eit_in_db(MSqlQuery&, MSqlQuery&, int, const Event&);
82 @@ -75,35 +79,45 @@
83      if (!eitList.size())
84          return 0;
85  
86 +    //VERBOSE(VB_EIT,QString("EITHelper::ProcessEvents: Events: %1/%2")
87 +    //        .arg(eitList.size()).arg(eitList.front()->size()));
88 +
89      uint insertCount = 0;
90 -    if (eitList.front()->size() <= kChunkSize)
91 +
92 +    QList_Events  subset;
93 +    while (subset.size() < kChunkSize && eitList.size())
94      {
95          QList_Events *events = eitList.front();
96 -        eitList.pop_front();
97 -
98 -        eitList_lock.unlock();
99 -        insertCount += UpdateEITList(mplexid, *events);
100 -        QList_Events::iterator it = events->begin();
101 -        for (; it != events->end(); ++it)
102 -            delete *it;
103 -        delete events;
104 -        eitList_lock.lock();
105 +        while (subset.size() < kChunkSize && events->size())
106 +        {
107 +            subset.push_back(events->front());
108 +            events->pop_front();
109 +        }
110 +        if (! events->size())
111 +        {
112 +            eitList.pop_front();
113 +            delete events;
114 +        }
115      }
116 -    else
117 +
118 +    eitList_lock.unlock();
119 +    insertCount += UpdateEITList(mplexid, subset);
120 +    QList_Events::iterator it = subset.begin();
121 +    for (; it != subset.end(); ++it)
122 +        delete *it;
123 +    eitList_lock.lock();
124 +
125 +    if (((eitList.size() <= kChunkSize) && events_full) 
126 +          || ((eitList.size() > kMAXChunkSize) && !events_full))
127      {
128 -        QList_Events *events = eitList.front();
129 -        QList_Events  subset;
130 +        int size = eitList.size();
131 +        VERBOSE(VB_GENERAL, QString ("EITHelper: ToggleParsing EIT (%1)")
132 +                                      .arg(size));
133 +
134 +        events_full = (size > kMAXChunkSize);
135  
136 -        QList_Events::iterator subset_end = events->begin();
137 -        for (uint i = 0; i < kChunkSize; ++i) ++subset_end;
138 -        subset.insert(subset.end(), events->begin(), subset_end);
139 -        events->erase(events->begin(), subset_end);
140 -        
141          eitList_lock.unlock();
142 -        insertCount += UpdateEITList(mplexid, subset);
143 -        QList_Events::iterator it = subset.begin();
144 -        for (; it != subset.end(); ++it)
145 -            delete *it;
146 +        emit(StopParsing(events_full));
147          eitList_lock.lock();
148      }
149  
150 Index: libs/libmythtv/eitscanner.cpp
151 ===================================================================
152 --- libs/libmythtv/eitscanner.cpp.orig  2006-06-20 17:31:09.000000000 -0400
153 +++ libs/libmythtv/eitscanner.cpp       2006-06-20 17:36:06.000000000 -0400
154 @@ -176,6 +176,8 @@
155              eitHelper, SLOT(HandleEITs(QMap_Events*)));
156      connect(channel,   SIGNAL(UpdatePMTObject(const PMTObject *)),
157              this,      SLOT(SetPMTObject(const PMTObject *)));
158 +    connect(eitHelper, SIGNAL(StopParsing(bool)),
159 +            parser,    SLOT(StopParsing(bool)));
160  }
161  
162  /** \fn EITScanner::StopPassiveScan(void)
163 Index: libs/libmythtv/siparser.h
164 ===================================================================
165 --- libs/libmythtv/siparser.h.orig      2006-06-20 17:36:06.000000000 -0400
166 +++ libs/libmythtv/siparser.h   2006-06-20 17:37:04.000000000 -0400
167 @@ -116,6 +116,8 @@
168  
169    public slots:
170      virtual void deleteLater(void);
171 +    void StopParsing(bool stop)
172 +         { pmap_lock.lock(); events_full = stop; pmap_lock.unlock(); }
173  
174    signals:
175      void FindTransportsComplete(void);
176 @@ -240,6 +242,9 @@
177      QDateTime ServiceSearchEndTime;
178      QDateTime EventSearchEndTime;
179  
180 +    // Rate Limit
181 +    bool events_full;
182 +
183      // Common Variables
184      int                 SIStandard;
185      uint                CurrentTransport;
This page took 0.145998 seconds and 3 git commands to generate.