Changeset 2886:a8c07cbd1368 in roaraudio for libroar
- Timestamp:
- 10/10/09 02:01:40 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/config.c
r2884 r2886 74 74 while (next != NULL) { 75 75 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 77 84 if ( next != NULL ) { 78 85 *next = 0; … … 105 112 } 106 113 114 struct 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 107 168 int roar_libroar_set_server(char * server) { 108 169 roar_libroar_get_config_ptr()->server = server;
Note: See TracChangeset
for help on using the changeset viewer.