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

    r5381 r5533  
    3333 printf("\nOptions:\n\n"); 
    3434 
    35  printf("  --server SERVER    - Set server hostname\n" 
    36         "  --rate   RATE      - Set sample rate\n" 
    37         "  --bits   BITS      - Set bits per sample\n" 
    38         "  --chans  CHANNELS  - Set number of channels\n" 
    39         "  --codec  CODEC     - Set the codec\n" 
    40         "  --help             - Show this help\n" 
     35 printf("  --server SERVER      - Set server hostname\n" 
     36        "  --rate  -R RATE      - Set sample rate\n" 
     37        "  --bits  -B BITS      - Set bits per sample\n" 
     38        "  --chans -C CHANNELS  - Set number of channels\n" 
     39        "  --codec -E CODEC     - Set the codec\n" 
     40        "  --aiprofile PROFILE  - Set audio profile\n" 
     41        "  --help               - Show this help\n" 
    4142       ); 
    4243 
     
    4445 
    4546int main (int argc, char * argv[]) { 
    46  int    rate     = ROAR_RATE_DEFAULT; 
    47  int    bits     = ROAR_BITS_DEFAULT; 
    48  int    channels = ROAR_CHANNELS_DEFAULT; 
    49  int    codec    = ROAR_CODEC_DEFAULT; 
     47 struct roar_audio_info info; 
    5048 char * server   = NULL; 
    5149 char * k; 
     
    6159 ssize_t ret; 
    6260 
     61 if ( roar_profile2info(&info, "default") == -1 ) 
     62  return 1; 
     63 
    6364 if ( roar_vio_dstr_init_defaults(&def, ROAR_VIO_DEF_TYPE_NONE, O_RDONLY, 0644) == -1 ) 
    6465  return 1; 
     
    6970  if ( strcmp(k, "--server") == 0 ) { 
    7071   server = argv[++i]; 
    71   } else if ( strcmp(k, "--rate") == 0 ) { 
    72    rate = roar_str2rate(argv[++i]); 
    73   } else if ( strcmp(k, "--bits") == 0 ) { 
    74    bits = roar_str2bits(argv[++i]); 
    75   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 
    76    channels = roar_str2channels(argv[++i]); 
    77   } else if ( strcmp(k, "--codec") == 0 ) { 
    78    codec = roar_str2codec(argv[++i]); 
     72  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     73   info.rate = roar_str2rate(argv[++i]); 
     74  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     75   info.bits = roar_str2bits(argv[++i]); 
     76  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     77   info.channels = roar_str2channels(argv[++i]); 
     78  } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) { 
     79   info.codec = roar_str2codec(argv[++i]); 
     80  } else if ( !strcmp(k, "--aiprofile") ) { 
     81   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     82    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     83    return 1; 
     84   } 
    7985  } else if ( strcmp(k, "--help") == 0 ) { 
    8086   usage(); 
     
    9399 } 
    94100 
    95  if ( (vss = roar_vs_new_simple(server, "roarbidir", rate, channels, codec, bits, ROAR_DIR_BIDIR, &err)) == NULL ) { 
     101 if ( (vss = roar_vs_new_simple(server, "roarbidir", 
     102                                info.rate, info.channels, info.codec, info.bits, 
     103                                ROAR_DIR_BIDIR, &err)) == NULL ) { 
    96104  fprintf(stderr, "Error: can not start playback: %s\n", roar_error2str(err)); 
    97105  if ( in != NULL ) 
Note: See TracChangeset for help on using the changeset viewer.