added VDR 2.3.1 compatibility

This commit is contained in:
louis
2016-03-13 16:02:26 +01:00
parent ef69fa6b36
commit b40f8c014e
15 changed files with 318 additions and 119 deletions

View File

@@ -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());

View File

@@ -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;

View File

@@ -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
#endif // __RECFOLDERINFO_H

View File

@@ -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
}
}
}

View File

@@ -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);