Changeset 905:2fd9cd5be5ef in roaraudio for roard/loop.c


Ignore:
Timestamp:
11/28/08 22:24:43 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added --sysclocksync

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/loop.c

    r729 r905  
    2525#include "roard.h" 
    2626 
    27 int main_loop (int driver, DRIVER_USERDATA_T driver_inst, struct roar_audio_info * sa) { 
     27int main_loop (int driver, DRIVER_USERDATA_T driver_inst, struct roar_audio_info * sa, int sysclocksync) { 
    2828 void ** streams_input = NULL; 
    2929 int     term = 0; 
    3030 int     streams; 
     31 long int loopc = 0; 
     32 struct timeval         try, ans; 
     33 float  freq; 
    3134#ifdef MONITOR_LATENCY 
    32  struct timeval         try, ans; 
    3335 long int ans_1last = 0, ans_2last = 0, ans_3last = 0; 
    34  long int loopc = 0; 
    3536 
    3637 printf("\n\e[s"); 
     
    4142 alive = 1; 
    4243 g_pos = 0; 
     44 
     45 if ( sysclocksync ) { 
     46  gettimeofday(&try, NULL); 
     47 } 
    4348 
    4449 while (alive) { 
     
    109114 ans_2last = ans_1last; 
    110115 ans_1last = ans.tv_usec; 
    111  loopc++; 
    112116#endif 
     117 
     118  if ( ! (loopc % sysclocksync ) ) { 
     119   gettimeofday(&ans, NULL); 
     120 
     121   while (ans.tv_sec > try.tv_sec) { 
     122    ans.tv_sec--; 
     123    ans.tv_usec += 1000000; 
     124   } 
     125   ans.tv_usec -= try.tv_usec; 
     126 
     127 
     128   freq = (sysclocksync * ROAR_OUTPUT_BUFFER_SAMPLES) / (ans.tv_usec / 1e6); 
     129   printf("SYNC: f_conf=%iHz, f_real=%.2fHz\n", sa->rate, freq); 
     130 
     131//   memcpy(&try, &ans, sizeof(try)); 
     132   gettimeofday(&try, NULL); 
     133  } 
     134 
     135  if ( sysclocksync ) 
     136   loopc++; 
    113137 } 
    114138 
Note: See TracChangeset for help on using the changeset viewer.