Changeset 5949:9528e85ba67c in roaraudio for roarclients/roarcatplay.c


Ignore:
Timestamp:
10/20/13 13:23:36 (11 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

Marked roarcatvio as obsolete. Added all unique features to roarcatplay.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarcatplay.c

    r5823 r5949  
    3333 printf("\nOptions:\n\n"); 
    3434 
    35  printf("  --server SERVER    - Set server hostname\n" 
    36         "  --simple           - Use the simple interface (default)\n" 
    37         "  --verbose          - Use verbose output\n" 
    38         "  --help             - Show this help\n" 
     35 printf("  --server SERVER       - Set server hostname\n" 
     36        "  --simple              - Use the simple interface (default)\n" 
     37        "  --verbose             - Use verbose output\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" 
    3944       ); 
    4045 
     
    4247 
    4348int main (int argc, char * argv[]) { 
     49 struct roar_audio_info info = {.rate = ROAR_RATE_DEFAULT, 
     50                                .bits = ROAR_BITS_DEFAULT, 
     51                                .channels = ROAR_CHANNELS_DEFAULT, 
     52                                .codec = ROAR_AUDIO_INFO_INVALID}; 
     53 int    auinfo_changed = 0; 
    4454 const char * server   = NULL; 
     55 const char * file     = NULL; 
    4556 const char * k; 
    4657 int    i; 
    47  const char * file    = NULL; 
    4858 int    verbose = 0; 
    4959 roar_vs_t * vss; 
     
    5969  } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { 
    6070   verbose++; 
     71  } else if ( strcmp(k, "-n") == 0 ) { 
     72   roar_debug_option_obsolete(argv[0], "-n", NULL, "Will ignore it for now."); 
     73  } else if ( !strcmp(k, "--rate") || !strcmp(k, "-R") ) { 
     74   info.rate = roar_str2rate(argv[++i]); 
     75   auinfo_changed = 1; 
     76  } else if ( !strcmp(k, "--bits") || !strcmp(k, "-B") ) { 
     77   info.bits = roar_str2bits(argv[++i]); 
     78   auinfo_changed = 1; 
     79  } else if ( !strcmp(k, "--channels") || !strcmp(k, "--chans") || !strcmp(k, "-C") ) { 
     80   info.channels = roar_str2channels(argv[++i]); 
     81   auinfo_changed = 1; 
     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   } 
     90   auinfo_changed = 1; 
    6191  } else if ( strcmp(k, "--help") == 0 || strcmp(k, "-h") == 0 ) { 
    6292   usage(); 
     
    74104  file = "fh:stdin"; 
    75105 
    76  if ( (vss = roar_vs_new_from_file(server, "roarcatplay", file, &err)) == NULL ) { 
    77   ROAR_ERR("Can not start playback: %s", roar_error2str(err)); 
    78   return 1; 
     106 if ( info.codec == ROAR_AUDIO_INFO_INVALID ) 
     107  info.codec = ROAR_CODEC_DEFAULT; 
     108 
     109 if ( (vss = roar_vs_new(server, "roarcatplay", &err)) == NULL ) { 
     110  fprintf(stderr, "Error: can not connect to server: %s: %s\n", 
     111   server == NULL ? "(default)" : server, roar_error2str(err)); 
     112  return 10; 
    79113 } 
     114 
     115 if ( auinfo_changed ) { 
     116  if ( roar_vs_stream(vss, &info, ROAR_DIR_PLAY, &err) == -1 ) { 
     117   fprintf(stderr, "Error: can not create new stream: %s\n", roar_error2str(err)); 
     118   roar_vs_close(vss, ROAR_VS_TRUE, NULL); 
     119   return 10; 
     120  } 
     121 } 
     122 
     123 if ( roar_vs_file_simple(vss, file, &err) == -1 ) { 
     124  fprintf(stderr, "Error: can not open file: %s: %s\n", file, roar_error2str(err)); 
     125  roar_vs_close(vss, ROAR_VS_TRUE, NULL); 
     126  return 10; 
     127 } 
     128 
    80129 roar_vs_run(vss, NULL); 
    81130 roar_vs_sync(vss, ROAR_VS_WAIT, NULL); 
Note: See TracChangeset for help on using the changeset viewer.