Hi,
ein Bug des DLNA-Plugins ist noch, dass das ständige Scannen nach Änderungen dazu führt, dass die CPU-Last sehr hoch ist. Ich versuche das abzudämpfen, in dem ich nur eine Änderung an den Scanner mitteile, wenn die EPG-Events von "jetzt" geändert haben. Aber irgendwie ist das noch nicht das Gelbe vom Ei:
Code
#define SLEEP_TIMEOUT 120
const cSchedules* Schedules;
cSchedule* Schedule;
const cEvent* event;
long now = 0;
bool modified = false;
while(Running()){
event = NULL;
now = time(NULL);
if(!Channels.BeingEdited() && Channels.Modified() > 0){
modified = true;
}
{ // Reduce Scope of Schedules lock.
cSchedulesLock lock;
Schedules = cSchedules::Schedules(lock);
// iterate over all the schedules, find those, which were modified and tell
// it to the media manager. If we found an entry, there's no need to continue searching.
for(Schedule = Schedules->First(); Schedule; Schedule = Schedules->Next(Schedule))
{
// Get the next event of the schedule...
event = Schedule->GetFollowingEvent();
if(event){
// and check if it starts after the last modification and in two minutes from now.
// This causes an update only if there is at least one element in the schedule
// which starts within the next two minutes. Other elements, which will start later,
// will be skipped.
if(event->StartTime() > lastModified && event->StartTime() < now + SLEEP_TIMEOUT){
modified = true;
break;
}
} else if(Schedule->Modified() > lastModified){
modified = true;
break;
}
}
}
if(modified){
OnContainerUpdate(GetRootContainer(), now);
modified = false;
lastModified = now;
}
// Sleep 2 minutes
sleep.Wait(SLEEP_TIMEOUT * 1000);
}
Alles anzeigen
Das geht doch sicher noch besser oder?