Changeset 5533:42f48072307c in roaraudio for roarclients/roarmonhttp.c


Ignore:
Timestamp:
06/12/12 14:39:40 (12 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Fixed usage of -R/-B/-C/-E as well as --aiprofile in roarclients (Closes: #176)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarmonhttp.c

    r5381 r5533  
    4747        "  --bits  -B  BITS      - Set bits per sample\n" 
    4848        "  --chans -C  CHANNELS  - Set number of channels\n" 
    49         "  --codec     CODEC     - Set the codec\n" 
     49        "  --codec -E  CODEC     - Set the codec\n" 
     50        "  --aiprofile PROFILE   - Set audio profile\n" 
    5051        "  --rel-id ID           - Set ID of relative stream\n" 
    5152        "  --inetd               - Start in inetd mode (STDIN and STDOUT connected to socket)\n" 
     
    231232 
    232233int main (int argc, char * argv[]) { 
    233  int    rate     = 44100; 
    234  int    bits     = 16; 
    235  int    channels = 2; 
    236  int    codec    = ROAR_CODEC_OGG_VORBIS; 
     234 struct roar_audio_info info; 
    237235 int    rel_id   = -1; 
    238236 int    sflags   = ROAR_FLAG_NONE; 
     
    252250#endif 
    253251 
     252 if ( roar_profile2info(&info, "default") == -1 ) 
     253  return 1; 
     254 
     255 info.codec = ROAR_CODEC_OGG_VORBIS; 
     256 
    254257 for (i = 1; i < argc; i++) { 
    255258  k = argv[i]; 
     
    263266  } else if ( !strcmp(k, "--server") ) { 
    264267   roar_libroar_set_server(argv[++i]); 
    265   } else if ( !strcmp(k, "--codec") ) { 
    266    codec = roar_str2codec(argv[++i]); 
     268  } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) { 
     269   info.codec = roar_str2codec(argv[++i]); 
    267270  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) { 
    268    rate = roar_str2rate(argv[++i]); 
     271   info.rate = roar_str2rate(argv[++i]); 
    269272  } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) { 
    270    bits = roar_str2bits(argv[++i]); 
     273   info.bits = roar_str2bits(argv[++i]); 
    271274  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) { 
    272    channels = roar_str2channels(argv[++i]); 
     275   info.channels = roar_str2channels(argv[++i]); 
     276  } else if ( !strcmp(k, "--aiprofile") ) { 
     277   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     278    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     279    return 1; 
     280   } 
    273281  } else if ( !strcmp(k, "--rel-id") ) { 
    274282   rel_id = atoi(argv[++i]); 
     
    294302 
    295303  if ( !strcmp(k, "codec") ) { 
    296    if ( (codec = roar_str2codec(v)) == -1 ) 
     304   if ( (info.codec = roar_str2codec(v)) == ROAR_AUDIO_INFO_INVALID ) 
    297305    return 1; 
    298306  } else if ( !strcmp(k, "channels") ) { 
    299    channels = roar_str2channels(v); 
     307   info.channels = roar_str2channels(v); 
    300308  } else if ( !strcmp(k, "rate") ) { 
    301    rate = roar_str2rate(v); 
     309   info.rate = roar_str2rate(v); 
    302310  } else if ( !strcmp(k, "bits") ) { 
    303    bits = roar_str2bits(v); 
     311   info.bits = roar_str2bits(v); 
     312  } else if ( !strcmp(k, "aiprofile") ) { 
     313   if ( roar_profile2info(&info, v) == -1 ) 
     314    return 1; 
    304315  } else if ( !strcmp(k, "rel-id") || !strcmp(k, "relid") ) { 
    305316   rel_id = atoi(v); 
     
    328339 } 
    329340 
    330  if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 
     341 if ( roar_stream_new(&s, info.rate, info.channels, info.bits, info.codec) == -1 ) { 
    331342  roar_disconnect(&con); 
    332343  return 20; 
     
    361372 
    362373 if ( !gopher ) 
    363   print_header(codec, rate, channels); 
     374  print_header(info.codec, info.rate, info.channels); 
    364375 
    365376/* 
Note: See TracChangeset for help on using the changeset viewer.