Changeset 3455:5a26f2fec851 in roaraudio for libroarpulse/channelmap.c


Ignore:
Timestamp:
02/13/10 21:14:01 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

implement pa_channel_map_parse()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • libroarpulse/channelmap.c

    r3422 r3455  
    192192 
    193193/** Parse a channel position list into a channel map structure. \since 0.8.1 */ 
    194 pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s); 
     194pa_channel_map *pa_channel_map_parse(pa_channel_map *map, const char *s) { 
     195 int i; 
     196 char * c; 
     197 size_t len; 
     198 pa_channel_position_t * v; 
     199 
     200 if ( map == NULL ) 
     201  return NULL; 
     202 
     203 map->channels = 0; 
     204 
     205 if ( s == NULL ) 
     206  return map; 
     207 
     208 while (*s != 0) { 
     209  c = strstr(s, ","); 
     210 
     211  if ( c == NULL ) { 
     212   len = strlen(s); 
     213  } else { 
     214   len = c - s; 
     215  } 
     216 
     217  v = &(map->map[map->channels++]); 
     218 
     219  *v = PA_CHANNEL_POSITION_INVALID; 
     220 
     221  for (i = 0; *v != PA_CHANNEL_POSITION_INVALID && _roar_po_chanpos[i].name != NULL; i++) { 
     222   if ( !strncasecmp(_roar_po_chanpos[i].name, s, len) && _roar_po_chanpos[i].name[len] == 0 ) { 
     223    *v = _roar_po_chanpos[i].pos; 
     224   } 
     225  } 
     226 
     227  if ( c == NULL ) { 
     228   break; 
     229  } else { 
     230   s = c + 1; 
     231  } 
     232 } 
     233 
     234 return map; 
     235} 
    195236 
    196237/** Compare two channel maps. Return 1 if both match. */ 
Note: See TracChangeset for help on using the changeset viewer.