diff options
| author | louis <louis.braun@gmx.de> | 2016-03-13 16:02:26 +0100 |
|---|---|---|
| committer | louis <louis.braun@gmx.de> | 2016-03-13 16:02:26 +0100 |
| commit | b40f8c014eb56426188db2e6efca48312458617d (patch) | |
| tree | 09a6f8f39afdbf922191b58e7baefdc30e06ae43 /extensions | |
| parent | ef69fa6b36113f6b3a256b44d4865be3ccc867de (diff) | |
| download | vdr-plugin-skindesigner-b40f8c014eb56426188db2e6efca48312458617d.tar.gz vdr-plugin-skindesigner-b40f8c014eb56426188db2e6efca48312458617d.tar.bz2 | |
added VDR 2.3.1 compatibility
Diffstat (limited to 'extensions')
| -rw-r--r-- | extensions/imagecache.c | 27 | ||||
| -rw-r--r-- | extensions/recfolderinfo.c | 89 | ||||
| -rw-r--r-- | extensions/recfolderinfo.h | 5 | ||||
| -rw-r--r-- | extensions/timers.c | 33 | ||||
| -rw-r--r-- | extensions/timers.h | 2 |
5 files changed, 106 insertions, 50 deletions
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, ""); - - 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 + 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 + 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<const cTimer *>(Timers.Count()) { +cGlobalSortedTimers::cGlobalSortedTimers(int timerCount, bool forceRefresh) : cVector<const cTimer*>(timerCount) { static bool initial = true; static cRemoteTimerRefresh *remoteTimerRefresh = NULL; localTimer = NULL; @@ -16,8 +16,16 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVector<const cTim //check if remotetimers plugin is available static cPlugin* pRemoteTimers = cPluginManager::GetPlugin("remotetimers"); - cSchedulesLock SchedulesLock; - const cSchedules *Schedules = cSchedules::Schedules(SchedulesLock); +#if defined (APIVERSNUM) && (APIVERSNUM >= 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) : cVector<const cTim initial = false; } - for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) { + for (const cTimer *Timer = timers->First(); Timer; Timer = timers->Next(Timer)) { if (Timer->HasFlags(tfActive)) Append(Timer); } @@ -34,7 +42,7 @@ cGlobalSortedTimers::cGlobalSortedTimers(bool forceRefresh) : cVector<const cTim if (pRemoteTimers) { cTimer* remoteTimer = NULL; while (pRemoteTimers->Service("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) : cVector<const cTim localTimer[i] = true; } else { localTimer[i] = false; - for (cTimer *Timer = Timers.First(); Timer; Timer = Timers.Next(Timer)) { + for (const cTimer *Timer = timers->First(); 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<const cTimer *> { private: bool *localTimer; public: - cGlobalSortedTimers(bool forceRefresh = false); + cGlobalSortedTimers(int timerCount, bool forceRefresh = false); virtual ~cGlobalSortedTimers(void); bool IsRemoteTimer(int i); int NumTimerConfilicts(void); |
