summaryrefslogtreecommitdiff
path: root/eit2.c
diff options
context:
space:
mode:
authorDimitar Petrovski <dimeptr@gmail.com>2018-08-21 08:33:02 (GMT)
committerDimitar Petrovski <dimeptr@gmail.com>2018-08-21 08:33:02 (GMT)
commit27fbd9ec01e5fc69f83a0649a631223b655b3a7a (patch)
tree8c40e0fdbe87e54b34461f67010c8a278c04b016 /eit2.c
parentfde4ca50a0f8887aec1ab17ab2fb368a2dcc71bd (diff)
downloadvdr-plugin-eepg-27fbd9ec01e5fc69f83a0649a631223b655b3a7a.tar.gz
vdr-plugin-eepg-27fbd9ec01e5fc69f83a0649a631223b655b3a7a.tar.bz2
code clenaup
Diffstat (limited to 'eit2.c')
-rw-r--r--eit2.c62
1 files changed, 40 insertions, 22 deletions
diff --git a/eit2.c b/eit2.c
index cb5f9fc..5aeb60d 100644
--- a/eit2.c
+++ b/eit2.c
@@ -18,7 +18,7 @@ using namespace util;
namespace SI
{
-cEvent* cEIT2::ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/cSchedule* pSchedule,const SI::EIT::Event* EitEvent,
+cEvent* cEIT2::ProcessEitEvent(cSchedule* pSchedule,const SI::EIT::Event* EitEvent,
uchar Tid, uchar versionNumber)
{
bool ExternalData = false;
@@ -90,15 +90,14 @@ cEvent* cEIT2::ProcessEitEvent(/*cChannels* Channels, cSchedules * Schedules,*/c
pEvent->SetVersion (versionNumber);
ProcessEventDescriptors(ExternalData, channel->Source(), Tid, EitEvent,
- pEvent, /*Schedules,*/ channel->GetChannelID());
+ pEvent, channel->GetChannelID());
Modified = true;
return pEvent;
}
-void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source,
- u_char Tid, const SI::EIT::Event* SiEitEvent, cEvent* pEvent,
- /*cChannels* Channels, cSchedules* Schedules,*/ const tChannelID& channelId)
+void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source, u_char Tid,
+ const SI::EIT::Event* SiEitEvent, cEvent* pEvent, const tChannelID& channelId)
{
const cEvent *rEvent = NULL;
@@ -235,7 +234,8 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source,
#if APIVERSNUM >= 20300
LOCK_SCHEDULES_READ;
#else
- //TODO
+ cSchedulesLock SchedulesLock;
+ cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock));
#endif
if (Schedules) {
SI::TimeShiftedEventDescriptor * tsed = (SI::TimeShiftedEventDescriptor *) d;
@@ -465,11 +465,9 @@ void cEIT2::ProcessEventDescriptors(bool ExternalData, int Source,
//channel->SetLinkChannels (LinkChannels);
}
-cEIT2::cEIT2 (/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid, bool OnlyRunningStatus)
+cEIT2::cEIT2 (int Source, u_char Tid, const u_char * Data, EFormat format, bool isEITPid)
: SI::EIT (Data, false)
-, OnlyRunningStatus(OnlyRunningStatus)
-//, Channels(Channels)
-//, Schedules(Schedules)
+, OnlyRunningStatus(false)
, Format(format)
{
@@ -493,18 +491,39 @@ cEIT2::cEIT2 (/*cChannels* Channels, cSchedules * Schedules,*/ int Source, u_cha
//LogD(5, prep("channelID: %s format:%d"), *channel->GetChannelID().ToString(), Format);
#if APIVERSNUM >= 20300
- LOCK_CHANNELS_WRITE;
- if (!Channels) {
- LogD(3, prep("Error obtaining channels lock"));
- return;
- }
- LOCK_SCHEDULES_WRITE;
- if (!Schedules) {
- LogD(3, prep("Error obtaining schedules lock"));
- return;
- }
+ LOCK_CHANNELS_WRITE;
+ if (!Channels) {
+ LogD(3, prep("Error obtaining channels lock"));
+ return;
+ }
+ LOCK_SCHEDULES_WRITE;
+ if (!Schedules) {
+ LogD(3, prep("Error obtaining schedules lock"));
+ return;
+ }
#else
- //TODO
+ cChannelsLock ChannelsLock(true, 10), ChannelsLockR;
+ cChannels *Channels = (cChannels*)(cChannels::Channels(ChannelsLock));
+ cSchedulesLock SchedulesLock(true, 10), SchedulesLockR;
+ cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLock));
+ if (!Channels) {
+ LogD(3, prep("Error obtaining channels lock"));
+ OnlyRunningStatus = true;
+ cChannels *Channels = (cChannels*)(cChannels::Channels(ChannelsLockR));
+ }
+ if (!Schedules) {
+ // If we don't get a write lock, let's at least get a read lock, so
+ // that we can set the running status and 'seen' timestamp (well, actually
+ // with a read lock we shouldn't be doing that, but it's only integers that
+ // get changed, so it should be ok)
+ LogD(3, prep("Error obtaining schedules lock"));
+ OnlyRunningStatus = true;
+ cSchedules *Schedules = (cSchedules*)(cSchedules::Schedules(SchedulesLockR));
+ }
+ if (!Schedules || !Channels) {
+ LogD(3, prep("Error obtaining read lock"));
+ return;
+ }
#endif
cSchedule *pSchedule = (cSchedule *) Schedules->GetSchedule (channel, true);
@@ -622,7 +641,6 @@ cEIT2::cEIT2 (cSchedule * Schedule, EFormat format)
, OnlyRunningStatus(false)
, SegmentStart(0)
, SegmentEnd(0)
-//, Schedules(NULL)
, Format(format)
{
//LogD(2, prep("cEIT2::cEIT2"));