Changeset 3058:6e387d16a16f in roaraudio


Ignore:
Timestamp:
12/16/09 09:01:13 (14 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added roar_meta_parse_audioinfo()

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • include/libroar/meta.h

    r3051 r3058  
    5151int    roar_meta_intgenre(char * genre); 
    5252 
     53int    roar_meta_parse_audioinfo(struct roar_audio_info * info, char * str); 
     54 
    5355#endif 
    5456 
  • libroar/meta.c

    r3052 r3058  
    560560} 
    561561 
     562int    roar_meta_parse_audioinfo(struct roar_audio_info * info, char * str) { 
     563 char * lc; 
     564 char * cur, * next; 
     565 char * k,   * v; 
     566 
     567 if ( info == NULL || str == NULL ) 
     568  return -1; 
     569 
     570 memset(info, 0, sizeof(struct roar_audio_info)); 
     571 
     572 if ( (lc = strdup(str)) == NULL ) 
     573  return -1; 
     574 
     575 cur = lc; 
     576 
     577 while (cur != NULL) { 
     578  next = strstr(cur, " "); 
     579  if ( next != NULL ) { 
     580   *next = 0; 
     581    next++; 
     582  } 
     583 
     584  k = cur; 
     585  v = strstr(cur, ":"); 
     586 
     587  if ( v != NULL ) { 
     588   *v = 0; 
     589    v++; 
     590  } else { 
     591    v = ""; 
     592  } 
     593 
     594  // we test for the key, unknown keys get ignored. 
     595  if ( !strcasecmp(k, "rate") ) { 
     596   info->rate     = atoi(v); 
     597  } else if ( !strcasecmp(k, "bits") ) { 
     598   info->bits     = atoi(v); 
     599  } else if ( !strcasecmp(k, "channels") ) { 
     600   info->channels = atoi(v); 
     601  } else if ( !strcasecmp(k, "codec") ) { 
     602   info->codec    = roar_str2codec(v); 
     603  } 
     604 
     605  cur = next; 
     606 } 
     607 
     608 free(lc); 
     609 
     610 return 0; 
     611} 
     612 
    562613//ll 
Note: See TracChangeset for help on using the changeset viewer.