Changeset 5010:065b9de0acf7 in roaraudio


Ignore:
Timestamp:
05/26/11 09:26:00 (13 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Updated roar_reset() (Closes: #131)

Files:
8 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r4998 r5010  
    11v. 0.4beta7 - ? 
    22        * Updated roar_panic() (Closes: #132) 
     3        * Updated roar_reset() (Closes: #131) 
    34 
    45v. 0.4beta6 - Mon May 23 2011 19:49 CEST 
  • include/libroar/config.h

    r4779 r5010  
    109109struct roar_libroar_config * roar_libroar_get_config(void); 
    110110 
     111int    roar_libroar_reset_config(void); 
     112 
    111113int    roar_libroar_config_parse(char * txt, char * delm); 
    112114 
  • include/libroar/libroar.h

    r4998 r5010  
    201201 
    202202// call this function after we fork/exec()ed or similar. 
    203 int roar_reset(int forked); 
     203enum roar_reset { 
     204 ROAR_RESET_UNKNOWN     = -1, 
     205#define ROAR_RESET_UNKNOWN ROAR_RESET_UNKNOWN 
     206 ROAR_RESET_NONE        =  0, 
     207#define ROAR_RESET_NONE ROAR_RESET_NONE 
     208 ROAR_RESET_ON_FORK     =  1, 
     209#define ROAR_RESET_ON_FORK ROAR_RESET_ON_FORK 
     210 ROAR_RESET_ON_EXIT     =  2, 
     211#define ROAR_RESET_ON_EXIT ROAR_RESET_ON_EXIT 
     212 ROAR_RESET_ON_PRE_EXEC =  3, 
     213#define ROAR_RESET_ON_PRE_EXEC ROAR_RESET_ON_PRE_EXEC 
     214 ROAR_RESET_MEMORY      =  0x81, 
     215#define ROAR_RESET_MEMORY ROAR_RESET_MEMORY 
     216 ROAR_RESET_CONFIG      =  0x82, 
     217#define ROAR_RESET_CONFIG ROAR_RESET_CONFIG 
     218 ROAR_RESET_RANDOMPOOL  =  0x84, 
     219#define ROAR_RESET_RANDOMPOOL ROAR_RESET_RANDOMPOOL 
     220 ROAR_RESET_EOL         = -2 
     221#define ROAR_RESET_EOL ROAR_RESET_EOL 
     222}; 
     223int roar_reset(enum roar_reset what); 
    204224 
    205225// fatal probelms: 
  • include/libroar/memmgr.h

    r5003 r5010  
    4848// those functions are currently not implemeted: 
    4949 
     50int     roar_mm_reset(void); 
     51 
    5052ssize_t roar_mm_sizeof(void * buf); 
    5153 
     
    6163 
    6264#else 
     65#define roar_mm_reset()             (0) 
    6366#define roar_mm_sizeof(ptr)         ((ssize_t)-1) 
    6467#define roar_mm_calloc(nmemb, size) calloc((nmemb), (size)) 
  • include/libroar/roarfeatures.h

    r4998 r5010  
    4747#define ROAR_FT_FUNC_SIMPLE_CONNECT2 
    4848#define ROAR_FT_FUNC_PANIC 
     49#define ROAR_FT_FUNC_RESET 
    4950#define ROAR_FT_FEATURE_VS 
    5051#define ROAR_FT_FEATURE_VS_FILE 
  • libroar/config.c

    r5006 r5010  
    8484 
    8585 return config; 
     86} 
     87 
     88int    roar_libroar_reset_config(void) { 
     89 struct roar_libroar_config * config = roar_libroar_get_config_ptr(); 
     90 
     91 if ( config->codecs.codec != NULL ) { 
     92  roar_mm_free(config->codecs.codec); 
     93  config->codecs.num = 0; 
     94 } 
     95 
     96 return 0; 
    8697} 
    8798 
  • libroar/libroar.c

    r4998 r5010  
    146146} 
    147147 
    148 int roar_reset(int forked) { 
     148int roar_reset(enum roar_reset what) { 
    149149 char c; 
    150150 int i; 
     151 enum roar_reset subsets = ROAR_RESET_NONE; 
    151152 
    152153 roar_err_set(ROAR_ERROR_NONE); 
    153154 
    154  for (i = 0; i < 16; i++) { 
    155   roar_random_gen_nonce(&c, 1); 
    156   roar_random_uint16(); 
    157   roar_random_uint32(); 
    158  } 
    159  
     155 switch (what) { 
     156  case ROAR_RESET_NONE: 
     157    return 0; 
     158   break; 
     159  case ROAR_RESET_UNKNOWN: 
     160  case ROAR_RESET_EOL: 
     161    roar_err_set(ROAR_ERROR_INVAL); 
     162    return -1; 
     163   break; 
     164  case ROAR_RESET_ON_FORK: 
     165    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_RANDOMPOOL; 
     166   break; 
     167  case ROAR_RESET_ON_EXIT: 
     168  case ROAR_RESET_ON_PRE_EXEC: 
     169    subsets |= ROAR_RESET_MEMORY|ROAR_RESET_CONFIG; 
     170   break; 
     171  default: 
     172    if ( what & 0x80 ) { 
     173     subsets |= what; 
     174    } else { 
     175     roar_err_set(ROAR_ERROR_INVAL); 
     176     return -1; 
     177    } 
     178   break; 
     179 } 
     180 
     181 // strip 0x80 so we can easly test on the other bit per subsystem. 
     182 what |= 0x80; 
     183 what -= 0x80; 
     184 
     185 if ( what & ROAR_RESET_MEMORY ) { 
     186  roar_mm_reset(); 
     187 } 
     188 
     189 if ( what & ROAR_RESET_CONFIG ) { 
     190  roar_libroar_reset_config(); 
     191 } 
     192 
     193 if ( what & ROAR_RESET_RANDOMPOOL ) { 
     194  for (i = 0; i < 16; i++) { 
     195   roar_random_gen_nonce(&c, 1); 
     196   roar_random_uint16(); 
     197   roar_random_uint32(); 
     198  } 
     199 } 
     200 
     201 roar_err_set(ROAR_ERROR_NONE); 
    160202 return 0; 
    161203} 
  • libroar/memmgr.c

    r5002 r5010  
    5050 
    5151#ifdef ROAR_USE_MEMMGR 
     52 
     53int     roar_mm_reset(void) { 
     54 // currently this does nothing. 
     55 // we need to free pools and such here later. 
     56 return 0; 
     57} 
     58 
    5259ssize_t roar_mm_sizeof(void * buf) { 
    5360 if ( buf == NULL ) { 
Note: See TracChangeset for help on using the changeset viewer.