|
a/libupnpp/device.cxx |
|
b/libupnpp/device.cxx |
|
... |
|
... |
322 |
return 0;
|
322 |
return 0;
|
323 |
}
|
323 |
}
|
324 |
#endif // ! CLOCK_REALTIME
|
324 |
#endif // ! CLOCK_REALTIME
|
325 |
|
325 |
|
326 |
// Loop on services, and poll each for changed data. Generate event
|
326 |
// Loop on services, and poll each for changed data. Generate event
|
327 |
// only if changed data exists. Every 3 S we generate an artificial
|
327 |
// only if changed data exists. Every now and then, we generate an
|
328 |
// event with all the current state.
|
328 |
// artificial event with all the current state.
|
329 |
void UpnpDevice::eventloop()
|
329 |
void UpnpDevice::eventloop()
|
330 |
{
|
330 |
{
|
331 |
int count = 0;
|
331 |
int count = 0;
|
332 |
const int loopwait_ms = 1000; // Polling the services every 1 S
|
332 |
const int loopwait_ms = 1000; // Polling the services every 1 S
|
333 |
const int nloopstofull = 10; // Full state every 10 S
|
333 |
const int nloopstofull = 10; // Full state every 10 S
|
334 |
struct timespec wkuptime, earlytime, lastadvert;
|
334 |
struct timespec wkuptime, earlytime;
|
335 |
bool didearly = false;
|
335 |
bool didearly = false;
|
336 |
|
|
|
337 |
clock_gettime(CLOCK_REALTIME, &lastadvert);
|
|
|
338 |
|
336 |
|
339 |
for (;;) {
|
337 |
for (;;) {
|
340 |
clock_gettime(CLOCK_REALTIME, &wkuptime);
|
338 |
clock_gettime(CLOCK_REALTIME, &wkuptime);
|
341 |
|
|
|
342 |
if (wkuptime.tv_sec - lastadvert.tv_sec > (expiretime / 3)) {
|
|
|
343 |
UpnpSendAdvertisement (m_lib->getdvh(), expiretime);
|
|
|
344 |
lastadvert = wkuptime;
|
|
|
345 |
}
|
|
|
346 |
|
339 |
|
347 |
timespec_addnanos(&wkuptime, loopwait_ms * 1000 * 1000);
|
340 |
timespec_addnanos(&wkuptime, loopwait_ms * 1000 * 1000);
|
348 |
|
341 |
|
349 |
//LOGDEB("eventloop: now " << time(0) << " wkup at "<<
|
342 |
//LOGDEB("eventloop: now " << time(0) << " wkup at "<<
|
350 |
// wkuptime.tv_sec << " S " << wkuptime.tv_nsec << " ns" << endl);
|
343 |
// wkuptime.tv_sec << " S " << wkuptime.tv_nsec << " ns" << endl);
|