|
a/libupnpp/device.cxx |
|
b/libupnpp/device.cxx |
|
... |
|
... |
14 |
* Free Software Foundation, Inc.,
|
14 |
* Free Software Foundation, Inc.,
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
15 |
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
16 |
*/
|
16 |
*/
|
17 |
#include "config.h"
|
17 |
#include "config.h"
|
18 |
|
18 |
|
|
|
19 |
#include <time.h>
|
|
|
20 |
#include <sys/time.h>
|
|
|
21 |
|
19 |
#include <iostream>
|
22 |
#include <iostream>
|
20 |
using namespace std;
|
23 |
using namespace std;
|
21 |
|
24 |
|
22 |
#include "upnpplib.hxx"
|
25 |
#include "upnpplib.hxx"
|
23 |
#include "vdir.hxx"
|
26 |
#include "vdir.hxx"
|
|
... |
|
... |
299 |
int timespec_diffms(const struct timespec& old, const struct timespec& recent)
|
302 |
int timespec_diffms(const struct timespec& old, const struct timespec& recent)
|
300 |
{
|
303 |
{
|
301 |
return (recent.tv_sec - old.tv_sec) * 1000 +
|
304 |
return (recent.tv_sec - old.tv_sec) * 1000 +
|
302 |
(recent.tv_nsec - old.tv_nsec) / (1000 * 1000);
|
305 |
(recent.tv_nsec - old.tv_nsec) / (1000 * 1000);
|
303 |
}
|
306 |
}
|
|
|
307 |
|
|
|
308 |
#ifndef CLOCK_REALTIME
|
|
|
309 |
// Mac OS X for one does not have clock_gettime. Gettimeofday is more than
|
|
|
310 |
// enough for our needs.
|
|
|
311 |
#define CLOCK_REALTIME 0
|
|
|
312 |
int clock_gettime(int /*clk_id*/, struct timespec* t) {
|
|
|
313 |
struct timeval now;
|
|
|
314 |
int rv = gettimeofday(&now, NULL);
|
|
|
315 |
if (rv) return rv;
|
|
|
316 |
t->tv_sec = now.tv_sec;
|
|
|
317 |
t->tv_nsec = now.tv_usec * 1000;
|
|
|
318 |
return 0;
|
|
|
319 |
}
|
|
|
320 |
#endif // ! CLOCK_REALTIME
|
304 |
|
321 |
|
305 |
// Loop on services, and poll each for changed data. Generate event
|
322 |
// Loop on services, and poll each for changed data. Generate event
|
306 |
// only if changed data exists. Every 3 S we generate an artificial
|
323 |
// only if changed data exists. Every 3 S we generate an artificial
|
307 |
// event with all the current state.
|
324 |
// event with all the current state.
|
308 |
void UpnpDevice::eventloop()
|
325 |
void UpnpDevice::eventloop()
|