Changeset 2242:01acf25aaeb5 in roaraudio
- Timestamp:
- 07/28/09 04:11:29 (15 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarcat.c
r2241 r2242 41 41 " --light - Use light control input\n" 42 42 " --raw - Use raw input\n" 43 " --rel-id ID - Set ID of relative stream\n" 43 44 " --help - Show this help\n" 44 45 ); … … 52 53 int codec = ROAR_CODEC_DEFAULT; 53 54 int dir = ROAR_DIR_PLAY; 55 int rel_id = -1; 54 56 char * server = NULL; 55 57 char * k; 56 int fh;57 58 int i; 58 int in = -1;59 59 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; 61 65 62 66 for (i = 1; i < argc; i++) { … … 96 100 dir = ROAR_DIR_RAW_IN; 97 101 102 } else if ( !strcmp(k, "--rel-id") ) { 103 rel_id = atoi(argv[++i]); 104 98 105 } else if ( !strcmp(k, "--help") || !strcmp(k, "-h") ) { 99 106 usage(); 100 107 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 ) { 103 111 fprintf(stderr, "Error: can not open file: %s: %s\n", k, strerror(errno)); 104 112 return 1; … … 111 119 } 112 120 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; 116 124 } 117 125 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 } 120 131 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 } 124 139 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 } 126 145 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); 128 162 129 163 return 0;
Note: See TracChangeset
for help on using the changeset viewer.