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/roarinterconnect.c

    r5381 r5533  
    7676 printf("\nOptions:\n\n"); 
    7777 
    78  printf("  --server SERVER    - Set server hostname\n" 
    79         "  --remote SERVER    - Set remote server\n" 
    80         "  --type   TYPE      - Set type of remote server\n" 
    81         "  --rate   RATE      - Set sample rate\n" 
    82         "  --bits   BITS      - Set bits per sample\n" 
    83         "  --chans  CHANNELS  - Set number of channels\n" 
    84         "  --codec  CODEC     - Set the codec\n" 
    85         "  --help             - Show this help\n" 
    86         "  --verbose -v       - Be verbose\n" 
     78 printf("  --server SERVER     - Set server hostname\n" 
     79        "  --remote SERVER     - Set remote server\n" 
     80        "  --type   TYPE       - Set type of remote server\n" 
     81        "  --rate  -R RATE     - Set sample rate\n" 
     82        "  --bits  -B BITS     - Set bits per sample\n" 
     83        "  --chans -C CHANNELS - Set number of channels\n" 
     84        "  --codec -E CODEC    - Set the codec\n" 
     85        "  --aiprofile PROFILE - Set audio profile\n" 
     86        "  --help              - Show this help\n" 
     87        "  --verbose -v        - Be verbose\n" 
    8788       ); 
    8889 
    8990 printf("\nPossible Types:\n\n"); 
    90  printf("  roar               - RoarAudio Server\n" 
     91 printf("  roar                - RoarAudio Server\n" 
    9192#ifdef ROAR_HAVE_ESD 
    92         "  esd                - EsounD Server\n" 
    93 #endif 
    94         "  simple             - PulseAudio using simple protocol\n" 
     93        "  esd                 - EsounD Server\n" 
     94#endif 
     95        "  simple              - PulseAudio using simple protocol\n" 
    9596#ifdef _HAVE_OSS 
    96         "  oss                - Open Sound System (OSS) device\n" 
     97        "  oss                 - Open Sound System (OSS) device\n" 
    9798#endif 
    9899#ifdef _HAVE_RSOUND 
    99         "  rsound             - RSound server\n" 
     100        "  rsound              - RSound server\n" 
    100101#endif 
    101102        "\n" 
    102         "  bidir              - Connect bidirectional\n" 
    103         "  filter             - Use local server as filter for remote server\n" 
    104         "  transmit           - Transmit data from local server to remote server\n" 
    105         "  receive            - Receive data from remote server\n" 
    106         "  recplay            - Record from and play data to remote server\n" 
    107         "  record             - Record data from remote server\n" 
     103        "  bidir               - Connect bidirectional\n" 
     104        "  filter              - Use local server as filter for remote server\n" 
     105        "  transmit            - Transmit data from local server to remote server\n" 
     106        "  receive             - Receive data from remote server\n" 
     107        "  recplay             - Record from and play data to remote server\n" 
     108        "  record              - Record data from remote server\n" 
    108109       ); 
    109110 
     
    257258 struct roar_stream     stream[1]; 
    258259 struct roar_vio_calls  vio; 
    259 #ifdef _HAVE_OSS 
    260260 struct roar_audio_info info; 
    261 #endif 
    262261#ifdef _HAVE_RSOUND 
    263262 rsound_t *rd; 
    264263 enum rsd_format fmt = 0; 
    265264#endif 
    266  int    rate     = 44100; 
    267  int    bits     = 16; 
    268  int    channels = 2; 
    269  int    codec    = ROAR_CODEC_DEFAULT; 
    270265 int    type     = parse_type(NULL); 
    271266 int    tmp; 
     
    278273 int    rport; 
    279274 
     275 if ( roar_profile2info(&info, "default") == -1 ) 
     276  return 1; 
     277 
    280278 for (i = 1; i < argc; i++) { 
    281279  k = argv[i]; 
     
    287285  } else if ( strcmp(k, "--type") == 0 ) { 
    288286   type = parse_type(argv[++i]); 
    289   } else if ( strcmp(k, "--rate") == 0 ) { 
    290    rate = roar_str2rate(argv[++i]); 
    291   } else if ( strcmp(k, "--bits") == 0 ) { 
    292    bits = roar_str2bits(argv[++i]); 
    293   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 
    294    channels = roar_str2channels(argv[++i]); 
    295   } else if ( strcmp(k, "--codec") == 0 ) { 
    296    codec = roar_str2codec(argv[++i]); 
     287  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     288   info.rate = roar_str2rate(argv[++i]); 
     289  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     290   info.bits = roar_str2bits(argv[++i]); 
     291  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     292   info.channels = roar_str2channels(argv[++i]); 
     293  } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) { 
     294   info.codec = roar_str2codec(argv[++i]); 
     295  } else if ( !strcmp(k, "--aiprofile") ) { 
     296   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     297    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     298    return 1; 
     299   } 
    297300  } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { 
    298301   g_verbose++; 
     
    339342       return 2; 
    340343    } 
    341     if ( roar_vio_simple_stream(&vio, rate, channels, bits, codec, remote, tmp, CLIENT_NAME, -1) == -1 ) { 
     344    if ( roar_vio_simple_stream(&vio, 
     345                                info.rate, info.channels, info.bits, info.codec, 
     346                                remote, tmp, CLIENT_NAME, -1) == -1 ) { 
    342347     fprintf(stderr, "Error: can not open RoarAudio stream to %s: %s\n", remote, roar_error2str(roar_error)); 
    343348     return 2; 
     
    374379       return 2; 
    375380    } 
    376     info.rate     = rate; 
    377     info.channels = channels; 
    378     info.bits     = bits; 
    379     info.codec    = codec; 
    380381    if ( roar_cdriver_oss(&vio, "OSS", remote, &info, tmp) == -1 ) { 
    381382     fprintf(stderr, "Error: can not open OSS device %s: %s\n", remote, roar_error2str(roar_error)); 
     
    393394    tmp = ESD_STREAM|ESD_PLAY; 
    394395 
    395     switch (bits) { 
     396    switch (info.bits) { 
    396397     case  8: tmp |= ESD_BITS8;  break; 
    397398     case 16: tmp |= ESD_BITS16; break; 
     
    401402    } 
    402403 
    403     switch (channels) { 
     404    switch (info.channels) { 
    404405     case 1: tmp |= ESD_MONO;   break; 
    405406     case 2: tmp |= ESD_STEREO; break; 
     
    410411 
    411412    // TODO: FIXME: this is only true if the esd runs on a LE system,... 
    412     if ( bits == 8 && codec != ROAR_CODEC_PCM_U_LE ) { 
     413    if ( info.bits == 8 && info.codec != ROAR_CODEC_PCM_U_LE ) { 
    413414     fprintf(stderr, "Error: EsounD only supports unsigned PCM in 8 bit mode\n"); 
    414415     return 2; 
    415     } else if ( bits == 16 && codec != ROAR_CODEC_DEFAULT ) { 
     416    } else if ( info.bits == 16 && info.codec != ROAR_CODEC_DEFAULT ) { 
    416417     fprintf(stderr, "Error: EsounD only supports signed PCM in 16 bit mode\n"); 
    417418     return 2; 
     
    420421    switch (type & ST_MASK) { 
    421422     case ST_FILTER: 
    422        rfh = esd_filter_stream(tmp, rate, remote, CLIENT_NAME); 
     423       rfh = esd_filter_stream(tmp, info.rate, remote, CLIENT_NAME); 
    423424      break; 
    424425     case ST_TRANSMIT: 
    425        rfh = esd_play_stream(tmp, rate, remote, CLIENT_NAME); 
     426       rfh = esd_play_stream(tmp, info.rate, remote, CLIENT_NAME); 
    426427       localdir = ROAR_DIR_MONITOR; 
    427428      break; 
    428429     case ST_RECEIVE: 
    429        rfh = esd_monitor_stream(tmp, rate, remote, CLIENT_NAME); 
     430       rfh = esd_monitor_stream(tmp, info.rate, remote, CLIENT_NAME); 
    430431       localdir = ROAR_DIR_PLAY; 
    431432      break; 
     
    439440#ifdef _HAVE_RSOUND 
    440441  case MT_RSOUND: 
    441     fmt = para2rsdfmt(bits, codec); 
     442    fmt = para2rsdfmt(info.bits, info.codec); 
    442443 
    443444    if ( fmt == 0 ) { 
     
    452453       rsd_init(&rd); 
    453454       rsd_set_param(rd, RSD_HOST,       remote); 
    454        rsd_set_param(rd, RSD_CHANNELS,   &channels); 
    455        rsd_set_param(rd, RSD_SAMPLERATE, &rate); 
     455       tmp = info.channels; 
     456       rsd_set_param(rd, RSD_CHANNELS,   &tmp); 
     457       tmp = info.rate; 
     458       rsd_set_param(rd, RSD_SAMPLERATE, &tmp); 
    456459       rsd_set_param(rd, RSD_FORMAT,     &fmt); 
    457460#ifdef RSD_IDENTITY 
     
    526529 } 
    527530 
    528  if ( roar_stream_new(stream, rate, channels, bits, codec) == -1 ) { 
     531 if ( roar_stream_new(stream, info.rate, info.channels, info.bits, info.codec) == -1 ) { 
    529532  roar_disconnect(con); 
    530533  return 21; 
Note: See TracChangeset for help on using the changeset viewer.