Changeset 5533:42f48072307c in roaraudio


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)

Files:
14 edited

Legend:

Unmodified
Added
Removed
  • ChangeLog

    r5529 r5533  
    22        * Try use-execed workaround also on UNIX Domain Sockets (Closes: #207) 
    33        * Implemented SHA1 support (Closes: #232) 
     4        * Fixed usage of -R/-B/-C/-E as well as --aiprofile in roarclients 
     5          (Closes: #176) 
    46 
    57v. 1.0beta2 - Wed Jun 06 2012 19:56 CEST 
  • 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 ) 
  • roarclients/roarcat.c

    r5457 r5533  
    3737        "  --bits  -B  BITS      - Set bits per sample\n" 
    3838        "  --chans -C  CHANNELS  - Set number of channels\n" 
    39         "  --codec     CODEC     - Set the codec\n" 
     39        "  --codec -E  CODEC     - Set the codec\n" 
     40        "  --aiprofile PROFILE   - Set audio profile\n" 
    4041        "  --wave                - Use Wave Audio (PCM) as input\n" 
    4142        "  --midi                - Use MIDI Audio as input\n" 
     
    7071 int file_opened = 0; 
    7172 
     73 // TODO: make use of roar_stdin. 
    7274 if ( roar_vio_open_fh(&file, ROAR_STDIN) == -1 ) 
    7375  return 1; 
     
    98100    return 1; 
    99101   } 
     102  } else if ( !strcmp(k, "--aiprofile") ) { 
     103   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     104    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     105    return 1; 
     106   } 
    100107 
    101108  } else if ( !strcmp(k, "--wave") ) { 
  • roarclients/roarcatvio.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 -s 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  struct roar_audio_info info = {.rate = ROAR_RATE_DEFAULT, .bits = ROAR_BITS_DEFAULT, .channels = ROAR_CHANNELS_DEFAULT}; 
    47  int    codec    = -1; 
     47 struct roar_audio_info info = {.rate = ROAR_RATE_DEFAULT, 
     48                                .bits = ROAR_BITS_DEFAULT, 
     49                                .channels = ROAR_CHANNELS_DEFAULT, 
     50                                .codec = ROAR_AUDIO_INFO_INVALID}; 
    4851 int    auinfo_changed = 0; 
    4952 char * server   = NULL; 
     
    6265  } else if ( !strcmp(k, "-n") ) { 
    6366   name = argv[++i]; 
    64   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") ) { 
     67  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) { 
    6568   info.rate = roar_str2rate(argv[++i]); 
    6669   auinfo_changed = 1; 
    67   } else if ( !strcmp(k, "--bits") ) { 
     70  } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) { 
    6871   info.bits = roar_str2bits(argv[++i]); 
    6972   auinfo_changed = 1; 
     
    7174   info.bits = 8; 
    7275   auinfo_changed = 1; 
    73   } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") ) { 
     76  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) { 
    7477   info.channels = roar_str2channels(argv[++i]); 
    7578   auinfo_changed = 1; 
     
    7780   info.channels = 1; 
    7881   auinfo_changed = 1; 
    79   } else if ( !strcmp(k, "--codec") ) { 
    80    codec = roar_str2codec(argv[++i]); 
     82  } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) { 
     83   info.codec = roar_str2codec(argv[++i]); 
     84   auinfo_changed = 1; 
     85  } else if ( !strcmp(k, "--aiprofile") ) { 
     86   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     87    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     88    return 1; 
     89   } 
    8190   auinfo_changed = 1; 
    8291  } else if ( !strcmp(k, "--help") ) { 
     
    92101 } 
    93102 
    94  if ( codec == -1 ) 
    95   codec = ROAR_CODEC_DEFAULT; 
    96  
    97  info.codec = codec; 
     103 if ( info.codec == ROAR_AUDIO_INFO_INVALID ) 
     104  info.codec = ROAR_CODEC_DEFAULT; 
    98105 
    99106 if ( (vss = roar_vs_new(server, name, &err)) == NULL ) { 
  • roarclients/roardtmf.c

    r5381 r5533  
    6868 
    6969 printf("  --server SERVER    - Set server hostname\n" 
    70         "  --rate   RATE      - Set sample rate\n" 
    71 //        "  --bits   BITS      - Set bits per sample\n" 
    72 //        "  --codec  CODEC     - Set the codec\n" 
     70        "  --rate  -R RATE    - Set sample rate\n" 
    7371        "  --help             - Show this help\n" 
    7472       ); 
     
    141139  if ( !strcmp(k, "--server") || !strcmp(k, "-s") ) { 
    142140   server = argv[++i]; 
    143   } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") ) { 
     141  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) { 
    144142   rate = roar_str2rate(argv[++i]); 
    145143  } else if ( !strcmp(k, "--help") ) { 
  • roarclients/roarfilt.c

    r5381 r5533  
    4545 printf("\nOptions:\n\n"); 
    4646 
    47  printf("  --server SERVER    - Set server hostname\n" 
    48         "  --rate   RATE      - Set sample rate\n" 
    49         "  --bits   BITS      - Set bits per sample\n" 
    50         "  --chans  CHANNELS  - Set number of channels\n" 
    51         "  --help             - Show this help\n" 
     47 printf("  --server SERVER     - Set server hostname\n" 
     48        "  --rate  -R RATE     - Set sample rate\n" 
     49        "  --bits  -B BITS     - Set bits per sample\n" 
     50        "  --chans -C CHANNELS - Set number of channels\n" 
     51        "  --aiprofile PROFILE - Set audio profile\n" 
     52        "  --help              - Show this help\n" 
    5253        "\n" 
    53         "  --half             - half the volume\n" 
    54         "  --double           - double the volume\n" 
    55         "  --amp VAL          - Set amplification\n" 
    56         "  --mul VAL          - Set mul\n" 
    57         "  --div VAL          - Set div\n" 
    58 #ifdef ROAR_HAVE_LIBM 
    59         "  --lowpass freq     - lowpass filter (obsolete)\n" 
    60 #endif 
    61         "  --filter  name     - add filter name\n" 
    62         "  --ffreq   freq     - set filter freq\n" 
    63         "  --fmul    mult     - set filter multiplier\n" 
    64         "  --fdiv    div      - set filter divider\n" 
    65         "  --fn      N        - set filter N parameter\n" 
    66         "  --flimit  limit    - set filter limit parameter\n" 
    67         "  --fmode   mode     - set filter mode parameter\n" 
    68         "  --fq      Q        - set filter quality\n" 
     54        "  --half              - half the volume\n" 
     55        "  --double            - double the volume\n" 
     56        "  --amp VAL           - Set amplification\n" 
     57        "  --mul VAL           - Set mul\n" 
     58        "  --div VAL           - Set div\n" 
     59#ifdef ROAR_HAVE_LIBM 
     60        "  --lowpass freq      - lowpass filter (obsolete)\n" 
     61#endif 
     62        "  --filter  name      - add filter name\n" 
     63        "  --ffreq   freq      - set filter freq\n" 
     64        "  --fmul    mult      - set filter multiplier\n" 
     65        "  --fdiv    div       - set filter divider\n" 
     66        "  --fn      N         - set filter N parameter\n" 
     67        "  --flimit  limit     - set filter limit parameter\n" 
     68        "  --fmode   mode      - set filter mode parameter\n" 
     69        "  --fq      Q         - set filter quality\n" 
    6970       ); 
    7071 
     
    176177  } else if ( strcmp(k, "-m") == 0 ) { 
    177178   info.channels = 1; 
     179  } else if ( !strcmp(k, "--aiprofile") ) { 
     180   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     181    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     182    return 1; 
     183   } 
     184   info.codec = ROAR_CODEC_DEFAULT; 
    178185  } else if ( strcmp(k, "--half") == 0 || strcmp(k, "-half") == 0 ) { 
    179186   div *= 2; 
  • 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; 
  • roarclients/roarmon.c

    r5381 r5533  
    3737        "  --bits  -B BITS      - Set bits per sample\n" 
    3838        "  --chans -C CHANNELS  - Set number of channels\n" 
    39         "  --codec    CODEC     - Set the codec\n" 
     39        "  --codec -E CODEC     - Set the codec\n" 
     40        "  --aiprofile PROFILE  - Set audio profile\n" 
    4041        "  --record             - Run in record mode (Wave Audio only)\n" 
    4142        "  --wave               - Output Wave Audio (PCM)\n" 
     
    5455 
    5556int main (int argc, char * argv[]) { 
    56  int    rate     = -1; 
    57  int    bits     = -1; 
    58  int    channels = -1; 
    59  int    codec    = -1; 
     57 struct roar_audio_info info = { 
     58  .rate = ROAR_AUDIO_INFO_INVALID, 
     59  .bits = ROAR_AUDIO_INFO_INVALID, 
     60  .channels = ROAR_AUDIO_INFO_INVALID, 
     61  .codec = ROAR_AUDIO_INFO_INVALID}; 
    6062 int    dir      = ROAR_DIR_MONITOR; 
    6163 int    rel_id   = -1; 
     
    8486   server = argv[++i]; 
    8587  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-r") || !strcmp(k, "-R") ) { 
    86    rate = roar_str2rate(argv[++i]); 
     88   info.rate = roar_str2rate(argv[++i]); 
    8789  } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) { 
    88    bits = roar_str2bits(argv[++i]); 
     90   info.bits = roar_str2bits(argv[++i]); 
    8991  } else if ( !strcmp(k, "-b") ) { 
    90    bits = 8; 
     92   info.bits = 8; 
    9193  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) { 
    92    channels = roar_str2channels(argv[++i]); 
     94   info.channels = roar_str2channels(argv[++i]); 
    9395  } else if ( !strcmp(k, "-m") ) { 
    94    channels = 1; 
    95   } else if ( !strcmp(k, "--codec") ) { 
    96    if ( (codec = roar_str2codec(argv[++i])) == -1 ) { 
     96   info.channels = 1; 
     97  } else if ( !strcmp(k, "--codec") || !strcmp(k, "-E") ) { 
     98   if ( (info.codec = roar_str2codec(argv[++i])) == ROAR_AUDIO_INFO_INVALID ) { 
    9799    fprintf(stderr, "Error: Unknown codec: %s\n", argv[i]); 
     100    return 1; 
     101   } 
     102 
     103  } else if ( !strcmp(k, "--aiprofile") ) { 
     104   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     105    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
    98106    return 1; 
    99107   } 
     
    140148  case ROAR_DIR_MONITOR: 
    141149  case ROAR_DIR_RECORD: 
    142     if ( rate     == -1 ) rate     = ROAR_RATE_DEFAULT; 
    143     if ( bits     == -1 ) bits     = ROAR_BITS_DEFAULT; 
    144     if ( channels == -1 ) channels = ROAR_CHANNELS_DEFAULT; 
    145     if ( codec    == -1 ) codec    = ROAR_CODEC_DEFAULT; 
     150    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_RATE_DEFAULT; 
     151    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_BITS_DEFAULT; 
     152    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_CHANNELS_DEFAULT; 
     153    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DEFAULT; 
    146154   break; 
    147155  case ROAR_DIR_MIDI_OUT: 
    148     if ( rate     == -1 ) rate     = 0; 
    149     if ( bits     == -1 ) bits     = ROAR_MIDI_BITS; 
    150     if ( channels == -1 ) channels = ROAR_MIDI_CHANNELS_DEFAULT; 
    151     if ( codec    == -1 ) codec    = ROAR_CODEC_MIDI; 
     156    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0; 
     157    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_MIDI_BITS; 
     158    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_MIDI_CHANNELS_DEFAULT; 
     159    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_MIDI; 
    152160   break; 
    153161  case ROAR_DIR_LIGHT_OUT: 
    154     if ( rate     == -1 ) rate     = 0; 
    155     if ( bits     == -1 ) bits     = ROAR_LIGHT_BITS; 
    156     if ( channels == -1 ) channels = 0; 
    157     if ( codec    == -1 ) codec    = ROAR_CODEC_DMX512; 
     162    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0; 
     163    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_LIGHT_BITS; 
     164    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = 0; 
     165    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DMX512; 
    158166   break; 
    159167  case ROAR_DIR_COMPLEX_OUT: 
    160     if ( rate     == -1 ) rate     = ROAR_COMPLEX_RATE; 
    161     if ( bits     == -1 ) bits     = ROAR_COMPLEX_BITS; 
    162     if ( channels == -1 ) channels = ROAR_COMPLEX_CHANNELS; 
    163     if ( codec    == -1 ) codec    = ROAR_COMPLEX_CODEC; 
     168    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_COMPLEX_RATE; 
     169    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_COMPLEX_BITS; 
     170    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_COMPLEX_CHANNELS; 
     171    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_COMPLEX_CODEC; 
    164172   break; 
    165173  case ROAR_DIR_RDTCS_OUT: 
    166     if ( rate     == -1 ) rate     = ROAR_RDTCS_RATE; 
    167     if ( bits     == -1 ) bits     = ROAR_RDTCS_BITS; 
    168     if ( channels == -1 ) channels = ROAR_RDTCS_CHANNELS; 
    169     if ( codec    == -1 ) codec    = ROAR_RDTCS_CODEC; 
     174    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = ROAR_RDTCS_RATE; 
     175    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = ROAR_RDTCS_BITS; 
     176    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = ROAR_RDTCS_CHANNELS; 
     177    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_RDTCS_CODEC; 
    170178   break; 
    171179  case ROAR_DIR_RAW_OUT: 
    172180  case ROAR_DIR_THRU: 
    173181  default: 
    174     if ( rate     == -1 ) rate     = 0; 
    175     if ( bits     == -1 ) bits     = 0; 
    176     if ( channels == -1 ) channels = 0; 
    177     if ( codec    == -1 ) codec    = ROAR_CODEC_DEFAULT; 
     182    if ( info.rate      == ROAR_AUDIO_INFO_INVALID ) info.rate     = 0; 
     183    if ( info.bits      == ROAR_AUDIO_INFO_INVALID ) info.bits     = 0; 
     184    if ( info.channels  == ROAR_AUDIO_INFO_INVALID ) info.channels = 0; 
     185    if ( info.codec     == ROAR_AUDIO_INFO_INVALID ) info.codec    = ROAR_CODEC_DEFAULT; 
    178186   break; 
    179187 } 
     
    184192 } 
    185193 
    186  if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 
     194 if ( roar_stream_new(&s, info.rate, info.channels, info.bits, info.codec) == -1 ) { 
    187195  fprintf(stderr, "Error: can not create stream\n"); 
    188196  roar_disconnect(&con); 
  • 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/* 
  • roarclients/roarphone.c

    r5381 r5533  
    114114 
    115115 printf("\nAudio Options:\n\n"); 
    116  printf("  --rate     RATE      - Set sample rate\n" 
    117         "  --bits     BITS      - Set bits per sample\n" 
    118         "  --chans    CHANNELS  - Set number of channels\n" 
     116 printf("  --rate  -R RATE      - Set sample rate\n" 
     117        "  --bits  -B BITS      - Set bits per sample\n" 
     118        "  --chans -C CHANNELS  - Set number of channels\n" 
     119        "  --aiprofile PROFILE  - Set audio profile\n" 
    119120       ); 
    120121 
     
    129130 
    130131 printf("\nCodec Options:\n\n"); 
    131  printf("  --codec   CODEC     - Set the codec\n" 
     132 printf("  --codec -E CODEC     - Set the codec\n" 
    132133        "  --transcode          - Use local transcodeing\n" 
    133134       ); 
     
    436437  } else if ( strcmp(k, "--io-flush") == 0 ) { 
    437438   g_conf.ioflush_interval = atoi(argv[++i]); 
    438   } else if ( strcmp(k, "--rate") == 0 ) { 
     439  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
    439440   info.rate = roar_str2rate(argv[++i]); 
    440   } else if ( strcmp(k, "--bits") == 0 ) { 
     441  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
    441442   info.bits = roar_str2bits(argv[++i]); 
    442   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 
     443  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
    443444   info.channels = roar_str2channels(argv[++i]); 
     445  } else if ( !strcmp(k, "--aiprofile") ) { 
     446   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     447    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     448    return 1; 
     449   } 
    444450 
    445451  } else if ( strcmp(k, "--afi-downmix") == 0 ) { 
     
    459465   g_conf.filter.in.speex_prep_vad = 1; 
    460466 
    461   } else if ( strcmp(k, "--codec") == 0 ) { 
     467  } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) { 
    462468   info.codec = roar_str2codec(argv[++i]); 
    463469 
  • 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; 
  • roarclients/roarshout.c

    r5381 r5533  
    3737 
    3838 printf("    --server SERVER    - Set server hostname\n" 
    39         "    --rate   RATE      - Set sample rate\n" 
    40         "    --bits   BITS      - Set bits per sample\n" 
    41         "    --chans  CHANNELS  - Set number of channels\n" 
    42         "    --codec  CODEC     - Set the codec\n" 
     39        " -R --rate   RATE      - Set sample rate\n" 
     40        " -B --bits   BITS      - Set bits per sample\n" 
     41        " -C --chans  CHANNELS  - Set number of channels\n" 
     42        " -E --codec  CODEC     - Set the codec\n" 
     43        "    --aiprofile PROFILE\n" 
     44        "                       - Set audio profile\n" 
    4345        " -h --help             - Show this help\n" 
    4446        "    --pw-arg           - Password is supplied as argument (default).\n" 
     
    9092int main (int argc, char * argv[]) { 
    9193 enum { ARG, ASK, DSTR } pw_source = ARG; 
    92  int    rate     = 44100; 
    93  int    bits     = 16; 
    94  int    channels = 2; 
    95  int    codec    = ROAR_CODEC_OGG_VORBIS; 
     94 struct roar_audio_info info; 
    9695 char * server   = NULL; 
    9796 char * k; 
     
    113112 char password_buf[128]; 
    114113 
     114 if ( roar_profile2info(&info, "default") == -1 ) 
     115  return 1; 
     116 
     117 info.codec = ROAR_CODEC_OGG_VORBIS; 
     118 
    115119 for (i = 1; i < argc; i++) { 
    116120  k = argv[i]; 
     
    118122  if ( strcmp(k, "--server") == 0 ) { 
    119123   server = argv[++i]; 
    120   } else if ( strcmp(k, "--rate") == 0 ) { 
    121    rate = roar_str2rate(argv[++i]); 
    122   } else if ( strcmp(k, "--bits") == 0 ) { 
    123    bits = roar_str2bits(argv[++i]); 
    124   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 ) { 
    125    channels = roar_str2channels(argv[++i]); 
    126   } else if ( strcmp(k, "--codec") == 0 ) { 
    127    codec = roar_str2codec(argv[++i]); 
     124  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     125   info.rate = roar_str2rate(argv[++i]); 
     126  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     127   info.bits = roar_str2bits(argv[++i]); 
     128  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     129   info.channels = roar_str2channels(argv[++i]); 
     130  } else if ( strcmp(k, "--codec") == 0 || strcmp(k, "-E") == 0 ) { 
     131   info.codec = roar_str2codec(argv[++i]); 
     132  } else if ( !strcmp(k, "--aiprofile") ) { 
     133   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     134    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     135    return 1; 
     136   } 
    128137  } else if ( strcmp(k, "--pw-arg") == 0 ) { 
    129138   pw_source = ARG; 
     
    254263  shout_set_url(shout, s_url); 
    255264 
    256  if ( (vss = roar_vs_new_simple(server, "roarshout", rate, channels, codec, bits, ROAR_DIR_MONITOR, &err)) == NULL ) { 
     265 if ( (vss = roar_vs_new_simple(server, "roarshout", 
     266                                info.rate, info.channels, info.codec, info.bits, 
     267                                ROAR_DIR_MONITOR, &err)) == NULL ) { 
    257268  fprintf(stderr, "Error: can not start monitoring: %s\n", roar_vs_strerr(err)); 
    258269  return 1; 
  • roarclients/roarsin.c

    r5381 r5533  
    7373} 
    7474 
     75static void usage(const char * progname) { 
     76 fprintf(stderr, "Usage: %s [OPTIONS] [FUNCTION]\n", progname); 
     77 
     78 fprintf(stderr, "\nOptions:\n\n"); 
     79 fprintf(stderr, 
     80         "  --help                  - Show this help\n" 
     81         "  --server SERVER         - Set server address\n" 
     82         "  --rate   -R  RATE       - Set sample rate to use\n" 
     83         "  --freq FREQ             - Set frequency (in Hz)\n" 
     84         "  --time TIME             - Set time (in sec)\n" 
     85        ); 
     86 
     87 fprintf(stderr, "\nFunctions:\n\n"); 
     88 fprintf(stderr, 
     89         "  --sin                   - Use Sinus\n" 
     90         "  --rect                  - Use Rectangle\n" 
     91         "  --saw                   - Use Saw\n" 
     92         "  --tri                   - Use Triangle\n" 
     93         "  --trap                  - Use Trap\n" 
     94        ); 
     95} 
     96 
    7597int main (int argc, char * argv[]) { 
     98 const char * server = NULL; 
    7699 int rate     = ROAR_RATE_DEFAULT; 
    77100 int bits     = 16; 
     
    94117  } else if ( !strcmp(argv[i], "--time") ) { 
    95118   length = atof(argv[++i]); 
     119  } else if ( !strcmp(argv[i], "--server") ) { 
     120   server = argv[++i]; 
     121  } else if ( !strcmp(argv[i], "--rate") || !strcmp(argv[i], "-R") ) { 
     122   rate = roar_str2rate(argv[++i]); 
    96123  } else if ( !strcmp(argv[i], "--sin") ) { 
    97124   func   = sin; 
     
    104131  } else if ( !strcmp(argv[i], "--trap") ) { 
    105132   func   = trap; 
     133  } else if ( !strcmp(argv[i], "--help") ) { 
     134   usage(argv[0]); 
     135   return 0; 
    106136  } else { 
     137   usage(argv[0]); 
    107138   return 2; 
    108139  } 
     
    111142 step   = M_PI*2*freq/rate; 
    112143 
    113  if ( (vss = roar_vs_new_playback(NULL, "sine gen", rate, channels, codec, bits, &err)) == NULL ) { 
     144 if ( (vss = roar_vs_new_playback(server, "sine gen", rate, channels, codec, bits, &err)) == NULL ) { 
    114145  fprintf(stderr, "Error: can not open playback: %s\n", roar_vs_strerr(err)); 
    115146  exit(1); 
  • roarclients/roarvumeter.c

    r5381 r5533  
    4545 printf("\nOptions:\n\n"); 
    4646 
    47  printf("  --server  SERVER   - Set server hostname\n" 
    48         "  --rate    RATE     - Set sample rate\n" 
    49         "  --bits    BITS     - Set bits per sample\n" 
    50         "  --chans   CHANNELS - Set number of channels\n" 
    51         "  --samples SAMPLES  - Set number of input samples per block\n" 
    52         "  --pc               - Use percent scale\n" 
    53         "  --db               - Use dB scale\n" 
    54         "  --beat             - Enable beat detection\n" 
    55         "  --lowpass FREQ     - Use lowpass to filter input (-%idB/dec)\n" 
    56         "  --help             - Show this help\n", 
     47 printf("  --server  SERVER    - Set server hostname\n" 
     48        "  --rate  -R RATE     - Set sample rate\n" 
     49        "  --bits  -B BITS     - Set bits per sample\n" 
     50        "  --chans -C CHANS    - Set number of channels\n" 
     51        "  --aiprofile PROFILE - Set audio profile\n" 
     52        "  --samples SAMPLES   - Set number of input samples per block\n" 
     53        "  --pc                - Use percent scale\n" 
     54        "  --db                - Use dB scale\n" 
     55        "  --beat              - Enable beat detection\n" 
     56        "  --lowpass FREQ      - Use lowpass to filter input (-%idB/dec)\n" 
     57        "  --help              - Show this help\n", 
    5758        LOWPASS_ORDER * 20 
    5859       ); 
     
    163164 struct roardsp_filter      * filter; 
    164165 float  lowpass_freq = 0; 
    165  int    rate     = ROAR_RATE_DEFAULT; 
    166  int    bits     = 16; 
    167  int    channels = 2; 
    168  int    codec    = ROAR_CODEC_DEFAULT; 
     166 struct roar_audio_info info; 
    169167 int    samples  = -1; 
    170168 char * server   = NULL; 
     
    174172 int    mode = 0; 
    175173 
     174 if ( roar_profile2info(&info, "default") == -1 ) 
     175  return 1; 
     176 
    176177 for (i = 1; i < argc; i++) { 
    177178  k = argv[i]; 
     
    179180  if ( strcmp(k, "--server") == 0 ) { 
    180181   server = argv[++i]; 
    181   } else if ( strcmp(k, "--rate") == 0 ) { 
    182    rate = roar_str2rate(argv[++i]); 
    183   } else if ( strcmp(k, "--bits") == 0 ) { 
    184    bits = roar_str2bits(argv[++i]); 
    185   } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0) { 
    186    channels = roar_str2channels(argv[++i]); 
     182  } else if ( strcmp(k, "--rate") == 0 || strcmp(k, "-R") == 0 ) { 
     183   info.rate = roar_str2rate(argv[++i]); 
     184  } else if ( strcmp(k, "--bits") == 0 || strcmp(k, "-B") == 0 ) { 
     185   info.bits = roar_str2bits(argv[++i]); 
     186  } else if ( strcmp(k, "--channels") == 0 || strcmp(k, "--chans") == 0 || strcmp(k, "-C") == 0 ) { 
     187   info.channels = roar_str2channels(argv[++i]); 
     188  } else if ( !strcmp(k, "--aiprofile") ) { 
     189   if ( roar_profile2info(&info, argv[++i]) == -1 ) { 
     190    fprintf(stderr, "Error: Can not load audio profile: %s: %s\n", argv[i], roar_error2str(roar_error)); 
     191    return 1; 
     192   } 
    187193  } else if ( strcmp(k, "--samples") == 0 ) { 
    188194   samples = atoi(argv[++i]); 
     
    213219 
    214220 if ( samples == -1 ) 
    215   samples = rate/10; 
     221  samples = info.rate/10; 
    216222 
    217223 if ( roar_simple_connect(&con, server, "roarvumeter") == -1 ) { 
     
    220226 } 
    221227 
    222  if ( roar_vio_simple_new_stream_obj(&stream, &con, &s, rate, channels, bits, codec, ROAR_DIR_MONITOR, -1) == -1) { 
     228 if ( roar_vio_simple_new_stream_obj(&stream, &con, &s, 
     229                                     info.rate, info.channels, info.bits, ROAR_CODEC_DEFAULT, 
     230                                     ROAR_DIR_MONITOR, -1) == -1) { 
    223231  fprintf(stderr, "Error: can not start monetoring\n"); 
    224232  return 1; 
     
    262270 } 
    263271 
    264  vumeter(&re, samples*channels, bits, channels, mode, &fchain); 
     272 vumeter(&re, samples*info.channels, info.bits, info.channels, mode, &fchain); 
    265273 
    266274 printf("\n"); // if the reach this then roard has quited and we should print a newline 
Note: See TracChangeset for help on using the changeset viewer.