Changeset 4913:5640b4c00ace in roaraudio


Ignore:
Timestamp:
05/07/11 20:10:37 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_sleep() function

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/libroar.h

    r4896 r4913  
    195195#define ROAR_MIN ROAR_MIN2 
    196196 
    197 void roar_usleep(uint_least32_t t); 
     197int roar_usleep(uint_least32_t t); 
     198int roar_sleep(int t); 
    198199 
    199200#endif 
  • libroar/libroar.c

    r4896 r4913  
    9797} 
    9898 
    99 void roar_usleep(uint_least32_t t) { 
     99int roar_usleep(uint_least32_t t) { 
    100100#ifdef ROAR_TARGET_WIN32 
    101101 Sleep(t/(uint_least32_t)1000); 
     102 return 0; 
    102103#elif defined(ROAR_HAVE_NANOSLEEP) 
    103104 struct timespec tv; 
     
    115116 while (nanosleep(&tv, &left) == -1) 
    116117  memcpy(&tv, &left, sizeof(tv)); 
     118 return 0; 
    117119#elif defined(ROAR_HAVE_USLEEP) 
    118120 usleep(t); 
     121 return 0; 
    119122#else 
    120123 ROAR_ERR("roar_usleep(t=%llu): can not sleep: not implemented", (long long unsigned int)t); 
    121124 roar_strap(ROAR_TRAP_GROUP_LIBROAR, "usleep.not-implemented"); 
    122125 roar_err_set(ROAR_ERROR_NOSYS); 
     126 return -1; 
    123127#endif 
    124128} 
    125129 
     130int roar_sleep(int t) { 
     131 if ( t < 0 ) { 
     132  roar_err_set(ROAR_ERROR_CAUSALITY); 
     133  return -1; 
     134 } 
     135 
     136 while (t) 
     137  t = sleep(t); 
     138 
     139 return 0; 
     140} 
     141 
    126142//ll 
Note: See TracChangeset for help on using the changeset viewer.