Changeset 5533:42f48072307c in roaraudio for roarclients/roarradio.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/roarradio.c

    r5381 r5533  
    3535 printf("\nOptions:\n\n"); 
    3636 
    37  printf("  --server SERVER    - Set server hostname\n" 
    38         "  --rate   RATE      - Set sample rate\n" 
    39         "  --bits   BITS      - Set bits per sample\n" 
    40         "  --chans  CHANNELS  - Set number of channels\n" 
    41         "  --codec  CODEC     - Set the codec\n" 
    42         "  --help             - Show this help\n" 
     37 printf("  --server SERVER      - Set server hostname\n" 
     38        "  --rate  -R RATE      - Set sample rate\n" 
     39        "  --bits  -B BITS      - Set bits per sample\n" 
     40        "  --chans -C CHANNELS  - Set number of channels\n" 
     41        "  --codec -E CODEC     - Set the codec\n" 
     42        "  --aiprofile PROFILE  - Set audio profile\n" 
     43        "  --help               - Show this help\n" 
    4344       ); 
    4445 
     
    5152 
    5253int main (int argc, char * argv[]) { 
    53  int    rate     = 44100; 
    54  int    bits     = 16; 
    55  int    channels = 2; 
    56  int    codec    = ROAR_CODEC_OGG_VORBIS; 
     54 struct roar_audio_info info; 
    5755 char * server   = NULL; 
    5856 char * k; 
     
    6967 ssize_t slen; 
    7068 
     69 if ( roar_profile2info(&info, "default") == -1 ) 
     70  return 1; 
     71 
     72 info.codec = ROAR_CODEC_OGG_VORBIS; 
     73 
    7174 for (i = 1; i < argc; i++) { 
    7275  k = argv[i]; 
     
    7477  if ( strcmp(k, "--server") == 0 ) { 
    7578   server = argv[++i]; 
    76   } else if ( strcmp(k, "--rate") == 0 ) { 
    77    rate = roar_str2rate(argv[++i]); 
    78   } else if ( strcmp(k, "--bits") == 0 ) { 
    79    bits = roar_str2bits(argv[++i]); 
    80   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 
    81    channels = roar_str2channels(argv[++i]); 
    82   } else if ( strcmp(k, "--codec") == 0 ) { 
    83    codec = roar_str2codec(argv[++i]); 
     79  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     80   info.rate = roar_str2rate(argv[++i]); 
     81  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     82   info.bits = roar_str2bits(argv[++i]); 
     83  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     84   info.channels = roar_str2channels(argv[++i]); 
     85  } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) { 
     86   info.codec = roar_str2codec(argv[++i]); 
     87  } else if ( !strcmp(k, "--aiprofile") ) { 
     88   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     89    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     90    return 1; 
     91   } 
    8492  } else if ( strcmp(k, "--help") == 0 ) { 
    8593   usage(); 
     
    206214 } 
    207215 
    208  if ( roar_stream_new(stream, rate, channels, bits, codec) == -1 ) { 
     216 if ( roar_stream_new(stream, info.rate, info.channels, info.bits, info.codec) == -1 ) { 
    209217  roar_disconnect(con); 
    210218  return 1; 
Note: See TracChangeset for help on using the changeset viewer.