Changeset 9:73840ee4793d in roaraudio


Ignore:
Timestamp:
06/18/08 15:15:31 (16 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added some simple hacked code to messure latency in the main loop

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roard/loop.c

    r0 r9  
    66 void ** streams_input = NULL; 
    77 uint32_t pos = 0; 
     8#ifdef MONITOR_LATENCY 
     9 struct timeval         try, ans; 
     10 long int ans_1last = 0, ans_2last = 0, ans_3last = 0; 
     11 
     12 printf("\n\e[s"); 
     13 fflush(stdout); 
     14#endif 
    815 
    916 ROAR_DBG("main_loop(*) = ?"); 
     
    1118 
    1219 while (alive) { 
     20#ifdef MONITOR_LATENCY 
     21 gettimeofday(&try, NULL); 
     22#endif 
     23 
    1324  ROAR_DBG("main_loop(*): looping..."); 
    1425 
     
    4556  pos = ROAR_MATH_OVERFLOW_ADD(pos, ROAR_OUTPUT_BUFFER_SAMPLES); 
    4657  ROAR_DBG("main_loop(*): current pos: %u", pos); 
     58#ifdef MONITOR_LATENCY 
     59 gettimeofday(&ans, NULL); 
     60 
     61 while (ans.tv_sec > try.tv_sec) { 
     62  ans.tv_sec--; 
     63  ans.tv_usec += 1000000; 
     64 } 
     65 ans.tv_usec -= try.tv_usec; 
     66 
     67 if ( pos % 3 ) { 
     68  printf("\e[ucurrent latency: %.3fms  average: %.3fms   ",  ans.tv_usec                               / (double)1000, 
     69                                                            (ans.tv_usec+ans_3last+ans_2last+ans_1last)/ (double)4000); 
     70  fflush(stdout); 
     71 } 
     72 
     73 ans_3last = ans_2last; 
     74 ans_2last = ans_1last; 
     75 ans_1last = ans.tv_usec; 
     76#endif 
    4777 } 
    4878 
Note: See TracChangeset for help on using the changeset viewer.