Changeset 2886:a8c07cbd1368 in roaraudio


Ignore:
Timestamp:
10/10/09 02:01:40 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added support to get a codec var, corrected small error in config parsing function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroar/config.c

    r2884 r2886  
    7474 while (next != NULL) { 
    7575  k = next; 
    76   next = strstr(next, delm); 
     76 
     77  if ( delm == NULL ) { 
     78   // no delm -> we have only one option 
     79   next = NULL; 
     80  } else { 
     81   next = strstr(next, delm); 
     82  } 
     83 
    7784  if ( next != NULL ) { 
    7885   *next = 0; 
     
    105112} 
    106113 
     114struct roar_libroar_config_codec * roar_libroar_config_codec_get(int codec, int create) { 
     115 struct roar_libroar_config * config = roar_libroar_get_config_ptr(); 
     116 int i; 
     117 int need_new = 1; 
     118 
     119 if ( codec < 0 || create < 0 ) 
     120  return NULL; 
     121 
     122 if ( config->codecs.num == 0 ) { 
     123  // no match case: 
     124  if ( !create ) 
     125   return NULL; 
     126 } else { 
     127  for (i = 0; i < config->codecs.num; i++) { 
     128   if ( config->codecs.codec[i].codec == codec ) 
     129    return &(config->codecs.codec[i]); 
     130   if ( config->codecs.codec[i].codec == -1 ) 
     131    need_new = 0; 
     132  } 
     133 } 
     134 
     135 if ( !create ) 
     136  return NULL; 
     137 
     138 if ( !need_new ) { 
     139  for (i = 0; i < config->codecs.num; i++) { 
     140   if ( config->codecs.codec[i].codec == -1 ) { 
     141    memset(&(config->codecs.codec[i]), 0, sizeof(struct roar_libroar_config_codec)); 
     142    config->codecs.codec[i].codec = codec; 
     143    return &(config->codecs.codec[i]); 
     144   } 
     145  } 
     146 } 
     147 
     148 if ( config->codecs.num == 0 ) { 
     149  config->codecs.codec = malloc(16*sizeof(struct roar_libroar_config_codec)); 
     150 } else { 
     151  config->codecs.codec = realloc(config->codecs.codec, (config->codecs.num+16)*sizeof(struct roar_libroar_config_codec)); 
     152 } 
     153 
     154 if ( config->codecs.codec == NULL ) 
     155  return NULL; 
     156 
     157 memset(&(config->codecs.codec[config->codecs.num]), 0, 16); 
     158 for (i = config->codecs.num; i < (config->codecs.num+16); i++) { 
     159  config->codecs.codec[i].codec = -1; 
     160 } 
     161 
     162 i = config->codecs.num; 
     163 config->codecs.num += 16; 
     164 
     165 return &(config->codecs.codec[i]); 
     166} 
     167 
    107168int    roar_libroar_set_server(char * server) { 
    108169 roar_libroar_get_config_ptr()->server = server; 
Note: See TracChangeset for help on using the changeset viewer.