From f0537ea0f1102fa4961ff7d592238c70da8c8240 Mon Sep 17 00:00:00 2001 From: Klaus Schmidinger Date: Fri, 23 Aug 2013 10:54:49 +0200 Subject: [PATCH] Added Begin/EndSegmentTransfer() to the EPG handler interface --- CONTRIBUTORS | 1 + HISTORY | 1 + eit.c | 4 +++- epg.c | 18 +++++++++++++++++- epg.h | 10 +++++++++- 5 files changed, 31 insertions(+), 3 deletions(-) diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 9840890e..f1628069 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -2550,6 +2550,7 @@ J for reporting that cPlugin::Active() was called too often for adding HandledExternally() to the EPG handler interface for adding IsUpdate() to the EPG handler interface + for adding Begin/EndSegmentTransfer() to the EPG handler interface Peter Pinnau for reporting that 'uint32_t' requires including stdint.h in font.h on some systems diff --git a/HISTORY b/HISTORY index b56c4bd1..3c8a3643 100644 --- a/HISTORY +++ b/HISTORY @@ -7884,3 +7884,4 @@ Video Disk Recorder Revision History Manfred Völkel and Oliver Endriss). - Reverted the change from version 1.5.7 that made all logging go to LOG_ERR (thanks to Christopher Reimer). +- Added Begin/EndSegmentTransfer() to the EPG handler interface (thanks to Jörg Wendel). diff --git a/eit.c b/eit.c index 73c4fa9b..a3cf3413 100644 --- a/eit.c +++ b/eit.c @@ -8,7 +8,7 @@ * Robert Schneider and Rolf Hakenes . * Adapted to 'libsi' for VDR 1.3.0 by Marcel Wiesweg . * - * $Id: eit.c 2.23 2012/12/04 11:10:10 kls Exp $ + * $Id: eit.c 3.1 2013/08/23 10:52:27 kls Exp $ */ #include "eit.h" @@ -46,6 +46,7 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo return; } + EpgHandlers.BeginSegmentTransfer(channel, OnlyRunningStatus); bool handledExternally = EpgHandlers.HandledExternally(channel); cSchedule *pSchedule = (cSchedule *)Schedules->GetSchedule(channel, true); @@ -310,6 +311,7 @@ cEIT::cEIT(cSchedules *Schedules, int Source, u_char Tid, const u_char *Data, bo Schedules->SetModified(pSchedule); } Channels.Unlock(); + EpgHandlers.EndSegmentTransfer(Modified, OnlyRunningStatus); } // --- cTDT ------------------------------------------------------------------ diff --git a/epg.c b/epg.c index 5fb49ae4..e16f9780 100644 --- a/epg.c +++ b/epg.c @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.c 2.23 2013/02/17 14:12:07 kls Exp $ + * $Id: epg.c 3.1 2013/08/23 10:46:33 kls Exp $ */ #include "epg.h" @@ -1537,3 +1537,19 @@ void cEpgHandlers::DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t } Schedule->DropOutdated(SegmentStart, SegmentEnd, TableID, Version); } + +void cEpgHandlers::BeginSegmentTransfer(const cChannel *Channel, bool OnlyRunningStatus) +{ + for (cEpgHandler *eh = First(); eh; eh = Next(eh)) { + if (eh->BeginSegmentTransfer(Channel, OnlyRunningStatus)) + return; + } +} + +void cEpgHandlers::EndSegmentTransfer(bool Modified, bool OnlyRunningStatus) +{ + for (cEpgHandler *eh = First(); eh; eh = Next(eh)) { + if (eh->EndSegmentTransfer(Modified, OnlyRunningStatus)) + return; + } +} diff --git a/epg.h b/epg.h index 3a7df772..65fbcbf9 100644 --- a/epg.h +++ b/epg.h @@ -7,7 +7,7 @@ * Original version (as used in VDR before 1.3.0) written by * Robert Schneider and Rolf Hakenes . * - * $Id: epg.h 2.15 2012/09/24 12:53:53 kls Exp $ + * $Id: epg.h 3.1 2013/08/23 10:50:05 kls Exp $ */ #ifndef __EPG_H @@ -273,6 +273,12 @@ public: virtual bool DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version) { return false; } ///< Takes a look at all EPG events between SegmentStart and SegmentEnd and ///< drops outdated events. + virtual bool BeginSegmentTransfer(const cChannel *Channel, bool OnlyRunningStatus) { return false; } + ///< Called directly after IgnoreChannel() before any other handler method is called. + ///< Designed to give handlers the possibility to prepare a database transaction. + virtual bool EndSegmentTransfer(bool Modified, bool OnlyRunningStatus) { return false; } + ///< Called after the segment data has been processed. + ///< At this point handlers should close/commit/rollback any pending database transactions. }; class cEpgHandlers : public cList { @@ -295,6 +301,8 @@ public: void HandleEvent(cEvent *Event); void SortSchedule(cSchedule *Schedule); void DropOutdated(cSchedule *Schedule, time_t SegmentStart, time_t SegmentEnd, uchar TableID, uchar Version); + void BeginSegmentTransfer(const cChannel *Channel, bool OnlyRunningStatus); + void EndSegmentTransfer(bool Modified, bool OnlyRunningStatus); }; extern cEpgHandlers EpgHandlers;