Changeset 5031:ebd6fe192503 in roaraudio


Ignore:
Timestamp:
05/28/11 14:23:32 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Added support for ROAR_CMD_GETTIMEOFDAY

Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5022 r5031  
    55        * Updated drivers to use new sync stream selection logic correctly (Closes: #136) 
    66        * Converted most roarclients to to use VS API (See: #87) 
     7        * Added support for ROAR_CMD_GETTIMEOFDAY 
    78 
    89v. 0.4beta6 - Mon May 23 2011 19:49 CEST 
  • include/libroar/libroar.h

    r5010 r5031  
    167167#include "ctl.h" 
    168168#include "caps.h" 
     169#include "roartime.h" 
    169170#include "meta.h" 
    170171#include "file.h" 
  • include/roaraudio/proto.h

    r5029 r5031  
    195195#define ROAR_ITST_UIURL             10 
    196196 
     197// old: do not use. 
    197198struct roar_timeofday { 
    198199 int64_t  t_sec;   // secund part of system time 
  • libroar/Makefile

    r4958 r5031  
    1111PASSWORD=passwordapi.o pinentry.o sshaskpass.o 
    1212CRYPTO=crypto.o random.o $(HASHES) crc.o 
    13 OBJS=libroar.o config.o debug.o error.o basic.o stream.o client.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o $(PASSWORD) $(VIO) stack.o slp.o nnode.o roardl.o roarx11.o beep.o proto.o env.o keyval.o vs.o ltm.o notify.o notify_proxy.o asyncctl.o enumdev.o serverinfo.o $(CRYPTO) authfile.o caps.o roarfloat.o base64.o trap.o memmgr.o 
     13OBJS=libroar.o config.o debug.o error.o basic.o stream.o client.o simple.o auth.o socket.o ctl.o buffer.o meta.o file.o acl.o cdrom.o $(PASSWORD) $(VIO) stack.o slp.o nnode.o roardl.o roarx11.o beep.o proto.o env.o keyval.o vs.o ltm.o notify.o notify_proxy.o asyncctl.o enumdev.o serverinfo.o $(CRYPTO) authfile.o caps.o roarfloat.o base64.o trap.o memmgr.o time.o 
    1414 
    1515#DEFINES        = -DDEBUG 
  • roarclients/roarctl.c

    r5005 r5031  
    123123        "\n" 
    124124        "  serverinfo              - Gets general information about the server\n" 
     125        "  servertime              - Gets server's time\n" 
    125126        "  serveroinfo             - Gets Information about server output\n" 
    126127        "  serveroinfo2 DIR        - Gets Information about server output for stream direction dir\n" 
     
    243244} 
    244245#undef _pm 
     246 
     247void server_time (struct roar_connection * con) { 
     248 struct roar_time time; 
     249 
     250 if ( roar_get_time(con, &time) == -1 ) { 
     251  fprintf(stderr, "Error: can not get server time\n"); 
     252  return; 
     253 } 
     254 
     255 if ( g_verbose ) { 
     256  printf("Server time           : %llu.%06llu [+%llu/2^64] sec\n", 
     257         (long long unsigned int)time.t_sec, 
     258         (long long unsigned int) time.t_ssec / 18446744073709LLU, 
     259         (long long unsigned int) time.t_ssec); 
     260 } else { 
     261  printf("Server time           : %llu.%06llu sec\n", 
     262         (long long unsigned int)time.t_sec, 
     263         (long long unsigned int) time.t_ssec / 18446744073709LLU); 
     264 } 
     265 if ( time.c_freq ) 
     266  printf("Server clock frequency: %f Hz\n", (float)time.c_freq / 1000000000.f); 
     267 if ( time.c_drift ) 
     268  printf("Server clock drift    : %llu:2^64 (~10^%f)\n", 
     269         (long long unsigned int)time.c_drift, logf((float)time.c_drift)/2.302585f); 
     270} 
    245271 
    246272void server_oinfo (struct roar_connection * con, int dir) { 
     
    11411167  } else if ( !strcmp(k, "serverinfo") ) { 
    11421168   server_info(&con); 
     1169  } else if ( !strcmp(k, "servertime") ) { 
     1170   server_time(&con); 
    11431171  } else if ( !strcmp(k, "serveroinfo") ) { 
    11441172   server_oinfo(&con, -1); 
  • roard/commands.c

    r4781 r5031  
    5353  {ROAR_CMD_PASSFH,       _NAME("PASSFH"),       req_on_passfh,       ACCLEV_PWRUSER}, 
    5454 
     55  {ROAR_CMD_GETTIMEOFDAY, _NAME("GETTIMEOFDAY"), req_on_gettimeofday, ACCLEV_NONE}, 
    5556  {ROAR_CMD_SERVER_INFO,  _NAME("SERVER_INFO"),  req_on_server_info,  ACCLEV_NONE},    // allow this early so the client 
    5657                                                                                       // can device ealry if this server 
  • roard/include/req.h

    r4708 r5031  
    5252int req_on_exit        (int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
    5353 
     54int req_on_gettimeofday(int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
    5455int req_on_server_info (int client, struct roar_message * mes, char ** data, uint32_t flags[2]); 
    5556 
  • roard/req.c

    r4949 r5031  
    682682#endif 
    683683 
     684int 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 struct roar_time curtime; 
     687#ifdef ROAR_HAVE_GETTIMEOFDAY 
     688 struct timeval tv; 
     689#elif defined(ROAR_HAVE_TIME) 
     690 time_t now = time(NULL); 
     691#endif 
     692 
     693 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 
     694 
     695 if ( *data != NULL ) { 
     696  return -1; 
     697 } 
     698 
     699 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 
     700 
     701 if ( mes->datalen && mes->datalen < 8 ) { 
     702  return -1; 
     703 } 
     704 
     705 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 
     706 
     707 if ( mes->datalen >= 8 ) { 
     708  if ( *(uint64_t *)mes->data != 0 ) { 
     709   return -1; 
     710  } 
     711 } 
     712 
     713 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 
     714 
     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 
     725 
     726 if ( roar_time_to_msg(mes, &curtime) == -1 ) 
     727  return -1; 
     728 
     729 mes->cmd = ROAR_CMD_OK; 
     730 
     731 ROAR_DBG("req_on_gettimeofday(client=%i, mes=%p, data=%p, flags=%p) = ?", client, mes, data, flags); 
     732 
     733 return 0; 
     734#else 
     735 return -1; 
     736#endif 
     737} 
     738 
    684739int req_on_server_info (int client, struct roar_message * mes, char ** data, uint32_t flags[2]) { 
    685740#ifdef ROAR_HAVE_UNAME 
Note: See TracChangeset for help on using the changeset viewer.