XMMS2
|
00001 #include <math.h> 00002 00003 #include "xmmsc/xmmsc_visualization.h" 00004 00005 /* helper functions to convert timestamps */ 00006 00007 double 00008 tv2ts (struct timeval *t) 00009 { 00010 return t->tv_sec + t->tv_usec / 1000000.0; 00011 } 00012 00013 double 00014 net2ts (int32_t* s) 00015 { 00016 return (int32_t)(ntohl (s[0])) + (int32_t)(ntohl (s[1])) / 1000000.0; 00017 } 00018 00019 void 00020 ts2net (int32_t* d, double t) 00021 { 00022 double s, u; 00023 u = modf (t, &s); 00024 d[0] = htonl ((int32_t)s); 00025 d[1] = htonl ((int32_t)(u * 1000000.0)); 00026 } 00027 00028 void 00029 tv2net (int32_t* d, struct timeval *t) 00030 { 00031 d[0] = htonl ((int32_t)t->tv_sec); 00032 d[1] = htonl ((int32_t)t->tv_usec); 00033 }