Changeset 5221:aa6530a03260 in roaraudio for roarclients
- Timestamp:
- 11/12/11 12:25:21 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roarclients/roarcatplay.c
r5109 r5221 35 35 printf(" --server SERVER - Set server hostname\n" 36 36 " --simple - Use the simple interface (default)\n" 37 " --passive - Use passiv playback (experimental, works only localy)\n"38 " --background - Use background playback, impleys passive mode\n"39 37 " --verbose - Use verbose output\n" 40 38 " --help - Show this help\n" … … 43 41 } 44 42 45 #define MODE_SIMPLE 146 #define MODE_PASSIVE 247 48 43 int main (int argc, char * argv[]) { 49 44 char * server = NULL; … … 51 46 int i; 52 47 char * file = NULL; 53 int mode = MODE_SIMPLE;54 int bg = 0;55 48 int verbose = 0; 56 49 roar_vs_t * vss; 57 50 int err; 58 #ifdef ROAR_HAVE_UNIX59 struct roar_connection con[1];60 struct roar_stream stream[1];61 #endif62 51 63 52 for (i = 1; i < argc; i++) { … … 67 56 server = argv[++i]; 68 57 } else if ( strcmp(k, "--simple") == 0 ) { 69 mode = MODE_SIMPLE; 70 } else if ( strcmp(k, "--passive") == 0 ) { 71 mode = MODE_PASSIVE; 72 } else if ( strcmp(k, "--background") == 0 ) { 73 bg = 1; 58 /* no op */ 74 59 } else if ( strcmp(k, "--verbose") == 0 || strcmp(k, "-v") == 0 ) { 75 60 verbose++; … … 86 71 } 87 72 88 if ( bg )89 mode = MODE_PASSIVE;90 91 #ifndef ROAR_HAVE_UNIX92 if ( mode == MODE_PASSIVE ) {93 fprintf(stderr, "Error: passive mode is not supported on this system.\n");94 return 1;95 }96 #endif97 98 if ( mode == MODE_PASSIVE ) {99 fprintf(stderr, "Warning: passive mode is obsoleted and will be removed soon.\n");100 }101 102 73 if ( file == NULL ) 103 74 file = "/dev/stdin"; 104 75 105 #ifdef ROAR_HAVE_UNIX 106 if ( mode == MODE_PASSIVE ) { 107 if ( roar_simple_connect(con, server, "roarcatplay") == -1 ) { 108 ROAR_ERR("Can not connect to server"); 109 return 0; 110 } 111 112 if ( roar_file_play_full(con, file, 0, 1, stream) == -1 ) { 113 ROAR_ERR("Can not start playback"); 114 return 1; 115 } 116 117 if ( bg ) { 118 if ( roar_stream_attach_simple(con, stream, 0) == -1 ) { 119 ROAR_ERR("Can not attach stream to server"); 120 } 121 } else { 122 roar_sleep(10); 123 } 124 125 roar_disconnect(con); 126 127 } else { // MODE_SIMPLE 128 #endif 129 if ( (vss = roar_vs_new_from_file(server, "roarcatplay", file, &err)) == NULL ) { 130 ROAR_ERR("Can not start playback: %s", roar_error2str(err)); 131 return 1; 132 } 133 roar_vs_run(vss, NULL); 134 roar_vs_sync(vss, ROAR_VS_WAIT, NULL); 135 roar_vs_close(vss, ROAR_VS_FALSE, NULL); 136 #ifdef ROAR_HAVE_UNIX 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; 137 79 } 138 #endif 80 roar_vs_run(vss, NULL); 81 roar_vs_sync(vss, ROAR_VS_WAIT, NULL); 82 roar_vs_close(vss, ROAR_VS_FALSE, NULL); 139 83 140 84 return 0;
Note: See TracChangeset
for help on using the changeset viewer.