Changeset 5065:18cdc8c3a1ab in roaraudio
- Timestamp:
- 06/18/11 04:07:49 (13 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/roarfeatures.h
r5010 r5065 48 48 #define ROAR_FT_FUNC_PANIC 49 49 #define ROAR_FT_FUNC_RESET 50 #define ROAR_FT_FUNC_CLOCK_GETTIME 50 51 #define ROAR_FT_FEATURE_VS 51 52 #define ROAR_FT_FEATURE_VS_FILE -
include/libroar/roartime.h
r5031 r5065 51 51 int roar_get_time (struct roar_connection * con, struct roar_time * time); 52 52 53 int roar_clock_gettime(struct roar_time * rt, int clock); 54 53 55 #endif 54 56 -
include/roaraudio/proto.h
r5031 r5065 195 195 #define ROAR_ITST_UIURL 10 196 196 197 // IDs for diffrent clocks: 198 #define ROAR_CLOCK_DEFAULT -2 199 #define ROAR_CLOCK_UNKNOWN -1 200 #define ROAR_CLOCK_REALTIME 1 201 #define ROAR_CLOCK_MONOTONIC 2 202 #define ROAR_CLOCK_UPTIME 3 203 197 204 // old: do not use. 198 205 struct roar_timeofday { -
libroar/time.c
r5031 r5065 57 57 58 58 if ( time->c_drift == 0 ) { 59 mes->datalen -= 4;59 mes->datalen -= 8; 60 60 if ( time->c_freq == 0 ) { 61 mes->datalen -= 4;61 mes->datalen -= 8; 62 62 if ( time->t_ssec == 0 ) { 63 mes->datalen -= 4;63 mes->datalen -= 8; 64 64 } 65 65 } … … 140 140 } 141 141 142 int roar_clock_gettime(struct roar_time * rt, int clock) { 143 #ifdef ROAR_HAVE_GETTIMEOFDAY 144 struct timeval tv; 145 #elif defined(ROAR_HAVE_TIME) 146 time_t now; 147 #endif 148 149 if ( rt == NULL ) { 150 roar_err_set(ROAR_ERROR_FAULT); 151 return -1; 152 } 153 154 memset(rt, 0, sizeof(struct roar_time)); 155 156 if ( clock == ROAR_CLOCK_DEFAULT ) 157 clock = ROAR_CLOCK_REALTIME; 158 159 switch (clock) { 160 case ROAR_CLOCK_REALTIME: 161 #ifdef ROAR_HAVE_GETTIMEOFDAY 162 if ( gettimeofday(&tv, NULL) == -1 ) { 163 roar_err_from_errno(); 164 return -1; 165 } 166 rt->t_sec = tv.tv_sec; 167 rt->t_ssec = (uint64_t)tv.tv_usec * (uint64_t)18446744073709ULL; 168 rt->c_freq = 1000LLU; 169 #elif defined(ROAR_HAVE_TIME) 170 now = time(NULL); 171 rt->t_sec = now; 172 rt->c_freq = 1000000000LLU; 173 #else 174 roar_err_set(ROAR_ERROR_NOTSUP); 175 return -1; 176 #endif 177 return 0; 178 break; 179 } 180 181 roar_err_set(ROAR_ERROR_NOTSUP); 182 return -1; 183 } 184 142 185 //ll -
roarclients/roarctl.c
r5031 r5065 249 249 250 250 if ( roar_get_time(con, &time) == -1 ) { 251 fprintf(stderr, "Error: can not get server time \n");251 fprintf(stderr, "Error: can not get server time: %s\n", roar_error2str(roar_error)); 252 252 return; 253 253 } -
roard/req.c
r5031 r5065 683 683 684 684 int req_on_gettimeofday (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 685 #if defined(ROAR_HAVE_GETTIMEOFDAY) || defined(ROAR_HAVE_TIME)686 685 struct roar_time curtime; 687 #ifdef ROAR_HAVE_GETTIMEOFDAY688 struct timeval tv;689 #elif defined(ROAR_HAVE_TIME)690 time_t now = time(NULL);691 #endif692 686 693 687 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); … … 713 707 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 714 708 715 memset(&curtime, 0, sizeof(curtime)); 716 717 #ifdef ROAR_HAVE_GETTIMEOFDAY 718 if ( gettimeofday(&tv, NULL) == -1 ) 719 return -1; 720 curtime.t_sec = tv.tv_sec; 721 curtime.t_ssec = (uint64_t)tv.tv_usec * (uint64_t)18446744073709ULL; 722 #elif defined(ROAR_HAVE_TIME) 723 curtime.t_sec = now; 724 #endif 709 if ( roar_clock_gettime(&curtime, ROAR_CLOCK_REALTIME) == -1 ) 710 return -1; 725 711 726 712 if ( roar_time_to_msg(mes, &curtime) == -1 ) … … 732 718 733 719 return 0; 734 #else735 return -1;736 #endif737 720 } 738 721
Note: See TracChangeset
for help on using the changeset viewer.