1 | commit 5d472faa338d58cebc66ec971bacfd49474ab03e |
---|
2 | Merge: 79c6f27 69cd78b |
---|
3 | Author: Roger James <roger@beardandsandals.co.uk> |
---|
4 | Date: Sun Apr 14 11:00:29 2013 +0100 |
---|
5 | |
---|
6 | Merge branch 'fixes/0.26' of https://github.com/MythTV/mythtv into fixes/0.26 |
---|
7 | |
---|
8 | commit 79c6f2721fc0e41ded3106f0f843dc283c2927c9 |
---|
9 | Author: Roger James <roger@beardandsandals.co.uk> |
---|
10 | Date: Sun Apr 14 10:56:17 2013 +0100 |
---|
11 | |
---|
12 | Fixes to EIT handling |
---|
13 | |
---|
14 | diff --git a/mythtv/libs/libmythtv/eitcache.cpp b/mythtv/libs/libmythtv/eitcache.cpp |
---|
15 | index d42dacd..69e7b77 100644 |
---|
16 | --- a/mythtv/libs/libmythtv/eitcache.cpp |
---|
17 | +++ b/mythtv/libs/libmythtv/eitcache.cpp |
---|
18 | @@ -12,11 +12,18 @@ |
---|
19 | #include "mythdb.h" |
---|
20 | #include "mythlogging.h" |
---|
21 | #include "mythdate.h" |
---|
22 | +#include "mpegtables.h" |
---|
23 | |
---|
24 | #define LOC QString("EITCache: ") |
---|
25 | |
---|
26 | // Highest version number. version is 5bits |
---|
27 | -const uint EITCache::kVersionMax = 31; |
---|
28 | +const uchar EITCache::kVersionMax = 31; |
---|
29 | +const uchar EITCache::kVersionInvalid = 32; |
---|
30 | +const uint EITCache::kTimeInvalid = 0; |
---|
31 | +const uchar EITCache::kTableidInvalid = 0; |
---|
32 | + |
---|
33 | +event_map_entry::event_map_entry() |
---|
34 | + : tableid(EITCache::kTableidInvalid), version(EITCache::kTimeInvalid), starttime(EITCache::kTimeInvalid), endtime(EITCache::kTimeInvalid), modified(false) {} |
---|
35 | |
---|
36 | EITCache::EITCache() |
---|
37 | : accessCnt(0), hitCnt(0), tblChgCnt(0), verChgCnt(0), |
---|
38 | @@ -57,34 +64,7 @@ QString EITCache::GetStatistics(void) const |
---|
39 | .arg((hitCnt+prunedHitCnt+wrongChannelHitCnt)/(double)accessCnt); |
---|
40 | } |
---|
41 | |
---|
42 | -static inline uint64_t construct_sig(uint tableid, uint version, |
---|
43 | - uint endtime, bool modified) |
---|
44 | -{ |
---|
45 | - return (((uint64_t) modified << 63) | ((uint64_t) tableid << 40) | |
---|
46 | - ((uint64_t) version << 32) | ((uint64_t) endtime)); |
---|
47 | -} |
---|
48 | - |
---|
49 | -static inline uint extract_table_id(uint64_t sig) |
---|
50 | -{ |
---|
51 | - return (sig >> 40) & 0xff; |
---|
52 | -} |
---|
53 | - |
---|
54 | -static inline uint extract_version(uint64_t sig) |
---|
55 | -{ |
---|
56 | - return (sig >> 32) & 0x1f; |
---|
57 | -} |
---|
58 | - |
---|
59 | -static inline uint extract_endtime(uint64_t sig) |
---|
60 | -{ |
---|
61 | - return sig & 0xffffffff; |
---|
62 | -} |
---|
63 | - |
---|
64 | -static inline bool modified(uint64_t sig) |
---|
65 | -{ |
---|
66 | - return sig >> 63; |
---|
67 | -} |
---|
68 | - |
---|
69 | -static void replace_in_db(int chanid, uint eventid, uint64_t sig) |
---|
70 | +static void replace_in_db(int chanid, uint eventid, event_map_entry_t entry) |
---|
71 | { |
---|
72 | |
---|
73 | MSqlQuery query(MSqlQuery::InitCon()); |
---|
74 | @@ -97,9 +77,9 @@ static void replace_in_db(int chanid, uint eventid, uint64_t sig) |
---|
75 | query.prepare(qstr); |
---|
76 | query.bindValue(":CHANID", chanid); |
---|
77 | query.bindValue(":EVENTID", eventid); |
---|
78 | - query.bindValue(":TABLEID", extract_table_id(sig)); |
---|
79 | - query.bindValue(":VERSION", extract_version(sig)); |
---|
80 | - query.bindValue(":ENDTIME", extract_endtime(sig)); |
---|
81 | + query.bindValue(":TABLEID", entry.tableid); |
---|
82 | + query.bindValue(":VERSION", entry.version); |
---|
83 | + query.bindValue(":ENDTIME", entry.endtime); |
---|
84 | |
---|
85 | if (!query.exec()) |
---|
86 | MythDB::DBError("Error updating eitcache", query); |
---|
87 | @@ -248,10 +228,12 @@ event_map_t * EITCache::LoadChannel(uint chanid) |
---|
88 | { |
---|
89 | uint eventid = query.value(0).toUInt(); |
---|
90 | uint tableid = query.value(1).toUInt(); |
---|
91 | - uint version = query.value(2).toUInt(); |
---|
92 | + uint version = kVersionInvalid; // Ignore stored version because the version has probably wrapped |
---|
93 | + // by the time we read this! |
---|
94 | uint endtime = query.value(3).toUInt(); |
---|
95 | |
---|
96 | - (*eventMap)[eventid] = construct_sig(tableid, version, endtime, false); |
---|
97 | + event_map_entry_t entry(tableid, version, kTimeInvalid, endtime, false); |
---|
98 | + (*eventMap)[eventid] = entry; |
---|
99 | } |
---|
100 | |
---|
101 | if (eventMap->size()) |
---|
102 | @@ -278,11 +260,11 @@ void EITCache::WriteChannelToDB(uint chanid) |
---|
103 | event_map_t::iterator it = eventMap->begin(); |
---|
104 | while (it != eventMap->end()) |
---|
105 | { |
---|
106 | - if (modified(*it) && extract_endtime(*it) > lastPruneTime) |
---|
107 | + if ((*it).modified && ((*it).endtime > lastPruneTime)) |
---|
108 | { |
---|
109 | replace_in_db(chanid, it.key(), *it); |
---|
110 | updated++; |
---|
111 | - *it &= ~(uint64_t)0 >> 1; // mark as synced |
---|
112 | + (*it).modified = false; // mark as synced |
---|
113 | } |
---|
114 | ++it; |
---|
115 | } |
---|
116 | @@ -309,10 +291,12 @@ void EITCache::WriteToDB(void) |
---|
117 | |
---|
118 | |
---|
119 | bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version, |
---|
120 | - uint eventid, uint endtime) |
---|
121 | + uint eventid, uint starttime, uint endtime, bool &bEventMayCauseReschedule) |
---|
122 | { |
---|
123 | accessCnt++; |
---|
124 | |
---|
125 | + bEventMayCauseReschedule = false; |
---|
126 | + |
---|
127 | if (accessCnt % 500000 == 50000) |
---|
128 | { |
---|
129 | LOG(VB_EIT, LOG_INFO, GetStatistics()); |
---|
130 | @@ -343,30 +327,117 @@ bool EITCache::IsNewEIT(uint chanid, uint tableid, uint version, |
---|
131 | |
---|
132 | event_map_t * eventMap = channelMap[chanid]; |
---|
133 | event_map_t::iterator it = eventMap->find(eventid); |
---|
134 | + bool bEntryUpdated = false; |
---|
135 | + |
---|
136 | if (it != eventMap->end()) |
---|
137 | { |
---|
138 | - if (extract_table_id(*it) > tableid) |
---|
139 | + uint cached_tableid = (*it).tableid; |
---|
140 | + uint cached_version = (*it).version; |
---|
141 | + uint cached_starttime = (*it).starttime; |
---|
142 | + uint cached_endtime = (*it).endtime; |
---|
143 | + if ((TableID::PF_EIT == tableid) || (TableID::PF_EITo == tableid)) |
---|
144 | { |
---|
145 | - // EIT from lower (ie. better) table number |
---|
146 | - tblChgCnt++; |
---|
147 | - } |
---|
148 | - else if ((extract_table_id(*it) == tableid) && |
---|
149 | - ((extract_version(*it) < version) || |
---|
150 | - ((extract_version(*it) == kVersionMax) && |
---|
151 | - version < kVersionMax))) |
---|
152 | - { |
---|
153 | - // EIT updated version on current table |
---|
154 | - verChgCnt++; |
---|
155 | + // tableid is for PF table |
---|
156 | + if ((TableID::PF_EIT == cached_tableid) || (TableID::PF_EITo == cached_tableid)) |
---|
157 | + { |
---|
158 | + // Already seen a PF table so check version |
---|
159 | + // and update if it has changed |
---|
160 | + if ((kVersionInvalid == cached_version) || |
---|
161 | + (cached_version < version) || |
---|
162 | + ((kVersionMax == cached_version) && (version < kVersionMax))) |
---|
163 | + { |
---|
164 | + LOG(VB_EIT, LOG_INFO, LOC + QString("PF table version change - new (%1 %2) old (%3 %4) eventid %5 for chanid %6") |
---|
165 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
166 | + .arg(QString().sprintf("%02x", cached_tableid)).arg(QString().sprintf("%02x", cached_version)) |
---|
167 | + .arg(eventid).arg(chanid)); |
---|
168 | + verChgCnt++; |
---|
169 | + bEntryUpdated = true; |
---|
170 | + if (((cached_starttime != kTimeInvalid) && (cached_starttime != starttime)) || (cached_endtime != endtime)) |
---|
171 | + bEventMayCauseReschedule = true; |
---|
172 | + } |
---|
173 | + else |
---|
174 | + { |
---|
175 | + // EIT data previously seen |
---|
176 | + hitCnt++; |
---|
177 | + return false; |
---|
178 | + } |
---|
179 | + } |
---|
180 | + else |
---|
181 | + { |
---|
182 | + // Old entry is in SC table |
---|
183 | + LOG(VB_EIT, LOG_INFO, LOC + QString("SC to PF tableid change - new (%1 %2) old (%3 %4) eventid %5 for chanid %6") |
---|
184 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
185 | + .arg(QString().sprintf("%02x", cached_tableid)).arg(QString().sprintf("%02x", cached_version)) |
---|
186 | + .arg(eventid).arg(chanid)); |
---|
187 | + bEntryUpdated = true; |
---|
188 | + if (((cached_starttime != kTimeInvalid) && (cached_starttime != starttime)) || (cached_endtime != endtime)) |
---|
189 | + bEventMayCauseReschedule = true; |
---|
190 | + } |
---|
191 | } |
---|
192 | else |
---|
193 | { |
---|
194 | - // EIT data previously seen |
---|
195 | - hitCnt++; |
---|
196 | - return false; |
---|
197 | + // tableid is for SC table |
---|
198 | + if ((TableID::PF_EIT == cached_tableid) || (TableID::PF_EITo == cached_tableid)) |
---|
199 | + { |
---|
200 | + // Already seen a PF table |
---|
201 | + hitCnt++; |
---|
202 | + return false; |
---|
203 | + } |
---|
204 | + else if ((cached_tableid & 0x0f) == (tableid & 0x0f)) |
---|
205 | + { |
---|
206 | + // Already seen in this segment of the table so check version |
---|
207 | + // and update if it has changed |
---|
208 | + if ((kVersionInvalid == cached_version) || |
---|
209 | + (cached_version < version) || |
---|
210 | + ((kVersionMax == cached_version) && (version < kVersionMax))) |
---|
211 | + { |
---|
212 | + LOG(VB_EIT, LOG_INFO, LOC + QString("SC table version change - new (%1 %2) old (%3 %4) eventid %5 for chanid %6") |
---|
213 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
214 | + .arg(QString().sprintf("%02x", cached_tableid)).arg(QString().sprintf("%02x", cached_version)) |
---|
215 | + .arg(eventid).arg(chanid)); |
---|
216 | + verChgCnt++; |
---|
217 | + bEntryUpdated = true; |
---|
218 | + if (((cached_starttime != kTimeInvalid) && (cached_starttime != starttime)) || (cached_endtime != endtime)) |
---|
219 | + bEventMayCauseReschedule = true; |
---|
220 | + } |
---|
221 | + else |
---|
222 | + { |
---|
223 | + // EIT data previously seen |
---|
224 | + hitCnt++; |
---|
225 | + return false; |
---|
226 | + } |
---|
227 | + } |
---|
228 | + else if ((cached_tableid & 0x0f) > (tableid < 0x0f)) |
---|
229 | + { |
---|
230 | + LOG(VB_EIT, LOG_INFO, LOC + QString("SC tableid change - new (%1 %2) old (%3 %4) eventid %5 for chanid %6") |
---|
231 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
232 | + .arg(QString().sprintf("%02x", cached_tableid)).arg(QString().sprintf("%02x", cached_version)) |
---|
233 | + .arg(eventid).arg(chanid)); |
---|
234 | + bEntryUpdated = true; |
---|
235 | + if (((cached_starttime != kTimeInvalid) && (cached_starttime != starttime)) || (cached_endtime != endtime)) |
---|
236 | + bEventMayCauseReschedule = true; |
---|
237 | + } |
---|
238 | + else |
---|
239 | + { |
---|
240 | + // Already seen this segment of SC table |
---|
241 | + hitCnt++; |
---|
242 | + return false; |
---|
243 | + } |
---|
244 | } |
---|
245 | } |
---|
246 | + else |
---|
247 | + bEventMayCauseReschedule = true; |
---|
248 | |
---|
249 | - eventMap->insert(eventid, construct_sig(tableid, version, endtime, true)); |
---|
250 | + if (bEntryUpdated) |
---|
251 | + LOG(VB_EIT, LOG_INFO, LOC + QString("Updated entry - table (%1 %2) eventid %3 for chanid %4 reschedule %5") |
---|
252 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
253 | + .arg(eventid).arg(chanid).arg(bEventMayCauseReschedule)); |
---|
254 | + else |
---|
255 | + LOG(VB_EIT, LOG_INFO, LOC + QString("New entry - table (%1 %2) eventid %3 for chanid %4 reschedule %5") |
---|
256 | + .arg(QString().sprintf("%02x", tableid)).arg(QString().sprintf("%02x", version)) |
---|
257 | + .arg(eventid).arg(chanid).arg(bEventMayCauseReschedule)); |
---|
258 | + event_map_entry_t entry(tableid, version, starttime, endtime, true); |
---|
259 | + eventMap->insert(eventid, entry); |
---|
260 | entryCnt++; |
---|
261 | |
---|
262 | return true; |
---|
263 | diff --git a/mythtv/libs/libmythtv/eitcache.h b/mythtv/libs/libmythtv/eitcache.h |
---|
264 | index 330b9aa..2ee0380 100644 |
---|
265 | --- a/mythtv/libs/libmythtv/eitcache.h |
---|
266 | +++ b/mythtv/libs/libmythtv/eitcache.h |
---|
267 | @@ -16,7 +16,21 @@ |
---|
268 | // MythTV headers |
---|
269 | #include "mythtvexp.h" |
---|
270 | |
---|
271 | -typedef QMap<uint, uint64_t> event_map_t; |
---|
272 | + |
---|
273 | +typedef struct __attribute__((__packed__)) event_map_entry |
---|
274 | +{ |
---|
275 | + event_map_entry(); |
---|
276 | + event_map_entry(uchar _tableid, uchar _version, uint _starttime, uint _endtime, bool _modified) |
---|
277 | + : tableid(_tableid), version(_version), starttime(_starttime), endtime(_endtime), modified(_modified) {} |
---|
278 | + uchar tableid; |
---|
279 | + uchar version; |
---|
280 | + uint starttime; |
---|
281 | + uint endtime; |
---|
282 | + bool modified; |
---|
283 | +} event_map_entry_t; |
---|
284 | + |
---|
285 | +typedef QMap<uint, event_map_entry_t> event_map_t; |
---|
286 | +//typedef QMap<uint, uint64_t> event_map_t; |
---|
287 | typedef QMap<uint, event_map_t*> key_map_t; |
---|
288 | |
---|
289 | class EITCache |
---|
290 | @@ -25,8 +39,13 @@ class EITCache |
---|
291 | EITCache(); |
---|
292 | ~EITCache(); |
---|
293 | |
---|
294 | + static const uchar kVersionMax; |
---|
295 | + static const uchar kVersionInvalid; |
---|
296 | + static const uint kTimeInvalid; |
---|
297 | + static const uchar kTableidInvalid; |
---|
298 | + |
---|
299 | bool IsNewEIT(uint chanid, uint tableid, uint version, |
---|
300 | - uint eventid, uint endtime); |
---|
301 | + uint eventid, uint starttime, uint endtime, bool &bEventMayCauseReschedule); |
---|
302 | |
---|
303 | uint PruneOldEntries(uint utc_timestamp); |
---|
304 | void WriteToDB(void); |
---|
305 | @@ -54,8 +73,6 @@ class EITCache |
---|
306 | uint prunedHitCnt; |
---|
307 | uint wrongChannelHitCnt; |
---|
308 | |
---|
309 | - static const uint kVersionMax; |
---|
310 | - |
---|
311 | public: |
---|
312 | static MTV_PUBLIC void ClearChannelLocks(void); |
---|
313 | }; |
---|
314 | diff --git a/mythtv/libs/libmythtv/eithelper.cpp b/mythtv/libs/libmythtv/eithelper.cpp |
---|
315 | index 9ee2cc8..ef20ba0 100644 |
---|
316 | --- a/mythtv/libs/libmythtv/eithelper.cpp |
---|
317 | +++ b/mythtv/libs/libmythtv/eithelper.cpp |
---|
318 | @@ -61,7 +61,7 @@ uint EITHelper::GetListSize(void) const |
---|
319 | * |
---|
320 | * \return Returns number of events inserted into DB. |
---|
321 | */ |
---|
322 | -uint EITHelper::ProcessEvents(void) |
---|
323 | +uint EITHelper::ProcessEvents(uint &rescheduleRequiredCount) |
---|
324 | { |
---|
325 | QMutexLocker locker(&eitList_lock); |
---|
326 | uint insertCount = 0; |
---|
327 | @@ -77,7 +77,12 @@ uint EITHelper::ProcessEvents(void) |
---|
328 | |
---|
329 | eitfixup->Fix(*event); |
---|
330 | |
---|
331 | - insertCount += event->UpdateDB(query, 1000); |
---|
332 | + bool rescheduleRequired; |
---|
333 | + |
---|
334 | + insertCount += event->UpdateDB(query, 1000, rescheduleRequired); |
---|
335 | + |
---|
336 | + if (rescheduleRequired) |
---|
337 | + rescheduleRequiredCount++; |
---|
338 | |
---|
339 | delete event; |
---|
340 | eitList_lock.lock(); |
---|
341 | @@ -90,14 +95,14 @@ uint EITHelper::ProcessEvents(void) |
---|
342 | { |
---|
343 | LOG(VB_EIT, LOG_INFO, |
---|
344 | LOC + QString("Added %1 events -- complete(%2) " |
---|
345 | - "incomplete(%3) unmatched(%4)") |
---|
346 | + "incomplete(%3) unmatched(%4) reschedule(%5)") |
---|
347 | .arg(insertCount).arg(db_events.size()) |
---|
348 | - .arg(incomplete_events.size()).arg(unmatched_etts.size())); |
---|
349 | + .arg(incomplete_events.size()).arg(unmatched_etts.size()).arg(rescheduleRequiredCount)); |
---|
350 | } |
---|
351 | else |
---|
352 | { |
---|
353 | LOG(VB_EIT, LOG_INFO, |
---|
354 | - LOC + QString("Added %1 events").arg(insertCount)); |
---|
355 | + LOC + QString("Added %1 events - reschedule %2").arg(insertCount).arg(rescheduleRequiredCount)); |
---|
356 | } |
---|
357 | |
---|
358 | return insertCount; |
---|
359 | @@ -285,6 +290,9 @@ static inline void parse_dvb_component_descriptors(desc_list_t list, |
---|
360 | |
---|
361 | void EITHelper::AddEIT(const DVBEventInformationTable *eit) |
---|
362 | { |
---|
363 | + // Skip if not current |
---|
364 | + if (!eit->IsCurrent()) |
---|
365 | + return; |
---|
366 | uint descCompression = (eit->TableID() > 0x80) ? 2 : 1; |
---|
367 | uint fix = fixup.value(eit->OriginalNetworkID() << 16); |
---|
368 | fix |= fixup.value((((uint64_t)eit->TSID()) << 32) | |
---|
369 | @@ -305,8 +313,10 @@ void EITHelper::AddEIT(const DVBEventInformationTable *eit) |
---|
370 | for (uint i = 0; i < eit->EventCount(); i++) |
---|
371 | { |
---|
372 | // Skip event if we have already processed it before... |
---|
373 | + bool bEventMayCauseReschedule; |
---|
374 | if (!eitcache->IsNewEIT(chanid, tableid, version, eit->EventID(i), |
---|
375 | - eit->EndTimeUnixUTC(i))) |
---|
376 | + eit->StartTimeUnixUTC(i), eit->EndTimeUnixUTC(i), |
---|
377 | + bEventMayCauseReschedule)) |
---|
378 | { |
---|
379 | continue; |
---|
380 | } |
---|
381 | @@ -473,8 +483,33 @@ void EITHelper::AddEIT(const DVBEventInformationTable *eit) |
---|
382 | subtitle_type, |
---|
383 | audio_props, |
---|
384 | video_props, stars, |
---|
385 | - seriesId, programId); |
---|
386 | - |
---|
387 | + seriesId, programId, bEventMayCauseReschedule); |
---|
388 | + |
---|
389 | +/* // If the event is from the now next table and the seriesId and programId are present |
---|
390 | + // then test whether any recording rules match the seriesId amd programId. If not |
---|
391 | + // then discard the event. |
---|
392 | + // For a less argressive discard policy swap the following two lines |
---|
393 | + //if (((0x4e == tableid) || (0x4f == tableid)) && (!seriesId.isEmpty() || !programId.isEmpty())) |
---|
394 | + if ((0x4e == tableid) || (0x4f == tableid)) |
---|
395 | + { |
---|
396 | + // Fix up the seriesId and programId |
---|
397 | + DBEventEIT tempEvent(*event); |
---|
398 | + tempEvent.fixup = EITFixUp::kFixGenericDVB; |
---|
399 | + eitfixup->Fix(tempEvent); |
---|
400 | + MSqlQuery query(MSqlQuery::InitCon()); |
---|
401 | + query.prepare("SELECT EXISTS(SELECT * FROM record WHERE seriesid = :SERIESID AND programid = :PROGRAMID)"); |
---|
402 | + query.bindValue(":SERIESID", tempEvent.seriesId); |
---|
403 | + query.bindValue(":PROGRAMID", tempEvent.programId); |
---|
404 | + if (!query.exec()) |
---|
405 | + MythDB::DBError("AddEIT", query); |
---|
406 | + if (query.next()) |
---|
407 | + if (!query.value(0).toBool()) |
---|
408 | + { |
---|
409 | + LOG(VB_EIT, LOG_INFO, LOC + QString("Discarding now next event - eventid %1").arg(eit->EventID(i))); |
---|
410 | + continue; |
---|
411 | + } |
---|
412 | + LOG(VB_EIT, LOG_INFO, LOC + QString("Adding now next event to queue - eventid %1").arg(eit->EventID(i))); |
---|
413 | + }*/ |
---|
414 | db_events.enqueue(event); |
---|
415 | } |
---|
416 | } |
---|
417 | @@ -559,7 +594,8 @@ void EITHelper::AddEIT(const PremiereContentInformationTable *cit) |
---|
418 | } |
---|
419 | |
---|
420 | // Skip event if we have already processed it before... |
---|
421 | - if (!eitcache->IsNewEIT(chanid, tableid, version, contentid, endtime)) |
---|
422 | + bool bEventMayCauseReschedule; |
---|
423 | + if (!eitcache->IsNewEIT(chanid, tableid, version, contentid, EITCache::kTimeInvalid, endtime, bEventMayCauseReschedule)) |
---|
424 | { |
---|
425 | continue; |
---|
426 | } |
---|
427 | @@ -580,7 +616,7 @@ void EITHelper::AddEIT(const PremiereContentInformationTable *cit) |
---|
428 | subtitle_type, |
---|
429 | audio_props, |
---|
430 | video_props, 0.0, |
---|
431 | - "", ""); |
---|
432 | + "", "", bEventMayCauseReschedule); |
---|
433 | |
---|
434 | db_events.enqueue(event); |
---|
435 | } |
---|
436 | @@ -982,4 +1018,4 @@ static void init_fixup(QMap<uint64_t,uint> &fix) |
---|
437 | fix[ 1094LL << 32 | 1 << 16 | 17028 ] = // NT1 |
---|
438 | fix[ 1100LL << 32 | 1 << 16 | 8710 ] = // NRJ 12 |
---|
439 | EITFixUp::kEFixForceISO8859_15; |
---|
440 | -} |
---|
441 | +} |
---|
442 | \ No newline at end of file |
---|
443 | diff --git a/mythtv/libs/libmythtv/eithelper.h b/mythtv/libs/libmythtv/eithelper.h |
---|
444 | index 790d86e..3a11c86 100644 |
---|
445 | --- a/mythtv/libs/libmythtv/eithelper.h |
---|
446 | +++ b/mythtv/libs/libmythtv/eithelper.h |
---|
447 | @@ -62,7 +62,7 @@ class EITHelper |
---|
448 | virtual ~EITHelper(); |
---|
449 | |
---|
450 | uint GetListSize(void) const; |
---|
451 | - uint ProcessEvents(void); |
---|
452 | + uint ProcessEvents(uint &rescheduleRequiredCount); |
---|
453 | |
---|
454 | uint GetGPSOffset(void) const { return (uint) (0 - gps_offset); } |
---|
455 | |
---|
456 | diff --git a/mythtv/libs/libmythtv/eitscanner.cpp b/mythtv/libs/libmythtv/eitscanner.cpp |
---|
457 | index 0c2a70e..6301d06 100644 |
---|
458 | --- a/mythtv/libs/libmythtv/eitscanner.cpp |
---|
459 | +++ b/mythtv/libs/libmythtv/eitscanner.cpp |
---|
460 | @@ -79,6 +79,7 @@ void EITScanner::run(void) |
---|
461 | |
---|
462 | MythTimer t; |
---|
463 | uint eitCount = 0; |
---|
464 | + uint rescheduleRequiredCount = 0; |
---|
465 | |
---|
466 | while (!exitThread) |
---|
467 | { |
---|
468 | @@ -102,7 +103,7 @@ void EITScanner::run(void) |
---|
469 | |
---|
470 | if (list_size) |
---|
471 | { |
---|
472 | - eitCount += eitHelper->ProcessEvents(); |
---|
473 | + eitCount += eitHelper->ProcessEvents(rescheduleRequiredCount); |
---|
474 | t.start(); |
---|
475 | } |
---|
476 | |
---|
477 | @@ -113,7 +114,12 @@ void EITScanner::run(void) |
---|
478 | LOG(VB_EIT, LOG_INFO, |
---|
479 | LOC_ID + QString("Added %1 EIT Events").arg(eitCount)); |
---|
480 | eitCount = 0; |
---|
481 | - RescheduleRecordings(); |
---|
482 | + |
---|
483 | + if (rescheduleRequiredCount) |
---|
484 | + { |
---|
485 | + rescheduleRequiredCount = 0; |
---|
486 | + RescheduleRecordings(); |
---|
487 | + } |
---|
488 | } |
---|
489 | |
---|
490 | if (activeScan && (MythDate::current() > activeScanNextTrig)) |
---|
491 | @@ -124,7 +130,11 @@ void EITScanner::run(void) |
---|
492 | LOG(VB_EIT, LOG_INFO, |
---|
493 | LOC_ID + QString("Added %1 EIT Events").arg(eitCount)); |
---|
494 | eitCount = 0; |
---|
495 | - RescheduleRecordings(); |
---|
496 | + if (rescheduleRequiredCount) |
---|
497 | + { |
---|
498 | + rescheduleRequiredCount = 0; |
---|
499 | + RescheduleRecordings(); |
---|
500 | + } |
---|
501 | } |
---|
502 | |
---|
503 | if (activeScanNextChan == activeScanChannels.end()) |
---|
504 | @@ -187,7 +197,7 @@ void EITScanner::RescheduleRecordings(void) |
---|
505 | MythDate::current().addSecs(kMinRescheduleInterval); |
---|
506 | resched_lock.unlock(); |
---|
507 | |
---|
508 | - ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(), "EITScanner"); |
---|
509 | + ScheduledRecording::RescheduleMatch(0, 0, 0, QDateTime(), "Requested by EIT Scanner "); |
---|
510 | } |
---|
511 | |
---|
512 | /** \fn EITScanner::StartPassiveScan(ChannelBase*, EITSource*, bool) |
---|
513 | diff --git a/mythtv/libs/libmythtv/programdata.cpp b/mythtv/libs/libmythtv/programdata.cpp |
---|
514 | index 06e822f..77d20ae 100644 |
---|
515 | --- a/mythtv/libs/libmythtv/programdata.cpp |
---|
516 | +++ b/mythtv/libs/libmythtv/programdata.cpp |
---|
517 | @@ -750,6 +750,33 @@ uint DBEvent::InsertDB(MSqlQuery &query, uint chanid) const |
---|
518 | return 1; |
---|
519 | } |
---|
520 | |
---|
521 | +uint DBEventEIT::UpdateDB(MSqlQuery &query, int match_threshold, bool &RescheduleRequired) const |
---|
522 | +{ |
---|
523 | + RescheduleRequired = false; |
---|
524 | + if (!DBEvent::UpdateDB(query, chanid, match_threshold)) |
---|
525 | + return 0; |
---|
526 | + |
---|
527 | + if (eventMayCauseReschedule) |
---|
528 | + { |
---|
529 | + MSqlQuery localquery(MSqlQuery::InitCon()); |
---|
530 | + localquery.prepare("SELECT EXISTS(SELECT * FROM record WHERE seriesid = :SERIESID AND programid = :PROGRAMID)"); |
---|
531 | + localquery.bindValue(":SERIESID", seriesId); |
---|
532 | + localquery.bindValue(":PROGRAMID", programId); |
---|
533 | + if (!localquery.exec()) |
---|
534 | + MythDB::DBError("AddEIT", query); |
---|
535 | + if (query.next()) |
---|
536 | + if (!query.value(0).toBool()) |
---|
537 | + { |
---|
538 | + RescheduleRequired = true; |
---|
539 | + LOG(VB_GENERAL, LOG_INFO, LOC + |
---|
540 | + QString("EIT scanner requesting reschedule for - %1 - seriesId %2 programId %3") |
---|
541 | + .arg(title).arg(seriesId).arg(programId)); |
---|
542 | + } |
---|
543 | + } |
---|
544 | + |
---|
545 | + return 1; |
---|
546 | +} |
---|
547 | + |
---|
548 | ProgInfo::ProgInfo(const ProgInfo &other) : |
---|
549 | DBEvent(other.listingsource) |
---|
550 | { |
---|
551 | diff --git a/mythtv/libs/libmythtv/programdata.h b/mythtv/libs/libmythtv/programdata.h |
---|
552 | index 9c484e6..d8e3583 100644 |
---|
553 | --- a/mythtv/libs/libmythtv/programdata.h |
---|
554 | +++ b/mythtv/libs/libmythtv/programdata.h |
---|
555 | @@ -184,11 +184,13 @@ class MTV_PUBLIC DBEventEIT : public DBEvent |
---|
556 | unsigned char _audioProps, |
---|
557 | unsigned char _videoProps, |
---|
558 | float _stars, |
---|
559 | - const QString &_seriesId, const QString &_programId) : |
---|
560 | + const QString &_seriesId, |
---|
561 | + const QString &_programId, |
---|
562 | + bool _eventMayCauseReschedule) : |
---|
563 | DBEvent(_title, _subtitle, _desc, _category, _category_type, |
---|
564 | _start, _end, _subtitleType, _audioProps, _videoProps, |
---|
565 | _stars, _seriesId, _programId, kListingSourceEIT), |
---|
566 | - chanid(_chanid), fixup(_fixup) |
---|
567 | + chanid(_chanid), fixup(_fixup), eventMayCauseReschedule(_eventMayCauseReschedule) |
---|
568 | { |
---|
569 | } |
---|
570 | |
---|
571 | @@ -206,14 +208,12 @@ class MTV_PUBLIC DBEventEIT : public DBEvent |
---|
572 | { |
---|
573 | } |
---|
574 | |
---|
575 | - uint UpdateDB(MSqlQuery &query, int match_threshold) const |
---|
576 | - { |
---|
577 | - return DBEvent::UpdateDB(query, chanid, match_threshold); |
---|
578 | - } |
---|
579 | + uint UpdateDB(MSqlQuery &query, int match_threshold, bool &RescheduleRequired) const; |
---|
580 | |
---|
581 | public: |
---|
582 | uint32_t chanid; |
---|
583 | uint32_t fixup; |
---|
584 | + bool eventMayCauseReschedule; |
---|
585 | }; |
---|
586 | |
---|
587 | class MTV_PUBLIC ProgInfo : public DBEvent |
---|