Changeset 4896:0cd0dc3bc104 in roaraudio


Ignore:
Timestamp:
04/29/11 15:28:16 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

removed useage of usleep() in flavor to nanosleep() if supported.

Files:
6 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/libroar.h

    r4824 r4896  
    195195#define ROAR_MIN ROAR_MIN2 
    196196 
     197void roar_usleep(uint_least32_t t); 
     198 
    197199#endif 
    198200 
  • libroar/libroar.c

    r4790 r4896  
    9797} 
    9898 
     99void roar_usleep(uint_least32_t t) { 
     100#ifdef ROAR_TARGET_WIN32 
     101 Sleep(t/(uint_least32_t)1000); 
     102#elif defined(ROAR_HAVE_NANOSLEEP) 
     103 struct timespec tv; 
     104 struct timespec left; 
     105 
     106 if ( t > (uint_least32_t)1000000 ) { 
     107  tv.tv_sec  = t/(uint_least32_t)1000000; 
     108  t         -= tv.tv_sec*(uint_least32_t)1000000; 
     109 } else { 
     110  tv.tv_sec  = 0; 
     111 } 
     112 
     113 tv.tv_nsec = t*(uint_least32_t)1000; 
     114 
     115 while (nanosleep(&tv, &left) == -1) 
     116  memcpy(&tv, &left, sizeof(tv)); 
     117#elif defined(ROAR_HAVE_USLEEP) 
     118 usleep(t); 
     119#else 
     120 ROAR_ERR("roar_usleep(t=%llu): can not sleep: not implemented", (long long unsigned int)t); 
     121 roar_strap(ROAR_TRAP_GROUP_LIBROAR, "usleep.not-implemented"); 
     122 roar_err_set(ROAR_ERROR_NOSYS); 
     123#endif 
     124} 
     125 
    99126//ll 
  • libroarpulse/util.c

    r4708 r4896  
    9696/** Wait t milliseconds */ 
    9797int pa_msleep(unsigned long t) { 
    98 #ifdef ROAR_TARGET_WIN32 
    99  Sleep(t); 
    100 #else 
    101  usleep(1000*t); 
    102 #endif 
     98 roar_usleep((uint_least32_t)1000*(uint_least32_t)t); 
    10399 return 0; 
    104100} 
  • roard/driver_sysclock.c

    r4708 r4896  
    113113 
    114114 if ( diff > 0 ) 
    115   usleep(diff); 
     115  roar_usleep(diff); 
    116116 
    117117 return count; 
  • roard/loop.c

    r4820 r4896  
    123123#ifdef ROAR_HAVE_USLEEP 
    124124  if ( g_standby || (streams < 1 && g_autostandby) ) { 
    125    usleep((1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate); 
     125   roar_usleep(((uint_least32_t)1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate); 
    126126   ROAR_DBG("usleep(%u) = ?\n", (1000000 * ROAR_OUTPUT_BUFFER_SAMPLES) / sa->rate); 
    127127  } else { 
  • roard/streams.c

    r4847 r4896  
    24272427 
    24282428#ifdef ROAR_HAVE_USLEEP 
    2429   usleep(100); // 0.1ms 
     2429  roar_usleep(100); // 0.1ms 
    24302430#endif 
    24312431 
Note: See TracChangeset for help on using the changeset viewer.