Changeset 2242:01acf25aaeb5 in roaraudio


Ignore:
Timestamp:
07/28/09 04:11:29 (15 years ago)
Author:
phi
Branch:
default
Phase:
public
Message:

added --rel-id from roarmon

File:
1 edited

Legend:

Unmodified
Added
Removed
  • roarclients/roarcat.c

    r2241 r2242  
    4141        "  --light               - Use light control input\n" 
    4242        "  --raw                 - Use raw input\n" 
     43        "  --rel-id ID          - Set ID of relative stream\n" 
    4344        "  --help                - Show this help\n" 
    4445       ); 
     
    5253 int    codec    = ROAR_CODEC_DEFAULT; 
    5354 int    dir      = ROAR_DIR_PLAY; 
     55 int    rel_id   = -1; 
    5456 char * server   = NULL; 
    5557 char * k; 
    56  int    fh; 
    5758 int    i; 
    58  int    in = -1; 
    5959 char * name = "roarcat"; 
    60  char buf[BUFSIZE]; 
     60 struct roar_connection    con; 
     61 struct roar_stream        s; 
     62 struct roar_vio_calls     file, stream; 
     63 struct roar_vio_defaults  def; 
     64 int file_opened = 0; 
    6165 
    6266 for (i = 1; i < argc; i++) { 
     
    96100   dir   = ROAR_DIR_RAW_IN; 
    97101 
     102  } else if ( !strcmp(k, "--rel-id") ) { 
     103   rel_id = atoi(argv[++i]); 
     104 
    98105  } else if ( !strcmp(k, "--help") || !strcmp(k, "-h") ) { 
    99106   usage(); 
    100107   return 0; 
    101   } else if ( in == -1 ) { 
    102    if ( (in = open(k, O_RDONLY, 0644)) == -1 ) { 
     108  } else if ( !file_opened ) { 
     109   file_opened = 1; 
     110   if ( roar_vio_open_dstr(&file, k, &def, 1) == -1 ) { 
    103111    fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno)); 
    104112    return 1; 
     
    111119 } 
    112120 
    113  if ( (fh = roar_simple_stream(rate, channels, bits, codec, server, dir, name)) == -1 ) { 
    114   fprintf(stderr, "Error: can not start playback\n"); 
    115   return 1; 
     121 if ( roar_simple_connect(&con, server, "roarmon") == -1 ) { 
     122  fprintf(stderr, "Error: can not connect to server\n"); 
     123  return 10; 
    116124 } 
    117125 
    118  if ( in == -1 ) 
    119   in = ROAR_STDIN; 
     126 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 
     127  fprintf(stderr, "Error: can not create stream\n"); 
     128  roar_disconnect(&con); 
     129  return 20; 
     130 } 
    120131 
    121  while((i = read(in, buf, BUFSIZE))) 
    122   if (write(fh, buf, i) != i) 
    123    break; 
     132 if ( rel_id != -1 ) { 
     133  if ( roar_stream_set_rel_id(&s, rel_id) ) { 
     134   fprintf(stderr, "Error: can not set id or realative stream\n"); 
     135   roar_disconnect(&con); 
     136   return 21; 
     137  } 
     138 } 
    124139 
    125  roar_simple_close(fh); 
     140 if ( roar_stream_connect(&con, &s, dir) == -1 ) { 
     141  fprintf(stderr, "Error: can not connect stream to server\n"); 
     142  roar_disconnect(&con); 
     143  return 11; 
     144 } 
    126145 
    127  close(in); 
     146 if ( roar_stream_exec(&con, &s) == -1 ) { 
     147  fprintf(stderr, "Error: can not exec stream\n"); 
     148  roar_disconnect(&con); 
     149  return 12; 
     150 } 
     151 
     152 if ( roar_get_connection_vio(&con, &stream) == -1 ) { 
     153  fprintf(stderr, "Error: can not get stream vio\n"); 
     154  roar_disconnect(&con); 
     155  return 13; 
     156 } 
     157 
     158 roar_vio_copy_data(&stream, &file); 
     159 
     160 roar_vio_close(&stream); 
     161 roar_vio_close(&file); 
    128162 
    129163 return 0; 
Note: See TracChangeset for help on using the changeset viewer.