diff --git a/config.h b/config.h index 3300a84..ec6d68a 100644 --- a/config.h +++ b/config.h @@ -123,7 +123,7 @@ public: cSDPluginManager *plgManager = NULL; cFontManager *fontManager = NULL; cImageCache *imgCache = NULL; - cRecordingsFolderInfo recFolderInfo(Recordings); + cRecordingsFolderInfo recFolderInfo; #else extern cDesignerConfig config; extern cSDPluginManager *plgManager; diff --git a/coreengine/area.c b/coreengine/area.c index ca5ae25..2340c39 100644 --- a/coreengine/area.c +++ b/coreengine/area.c @@ -51,36 +51,36 @@ cArea::cArea(const cArea &other) { blinking = false; scrollFunc = NULL; - for (cFunction *func = other.functions.First(); func; func = other.functions.Next(func)) { - if (cFuncFill *f = dynamic_cast(func)) { + for (const cFunction *func = other.functions.First(); func; func = other.functions.Next(func)) { + if (cFuncFill *f = dynamic_cast((cFunction*)func)) { cFuncFill *fFill = new cFuncFill(*f); fFill->SetOwner(this); functions.Add(fFill); - } else if (cFuncDrawRectangle *f = dynamic_cast(func)) { + } else if (cFuncDrawRectangle *f = dynamic_cast((cFunction*)func)) { cFuncDrawRectangle *fDrawRect = new cFuncDrawRectangle(*f); fDrawRect->SetOwner(this); functions.Add(fDrawRect); - } else if (cFuncDrawEllipse *f = dynamic_cast(func)) { + } else if (cFuncDrawEllipse *f = dynamic_cast((cFunction*)func)) { cFuncDrawEllipse *fDrawEllipse = new cFuncDrawEllipse(*f); fDrawEllipse->SetOwner(this); functions.Add(fDrawEllipse); - } else if (cFuncDrawSlope *f = dynamic_cast(func)) { + } else if (cFuncDrawSlope *f = dynamic_cast((cFunction*)func)) { cFuncDrawSlope *fDrawSlope = new cFuncDrawSlope(*f); fDrawSlope->SetOwner(this); functions.Add(fDrawSlope); - } else if (cFuncDrawText *f = dynamic_cast(func)) { + } else if (cFuncDrawText *f = dynamic_cast((cFunction*)func)) { cFuncDrawText *fDrawText = new cFuncDrawText(*f); fDrawText->SetOwner(this); functions.Add(fDrawText); - } else if (cFuncDrawTextVertical *f = dynamic_cast(func)) { + } else if (cFuncDrawTextVertical *f = dynamic_cast((cFunction*)func)) { cFuncDrawTextVertical *fDrawTextVertical = new cFuncDrawTextVertical(*f); fDrawTextVertical->SetOwner(this); functions.Add(fDrawTextVertical); - } else if (cFuncDrawTextBox *f = dynamic_cast(func)) { + } else if (cFuncDrawTextBox *f = dynamic_cast((cFunction*)func)) { cFuncDrawTextBox *fDrawTextBox = new cFuncDrawTextBox(*f); fDrawTextBox->SetOwner(this); functions.Add(fDrawTextBox); - } else if (cFuncDrawImage *f = dynamic_cast(func)) { + } else if (cFuncDrawImage *f = dynamic_cast((cFunction*)func)) { cFuncDrawImage *fDrawImage = new cFuncDrawImage(*f); fDrawImage->SetOwner(this); functions.Add(fDrawImage); @@ -580,7 +580,7 @@ cAreaContainer::cAreaContainer(void) { cAreaContainer::cAreaContainer(const cAreaContainer &other) { globals = other.globals; attribs = new cAreaContainerAttribs(*other.attribs); - for (cArea *area = other.areas.First(); area; area = other.areas.Next(area)) { + for (const cArea *area = other.areas.First(); area; area = other.areas.Next(area)) { cArea *a = new cArea(*area); a->SetAreaContainer(this); areas.Add(a); diff --git a/coreengine/complextypes.c b/coreengine/complextypes.c index 67772f0..a660dca 100644 --- a/coreengine/complextypes.c +++ b/coreengine/complextypes.c @@ -99,7 +99,7 @@ void cCond::Debug(void) { if (compareValue >= 0) esyslog("skindesigner: compare value: %d", compareValue); if (compareStrValue) - esyslog("skindesigner: compare string value: %d", compareStrValue); + esyslog("skindesigner: compare string value: %s", compareStrValue); } /****************************************************************** @@ -117,7 +117,7 @@ cCondition::cCondition(const cCondition &other) { globals = NULL; tokenContainer = NULL; loopInfo = NULL; - for (cCond *cond = other.conds.First(); cond; cond = other.conds.Next(cond)) + for (const cCond *cond = other.conds.First(); cond; cond = other.conds.Next(cond)) conds.Add(new cCond(*cond)); } @@ -468,7 +468,7 @@ cSummand::cSummand(const cSummand &other) { if (other.summand) summand = strdup(other.summand); positive = other.positive; - for (cFactor *fac = other.factors.First(); fac; fac = other.factors.Next(fac)) { + for (const cFactor *fac = other.factors.First(); fac; fac = other.factors.Next(fac)) { factors.Add(new cFactor(*fac)); } } @@ -490,13 +490,13 @@ void cSummand::Debug(void) { else if (f->type == eFactorType::looptoken) esyslog("skindesigner: LoopToken factor, index %d, %s", f->tokenIndex, link); else if (f->type == eFactorType::xref) - esyslog("skindesigner: posx reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncX()); + esyslog("skindesigner: posx reference factor, %s, %p, %s, result: %d", f->funcRefName, f->funcRef, link, f->funcRef->FuncX()); else if (f->type == eFactorType::yref) - esyslog("skindesigner: posy reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncY()); + esyslog("skindesigner: posy reference factor, %s, %p, %s, result: %d", f->funcRefName, f->funcRef, link, f->funcRef->FuncY()); else if (f->type == eFactorType::widthref) - esyslog("skindesigner: width reference factor, %s, %p, %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncWidth()); + esyslog("skindesigner: width reference factor, %s, %p, %s, result: %d", f->funcRefName, f->funcRef, link, f->funcRef->FuncWidth()); else if (f->type == eFactorType::heightref) - esyslog("skindesigner: height reference factor, %s, %p %s, result: %f", f->funcRefName, f->funcRef, link, f->funcRef->FuncHeight()); + esyslog("skindesigner: height reference factor, %s, %p %s, result: %d", f->funcRefName, f->funcRef, link, f->funcRef->FuncHeight()); else if (f->type == eFactorType::areawidth) esyslog("skindesigner: {areawidth} factor, %s", link); else if (f->type == eFactorType::areaheight) @@ -531,7 +531,7 @@ cNumericExpr::cNumericExpr(const cNumericExpr &other) { horizontal = other.horizontal; value = other.value; dynamic = other.dynamic; - for (cSummand *s = other.summands.First(); s; s = other.summands.Next(s)) { + for (const cSummand *s = other.summands.First(); s; s = other.summands.Next(s)) { summands.Add(new cSummand(*s)); } } @@ -1079,7 +1079,7 @@ cTextExpr::cTextExpr(const cTextExpr &other) { expr = strdup(other.expr); tokenContainer = NULL; loopInfo = NULL; - for (cTextToken* t = other.textTokens.First(); t; t = other.textTokens.Next(t)) { + for (const cTextToken* t = other.textTokens.First(); t; t = other.textTokens.Next(t)) { textTokens.Add(new cTextToken(*t)); } } diff --git a/coreengine/listelements.c b/coreengine/listelements.c index 6a3b525..74bd1bb 100644 --- a/coreengine/listelements.c +++ b/coreengine/listelements.c @@ -797,10 +797,14 @@ bool cCeMenuSchedules::Parse(bool forced) { if (menuCat == mcScheduleNow || menuCat == mcScheduleNext) { int eventsAvailable = 0; +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_SCHEDULES_READ; + const cSchedules* schedules = Schedules; +#else cSchedulesLock schedulesLock; - const cSchedules *schedules = cSchedules::Schedules(schedulesLock); - const cSchedule *schedule = NULL; - schedule = schedules->GetSchedule(channel); + const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); +#endif + const cSchedule *schedule = schedules->GetSchedule(channel); if (schedule) { for (const cEvent *e = schedule->GetPresentEvent(); e; e = schedule->Events()->Next(e)) { eventsAvailable++; @@ -917,10 +921,14 @@ bool cLeMenuChannels::Parse(bool forced) { } //current schedule +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_SCHEDULES_READ; + const cSchedules* schedules = Schedules; +#else cSchedulesLock schedulesLock; - const cSchedules *schedules = cSchedules::Schedules(schedulesLock); - const cSchedule *schedule = NULL; - schedule = schedules->GetSchedule(channel); + const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); +#endif + const cSchedule *schedule = schedules->GetSchedule(channel); if (schedule) { const cEvent *presentEvent = schedule->GetPresentEvent(); if (presentEvent) { @@ -1046,10 +1054,14 @@ bool cCeMenuChannels::Parse(bool forced) { tokenContainer->AddIntToken((int)eCeMenuChannelsIT::isTerr, source->IsTerr(source->Code())); } +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_SCHEDULES_READ; + const cSchedules* schedules = Schedules; +#else cSchedulesLock schedulesLock; - const cSchedules *schedules = cSchedules::Schedules(schedulesLock); - const cSchedule *schedule = NULL; - schedule = schedules->GetSchedule(channel); + const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); +#endif + const cSchedule *schedule = schedules->GetSchedule(channel); if (schedule) { const cEvent *presentEvent = schedule->GetPresentEvent(); if (presentEvent) { @@ -1484,7 +1496,13 @@ bool cLeMenuRecordings::Parse(bool forced) { cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName); delete[] folderName; if (folderInfo) { - cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_RECORDINGS_READ; + const cRecordings* recordings = Recordings; +#else + cRecordings* recordings = &Recordings; +#endif + const cRecording *newestRec = recordings->GetByName(*folderInfo->LatestFileName); if (newestRec) { usedRecording = newestRec; } @@ -1724,7 +1742,13 @@ bool cCeMenuRecordings::Parse(bool forced) { if (isFolder) { cRecordingsFolderInfo::cFolderInfo *folderInfo = recFolderInfo.Get(folderName.str().c_str()); if (folderInfo) { - cRecording *newestRec = Recordings.GetByName(*folderInfo->LatestFileName); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_RECORDINGS_READ; + const cRecordings* recordings = Recordings; +#else + cRecordings* recordings = &Recordings; +#endif + const cRecording *newestRec = recordings->GetByName(*folderInfo->LatestFileName); if (newestRec) { usedRecording = newestRec; } diff --git a/coreengine/viewdetail.c b/coreengine/viewdetail.c index 2999b00..0bb8555 100644 --- a/coreengine/viewdetail.c +++ b/coreengine/viewdetail.c @@ -353,7 +353,13 @@ bool cViewDetailEpg::Parse(bool forced) { tokenContainer->AddIntToken((int)eDmDetailedEpgIT::year, sStartTime->tm_year + 1900); tokenContainer->AddIntToken((int)eDmDetailedEpgIT::daynumeric, sStartTime->tm_mday); tokenContainer->AddIntToken((int)eDmDetailedEpgIT::month, sStartTime->tm_mon+1); - const cChannel *channel = Channels.GetByChannelID(event->ChannelID()); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(event->ChannelID()); if (channel) { tokenContainer->AddStringToken((int)eDmDetailedEpgST::channelname, channel->Name()); tokenContainer->AddIntToken((int)eDmDetailedEpgIT::channelnumber, channel->Number()); @@ -434,7 +440,13 @@ int cViewDetailEpg::NumReruns(cListFirst(); r && i < maxNumReruns; r = reruns->Next(r)) { time_t eventStart = event->StartTime(); time_t rerunStart = r->event->StartTime(); - cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(r->event->ChannelID(), true, true); //check for identical event if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart)) continue; @@ -463,7 +475,13 @@ void cViewDetailEpg::SetReruns(cListFirst(); r && i < maxNumReruns; r = reruns->Next(r)) { time_t eventStart = event->StartTime(); time_t rerunStart = r->event->StartTime(); - cChannel *channel = Channels.GetByChannelID(r->event->ChannelID(), true, true); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(r->event->ChannelID(), true, true); //check for identical event if ((event->ChannelID() == r->event->ChannelID()) && (eventStart == rerunStart)) continue; @@ -792,7 +810,13 @@ void cViewDetailRec::SetRecInfos(void) { const cRecordingInfo *info = recording->Info(); if (info) { - cChannel *channel = Channels.GetByChannelID(info->ChannelID()); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(info->ChannelID()); if (channel) { tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelname, channel->Name()); tokenContainer->AddStringToken((int)eDmDetailedRecST::recchannelid, *channel->GetChannelID().ToString()); diff --git a/coreengine/viewdisplaymenu.c b/coreengine/viewdisplaymenu.c index 467511e..5cd0298 100644 --- a/coreengine/viewdisplaymenu.c +++ b/coreengine/viewdisplaymenu.c @@ -406,7 +406,12 @@ void cViewMenu::SetChannelHeader(const cEvent *event) { if (!event) return; if (menuChange && menuCat == mcSchedule) { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannel *channel = Channels->GetByChannelID(event->ChannelID()); +#else const cChannel *channel = Channels.GetByChannelID(event->ChannelID()); +#endif if (channel) activeSubview->SetChannel(channel); } diff --git a/coreengine/viewelement.c b/coreengine/viewelement.c index 466f8cb..b6ae4bc 100644 --- a/coreengine/viewelement.c +++ b/coreengine/viewelement.c @@ -39,10 +39,10 @@ cViewElement::cViewElement(const cViewElement &other) { tokenContainer = NULL; attribs = new cViewElementAttribs(*other.attribs); - for (cAreaNode *node = other.areaNodes.First(); node; node = other.areaNodes.Next(node)) { - if (cArea *a = dynamic_cast(node)) { + for (const cAreaNode *node = other.areaNodes.First(); node; node = other.areaNodes.Next(node)) { + if (cArea *a = dynamic_cast((cAreaNode*)node)) { areaNodes.Add(new cArea(*a)); - } else if (cAreaContainer *ac = dynamic_cast(node)) { + } else if (cAreaContainer *ac = dynamic_cast((cAreaNode*)node)) { areaNodes.Add(new cAreaContainer(*ac)); } } diff --git a/coreengine/viewelementscommon.c b/coreengine/viewelementscommon.c index 0f9c85c..2226b77 100644 --- a/coreengine/viewelementscommon.c +++ b/coreengine/viewelementscommon.c @@ -287,18 +287,27 @@ bool cVeDevices::Parse(bool forced) { else deviceLiveTV = primaryDevice->DeviceNumber(); } - //check currently recording devices - for (cTimer *timer = Timers.First(); timer; timer = Timers.Next(timer)) { - if (!timer->Recording()) { - continue; - } - if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) { - const cDevice *recDevice = RecordControl->Device(); - if (recDevice) { - mutexDevices.Lock(); - if (recDevices) - recDevices[recDevice->DeviceNumber()] = true; - mutexDevices.Unlock(); + // check currently recording devices + // BLOCK for LOCK_TIMERS_READ scope !! + { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_READ; + const cTimers* timers = Timers; +#else + const cTimers* timers = &Timers; +#endif + for (const cTimer *timer = timers->First(); timer; timer = timers->Next(timer)) { + if (!timer->Recording()) { + continue; + } + if (cRecordControl *RecordControl = cRecordControls::GetRecordControl(timer)) { + const cDevice *recDevice = RecordControl->Device(); + if (recDevice) { + mutexDevices.Lock(); + if (recDevices) + recDevices[recDevice->DeviceNumber()] = true; + mutexDevices.Unlock(); + } } } } diff --git a/coreengine/viewelementsdisplaychannel.c b/coreengine/viewelementsdisplaychannel.c index 1ade883..d104ef8 100644 --- a/coreengine/viewelementsdisplaychannel.c +++ b/coreengine/viewelementsdisplaychannel.c @@ -91,9 +91,16 @@ void cVeDcChannelGroup::Set(const cChannel *c) { } const char *cVeDcChannelGroup::GetChannelSep(const cChannel *c, bool prev) { - const cChannel *sep = prev ? Channels.Prev(c) : - Channels.Next(c); - for (; sep; (prev)?(sep = Channels.Prev(sep)):(sep = Channels.Next(sep))) { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + const cChannels* channels = &Channels; +#endif + const cChannel *sep = prev ? channels->Prev(c) : + channels->Next(c); + + for (; sep; (prev)?(sep = channels->Prev(sep)):(sep = channels->Next(sep))) { if (sep->GroupSep()) { return sep->Name(); } @@ -169,7 +176,17 @@ void cVeDcEpgInfo::Close(void) { bool cVeDcEpgInfo::EventHasTimer(const cEvent *e) { if (!e) return false; - cGlobalSortedTimers SortedTimers;// local and remote timers + int timerCount = 0; + // BLOCK for LOCK_TIMERS_READ scope !! + { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_READ; + timerCount = Timers->Count(); +#else + timerCount = Timers.Count(); +#endif + } + cGlobalSortedTimers SortedTimers(timerCount); // local and remote timers bool hasTimer = e->HasTimer(); for (int i = 0; i < SortedTimers.Size() && !hasTimer; i++) if (const cTimer *Timer = SortedTimers[i]) @@ -311,7 +328,17 @@ void cVeDcStatusInfo::Set(const cChannel *c) { bool isDolby = c->Dpid(0); bool isEncrypted = c->Ca(); bool isRecording = cRecordControls::Active(); - cGlobalSortedTimers SortedTimers;// local and remote timers + int timerCount = 0; + // BLOCK for LOCK_TIMERS_READ scope !! + { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_READ; + timerCount = Timers->Count(); +#else + timerCount = Timers.Count(); +#endif + } + cGlobalSortedTimers SortedTimers(timerCount); // local and remote timers for (int i = 0; i < SortedTimers.Size() && !isRecording; i++) if (const cTimer *Timer = SortedTimers[i]) if (Timer->Recording()) diff --git a/coreengine/viewelementsdisplaymenu.c b/coreengine/viewelementsdisplaymenu.c index f357b22..b08d7a7 100644 --- a/coreengine/viewelementsdisplaymenu.c +++ b/coreengine/viewelementsdisplaymenu.c @@ -351,9 +351,19 @@ void cVeDmTimers::SetTokenContainer(void) { bool cVeDmTimers::Parse(bool forced) { if (!cViewElement::Parse(forced)) return false; - tokenContainer->Clear(); - cGlobalSortedTimers SortedTimers;// local and remote timers + + int timerCount = 0; + // BLOCK for LOCK_TIMERS_READ scope !! + { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_READ; + timerCount = Timers->Count(); +#else + timerCount = Timers.Count(); +#endif + } + cGlobalSortedTimers SortedTimers(timerCount); // local and remote timers int numTimers = SortedTimers.Size(); tokenContainer->AddIntToken((int)eDMTimersIT::numtimers, numTimers); tokenContainer->AddIntToken((int)eDMTimersIT::numtimerconflicts, SortedTimers.NumTimerConfilicts()); @@ -469,8 +479,15 @@ bool cVeDmCurrentschedule::Parse(bool forced) { cDevice *device = cDevice::PrimaryDevice(); const cChannel *channel = NULL; +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + if (!device->Replaying() || device->Transferring()) { - channel = Channels.GetByNumber(device->CurrentChannel()); + channel = channels->GetByNumber(device->CurrentChannel()); } if (channel) { ParseFromChannel(channel); @@ -489,9 +506,17 @@ bool cVeDmCurrentschedule::Parse(bool forced) { void cVeDmCurrentschedule::ParseFromChannel(const cChannel *channel) { const cEvent *event = NULL; - cSchedulesLock SchedulesLock; - if (const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock)) - if (const cSchedule *Schedule = Schedules->GetSchedule(channel)) + +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_SCHEDULES_READ; + const cSchedules* schedules = Schedules; +#else + cSchedulesLock schedulesLock; + const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); +#endif + + if (schedules) + if (const cSchedule *Schedule = schedules->GetSchedule(channel)) event = Schedule->GetPresentEvent(); if (!event) return; @@ -839,20 +864,37 @@ bool cVeDmLastrecordings::Parse(bool forced) { return false; tokenContainer->Clear(); - cGlobalSortedTimers SortedTimers;// local and remote timers - int numTimers = SortedTimers.Size(); + int numTimers = 0; + // BLOCK for LOCK_TIMERS_READ scope !! + { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_READ; + numTimers = Timers->Count(); +#else + numTimers = Timers.Count(); +#endif + } + + cGlobalSortedTimers SortedTimers(numTimers); // local and remote timers //set number of timers so that it is possible to adapt this viewelement accordingly - tokenContainer->AddIntToken((int)eDMLastrecordingsIT::numtimers, numTimers); + tokenContainer->AddIntToken((int)eDMLastrecordingsIT::numtimers, SortedTimers.Size()); - list orderedRecs; + list orderedRecs; - for (cRecording *recording = Recordings.First(); recording; recording = Recordings.Next(recording)) { +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_RECORDINGS_READ; + const cRecordings* recordings = Recordings; +#else + const cRecordings* recordings = &Recordings; +#endif + + for (const cRecording *recording = recordings->First(); recording; recording = recordings->Next(recording)) { if (orderedRecs.size() == 0) { orderedRecs.push_back(recording); continue; } bool inserted = false; - for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { + for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { const cRecording *orderedRec = *it; if (recording->Start() >= orderedRec->Start()) { orderedRecs.insert(it, recording); @@ -876,7 +918,7 @@ bool cVeDmLastrecordings::Parse(bool forced) { tokenContainer->CreateLoopTokenContainer(&loopInfo); int i = 0; - for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { + for (list::iterator it = orderedRecs.begin(); it != orderedRecs.end(); it++) { const cRecording *recording = *it; #if APIVERSNUM >= 20101 if (recording->IsInUse()) { @@ -1000,7 +1042,13 @@ bool cVeDmDetailheaderEpg::Parse(bool forced) { tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::year, sStartTime->tm_year + 1900); tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::daynumeric, sStartTime->tm_mday); tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::month, sStartTime->tm_mon+1); - const cChannel *channel = Channels.GetByChannelID(event->ChannelID()); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(event->ChannelID()); if (channel) { tokenContainer->AddStringToken((int)eDmDetailedHeaderEpgST::channelname, channel->Name()); tokenContainer->AddIntToken((int)eDmDetailedHeaderEpgIT::channelnumber, channel->Number()); @@ -1132,7 +1180,13 @@ bool cVeDmDetailheaderRec::Parse(bool forced) { tokenContainer->AddIntToken((int)eDmDetailedHeaderRecIT::durationeventhours, duration / 60); tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::durationeventminutes, *cString::sprintf("%.2d", duration%60)); } - cChannel *channel = Channels.GetByChannelID(info->ChannelID()); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(info->ChannelID()); if (channel) { tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelname, channel->Name()); tokenContainer->AddStringToken((int)eDmDetailedHeaderRecST::recchannelid, *channel->GetChannelID().ToString()); diff --git a/extensions/imagecache.c b/extensions/imagecache.c index d8c89c8..fc05f5f 100644 --- a/extensions/imagecache.c +++ b/extensions/imagecache.c @@ -56,13 +56,20 @@ void cImageCache::CacheLogo(int width, int height) { return; if (width == 0 || height == 0) return; - + +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + const cChannels* channels = &Channels; +#endif + int logosCached = 0; if (config.numLogosMax && config.numLogosMax < (int)channelLogoCache.size()) return; - for (const cChannel *channel = Channels.First(); channel; channel = Channels.Next(channel)) { + for (const cChannel *channel = channels->First(); channel; channel = channels->Next(channel)) { if (logosCached >= config.numLogosPerSizeInitial) break; if (channel->GroupSep()) { @@ -97,7 +104,13 @@ cImage *cImageCache::GetLogo(string channelID, int width, int height) { return (cImage*)hit->second; } else { tChannelID chanID = tChannelID::FromString(channelID.c_str()); - const cChannel *channel = Channels.GetByChannelID(chanID); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(chanID); if (!channel) return NULL; bool success = LoadLogo(channel); @@ -151,7 +164,13 @@ cImage *cImageCache::GetSeparatorLogo(string name, int width, int height) { bool cImageCache::LogoExists(string channelID) { tChannelID chanID = tChannelID::FromString(channelID.c_str()); - const cChannel *channel = Channels.GetByChannelID(chanID); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_CHANNELS_READ; + const cChannels* channels = Channels; +#else + cChannels* channels = &Channels; +#endif + const cChannel *channel = channels->GetByChannelID(chanID); if (!channel) return false; string logoLower = StrToLowerCase(channel->Name()); diff --git a/extensions/recfolderinfo.c b/extensions/recfolderinfo.c index d03ed6c..5f71354 100644 --- a/extensions/recfolderinfo.c +++ b/extensions/recfolderinfo.c @@ -13,7 +13,7 @@ private: int _count; cString _latestFileName; - void UpdateData(cRecording *Recording); + void UpdateData(const cRecording *Recording); cFolderInfoIntern *FindSubFolder(const char *Name) const; public: @@ -24,7 +24,7 @@ public: // if "Add", missing folders are created cFolderInfoIntern *Find(const char *Name, bool Add); - void Add(cRecording *Recording); + void Add(const cRecording *Recording); cRecordingsFolderInfo::cFolderInfo *GetInfo(void) const; @@ -44,9 +44,8 @@ cRecordingsFolderInfo::cFolderInfo::cFolderInfo(const char *Name, const char *Fu } -cRecordingsFolderInfo::cRecordingsFolderInfo(cRecordings &Recordings) -:_recordings(Recordings) -,_root(NULL) +cRecordingsFolderInfo::cRecordingsFolderInfo() + : _root(NULL) { Rebuild(); } @@ -59,44 +58,70 @@ cRecordingsFolderInfo::~cRecordingsFolderInfo(void) void cRecordingsFolderInfo::Rebuild(void) { - delete _root; - _root = new cFolderInfoIntern(NULL, ""); + cFolderInfoIntern *info; + + delete _root; + _root = new cFolderInfoIntern(NULL, ""); + +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_RECORDINGS_READ; + const cRecordings* recordings = Recordings; + + for (const cRecording *rec = recordings->First(); rec; rec = recordings->Next(rec)) + { + info = _root->Find(rec->Folder(), true); + info->Add(rec); + } +#else + cString folder; + cThreadLock RecordingsLock(&Recordings); + + // re-get state with lock held + + Recordings.StateChanged(_recState); + + for (cRecording *rec = Recordings.First(); rec; rec = Recordings.Next(rec)) + { +# if APIVERSNUM < 20102 - cThreadLock RecordingsLock(&_recordings); - // re-get state with lock held - _recordings.StateChanged(_recState); - cFolderInfoIntern *info; - cString folder; - for (cRecording *rec = _recordings.First(); rec; rec = _recordings.Next(rec)) { -#if APIVERSNUM < 20102 - //cRecording::Folder() first available since VDR 2.1.2 const char *recName = rec->Name(); - if (const char *s = strrchr(recName, FOLDERDELIMCHAR)) { + if (const char *s = strrchr(recName, FOLDERDELIMCHAR)) + { folder = recName; folder.Truncate(s - recName); - } + } else folder = ""; -#else +# else folder = rec->Folder(); -#endif +# endif info = _root->Find(*folder, true); info->Add(rec); } +#endif } cRecordingsFolderInfo::cFolderInfo *cRecordingsFolderInfo::Get(const char *Folder) { - cMutexLock lock(&_rootLock); - - if (_recordings.StateChanged(_recState) || (_root == NULL)) - Rebuild(); - - cFolderInfoIntern *info = _root->Find(Folder, false); - if (info == NULL) - return NULL; - - return info->GetInfo(); + cMutexLock lock(&_rootLock); + +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + static cStateKey recordingsKey; + const cRecordings* recordings = cRecordings::GetRecordingsRead(recordingsKey); + int recStateChanged = recordings != 0; + if (recordings) recordingsKey.Remove(); +#else + int recStateChanged = Recordings.StateChanged(_recState); +#endif + + if (recStateChanged || (_root == NULL)) + Rebuild(); + + cFolderInfoIntern *info = _root->Find(Folder, false); + if (info == NULL) + return NULL; + + return info->GetInfo(); } cString cRecordingsFolderInfo::DebugOutput(void) const @@ -154,7 +179,7 @@ cRecordingsFolderInfo::cFolderInfoIntern *cRecordingsFolderInfo::cFolderInfoInte return info; } -void cRecordingsFolderInfo::cFolderInfoIntern::UpdateData(cRecording *Recording) +void cRecordingsFolderInfo::cFolderInfoIntern::UpdateData(const cRecording *Recording) { // count every recording _count++; @@ -176,7 +201,7 @@ cRecordingsFolderInfo::cFolderInfoIntern *cRecordingsFolderInfo::cFolderInfoInte return NULL; } -void cRecordingsFolderInfo::cFolderInfoIntern::Add(cRecording *Recording) +void cRecordingsFolderInfo::cFolderInfoIntern::Add(const cRecording *Recording) { if (Recording == NULL) return; diff --git a/extensions/recfolderinfo.h b/extensions/recfolderinfo.h index 8148ea7..6e9f920 100644 --- a/extensions/recfolderinfo.h +++ b/extensions/recfolderinfo.h @@ -9,7 +9,6 @@ public: class cFolderInfoIntern; private: - cRecordings &_recordings; int _recState; cFolderInfoIntern *_root; mutable cMutex _rootLock; @@ -28,7 +27,7 @@ public: cFolderInfo(const char *Name, const char *FullName, time_t Latest, int Count, const char *LatestFileName); }; - cRecordingsFolderInfo(cRecordings &Recordings); + cRecordingsFolderInfo(); ~cRecordingsFolderInfo(void); // caller must delete the cInfo object! @@ -40,4 +39,4 @@ public: cString DebugOutput(void) const; }; -#endif // __RECFOLDERINFO_H \ No newline at end of file +#endif // __RECFOLDERINFO_H diff --git a/extensions/timers.c b/extensions/timers.c index b93aada..4f81b2a 100644 --- a/extensions/timers.c +++ b/extensions/timers.c @@ -6,7 +6,7 @@ static int CompareTimers(const void *a, const void *b) { return (*(const cTimer **)a)->Compare(**(const cTimer **)b); } -cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVector(Timers.Count()) { +cGlobalSortedTimers::cGlobalSortedTimers(int timerCount, bool forceRefresh) : cVector(timerCount) { static bool initial = true; static cRemoteTimerRefresh *remoteTimerRefresh = NULL; localTimer = NULL; @@ -16,8 +16,16 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVector= 20301) + LOCK_TIMERS_READ; + LOCK_SCHEDULES_READ; + const cTimers* timers = Timers; + const cSchedules* schedules = Schedules; +#else + const cTimers* timers = &Timers; + cSchedulesLock schedulesLock; + const cSchedules* schedules = (cSchedules*)cSchedules::Schedules(schedulesLock); +#endif if (pRemoteTimers && initial) { cString errorMsg; @@ -25,7 +33,7 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVectorFirst(); Timer; Timer = timers->Next(Timer)) { if (Timer->HasFlags(tfActive)) Append(Timer); } @@ -34,7 +42,7 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVectorService("RemoteTimers::ForEach-v1.0", &remoteTimer) && remoteTimer != NULL) { - remoteTimer->SetEventFromSchedule(Schedules); // make sure the event is current + remoteTimer->SetEventFromSchedule(schedules); // make sure the event is current if (remoteTimer->HasFlags(tfActive)) Append(remoteTimer); } @@ -50,7 +58,7 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVectorFirst(); Timer; Timer = timers->Next(Timer)) { if (Timer == At(i)) { localTimer[i] = true; break; @@ -109,13 +117,18 @@ cRemoteTimerRefresh::~cRemoteTimerRefresh(void) { } void cRemoteTimerRefresh::Action(void) { - #define REFESH_INTERVALL_MS 30000 +#define REFESH_INTERVALL_MS 30000 while (Running()) { - cCondWait::SleepMs(REFESH_INTERVALL_MS); - if (!cOsd::IsOpen()) {//make sure that no timer is currently being edited + cCondWait::SleepMs(REFESH_INTERVALL_MS); + // make sure that no timer is currently being edited + if (!cOsd::IsOpen()) { cGlobalSortedTimers(true); +#if defined (APIVERSNUM) && (APIVERSNUM >= 20301) + LOCK_TIMERS_WRITE; + Timers->SetModified(); +#else Timers.SetModified(); +#endif } } } - \ No newline at end of file diff --git a/extensions/timers.h b/extensions/timers.h index aba873c..fdbca31 100644 --- a/extensions/timers.h +++ b/extensions/timers.h @@ -8,7 +8,7 @@ class cGlobalSortedTimers : public cVector { private: bool *localTimer; public: - cGlobalSortedTimers(bool forceRefresh = false); + cGlobalSortedTimers(int timerCount, bool forceRefresh = false); virtual ~cGlobalSortedTimers(void); bool IsRemoteTimer(int i); int NumTimerConfilicts(void);