Changeset 5221:aa6530a03260 in roaraudio
- Timestamp:
- 11/12/11 12:25:21 (12 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
ChangeLog
r5219 r5221 3 3 * Do not set errno to zero in ogg_vorbis codec filter (Closes: #191) 4 4 * Updated data types for struct roar_audio_info (Closes: #189) 5 * Removed old functions from API (Closes: #186) 5 6 6 7 v. 0.4 - Fri Nov 11 2011 20:12 CET -
doc/man1/roarcatplay.1
r3088 r5221 26 26 27 27 .TP 28 \fB--passive\fR29 Use passiv playback (experimental, works only localy)30 31 .TP32 \fB--background\fR33 Use background playback, impleys passive mode34 35 .TP36 28 \fB--verbose\fR 37 29 Use verbose output … … 40 32 \fB--help\fR 41 33 Show this help 34 35 .SH "REMOVED OPTIONS" 36 The following options has been removed: 37 \fB--passive\fR, 38 \fB--background\fR 42 39 43 40 .SH "SEE ALSO" -
include/libroar/file.h
r5109 r5221 45 45 int roar_file_codecdetect(char * buf, int len); 46 46 ssize_t roar_file_send_raw (int out, int in) _LIBROAR_ATTR_DEPRECATED; 47 ssize_t roar_file_play (struct roar_connection * con, char * file, int exec) _LIBROAR_ATTR_DEPRECATED;48 ssize_t roar_file_play_full (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s) _LIBROAR_ATTR_DEPRECATED;49 47 50 48 ssize_t roar_file_map (char * filename, int flags, mode_t mode, size_t len, void ** mem) _LIBROAR_ATTR_DEPRECATED; -
libroar/file.c
r5148 r5221 198 198 199 199 200 ssize_t roar_file_play (struct roar_connection * con, char * file, int exec) {201 return roar_file_play_full(con, file, exec, 0, NULL);202 }203 204 ssize_t roar_file_play_full (struct roar_connection * con, char * file, int exec, int passfh, struct roar_stream * s) {205 #ifdef _CAN_OPERATE206 int codec = -1;207 int in, out = -1;208 ssize_t r = 0;209 int seek;210 int len;211 char buf[BUFFERSIZE];212 int rate = ROAR_RATE_DEFAULT, channels = ROAR_CHANNELS_DEFAULT, bits = ROAR_BITS_DEFAULT;213 struct roar_stream localstream[1];214 215 // FIXME: check error cases216 217 ROAR_DBG("roar_file_play_full(*) = ?");218 219 if ( s == NULL )220 s = localstream;221 222 if ( con == NULL ) {223 roar_err_set(ROAR_ERROR_FAULT);224 return -1;225 }226 227 if ( file == NULL ) {228 roar_err_set(ROAR_ERROR_FAULT);229 return -1;230 }231 232 if ( exec && passfh ) {233 roar_err_set(ROAR_ERROR_INVAL);234 return -1;235 }236 237 #ifdef ROAR_TARGET_WIN32238 if ( (in = open(file, O_RDONLY|O_BINARY, 0644)) == -1 ) {239 #else240 if ( (in = open(file, O_RDONLY, 0644)) == -1 ) {241 #endif242 roar_err_from_errno();243 return -1;244 }245 246 if ((len = read(in, buf, BUFFERSIZE)) < 1) {247 roar_err_from_errno();248 close(in);249 return -1;250 }251 252 codec = roar_file_codecdetect(buf, len);253 254 ROAR_DBG("roar_file_play_full(*): codec=%i(%s)", codec, roar_codec2str(codec));255 256 seek = lseek(in, 0, SEEK_SET) == (off_t) -1 ? 0 : 1;257 258 if ( codec == -1 ) {259 ROAR_WARN("roar_file_play_full(*): Unknown codec of file: %s", file);260 close(in);261 roar_err_set(ROAR_ERROR_BADMAGIC);262 return -1;263 }264 265 if ( passfh && !seek ) {266 ROAR_WARN("roar_file_play_full(*): passfh on non seekable file: this may produce incorrect playback");267 }268 269 if ( exec ) {270 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) {271 ROAR_DBG("roar_file_play_full(*): Can not create new stream. This is realy BAD!");272 close(in);273 return -1;274 }275 276 if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) {277 ROAR_DBG("roar_file_play_full(*): Can not connect new stream to server.");278 close(in);279 return -1;280 }281 282 if ( roar_stream_exec(con, s) == -1 ) {283 ROAR_DBG("roar_file_play_full(*): Can not exec new stream on server.");284 close(in);285 return -1;286 }287 288 roar_libroar_nowarn();289 if ( (out = roar_get_connection_fh(con)) == -1 ) {290 ROAR_DBG("roar_file_play_full(*): Can not get socket of server connection for exec data transmition.");291 close(in);292 roar_libroar_warn();293 return -1;294 }295 roar_libroar_warn();296 297 ROAR_SHUTDOWN(out, SHUT_RD);298 } else {299 if ( !(passfh && seek) ) {300 if ( (out = roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, ROAR_DIR_PLAY)) == -1 ) {301 close(in);302 return -1;303 }304 } else {305 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) {306 close(in);307 return -1;308 }309 310 if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) {311 close(in);312 return -1;313 }314 }315 }316 317 if ( !seek )318 ROAR_NETWORK_WRITE(out, buf, len);319 320 if ( !passfh ) {321 #ifndef ROAR_TARGET_WIN32322 r = roar_file_send_raw(out, in);323 324 close(out);325 #else326 while ((len = read(in, buf, BUFFERSIZE)) > 0)327 if ( send(out, buf, len, 0) != len )328 break;329 330 closesocket(out);331 #endif332 333 if ( exec ) {334 // TODO: FIXME: this ma cause a memory leak in future335 // OLD: con->fh = -1;336 roar_connect_fh(con, -2);337 }338 339 close(in);340 } else {341 if ( roar_stream_passfh(con, s, in) == -1 ) {342 return -1;343 }344 close(out);345 close(in);346 return 0;347 }348 349 return r;350 #else351 roar_err_set(ROAR_ERROR_NOSYS);352 return -1;353 #endif354 }355 356 200 char * roar_cdromdevice (void) { 357 201 char * k; -
libroaryiff/playback.c
r4708 r5221 36 36 #include <libroaryiff.h> 37 37 38 #define BUFFERSIZE 8192 39 40 #ifdef ROAR_HAVE_IO_POSIX 41 #define _CAN_OPERATE 42 #endif 43 38 44 YID YStartPlaySoundObjectSimple (YConnection *con, const char *path) { 39 45 return YStartPlaySoundObject(con, path, NULL); 46 } 47 48 static inline ssize_t _file_play (struct roar_connection * con, const char * file, struct roar_stream * s) { 49 #ifdef _CAN_OPERATE 50 int codec = -1; 51 int in, out = -1; 52 ssize_t r = 0; 53 int seek; 54 int len; 55 char buf[BUFFERSIZE]; 56 int rate = ROAR_RATE_DEFAULT, channels = ROAR_CHANNELS_DEFAULT, bits = ROAR_BITS_DEFAULT; 57 58 // FIXME: check error cases 59 60 ROAR_DBG("roar_file_play_full(*) = ?"); 61 62 #ifdef ROAR_TARGET_WIN32 63 if ( (in = open(file, O_RDONLY|O_BINARY, 0644)) == -1 ) { 64 #else 65 if ( (in = open(file, O_RDONLY, 0644)) == -1 ) { 66 #endif 67 roar_err_from_errno(); 68 return -1; 69 } 70 71 if ((len = read(in, buf, BUFFERSIZE)) < 1) { 72 roar_err_from_errno(); 73 close(in); 74 return -1; 75 } 76 77 codec = roar_file_codecdetect(buf, len); 78 79 ROAR_DBG("roar_file_play_full(*): codec=%i(%s)", codec, roar_codec2str(codec)); 80 81 seek = lseek(in, 0, SEEK_SET) == (off_t) -1 ? 0 : 1; 82 83 if ( codec == -1 ) { 84 ROAR_WARN("roar_file_play_full(*): Unknown codec of file: %s", file); 85 close(in); 86 roar_err_set(ROAR_ERROR_BADMAGIC); 87 return -1; 88 } 89 90 if ( !seek ) { 91 ROAR_WARN("roar_file_play_full(*): passfh on non seekable file: this may produce incorrect playback"); 92 close(in); 93 roar_err_set(ROAR_ERROR_NOSEEK); 94 return -1; 95 } 96 97 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { 98 close(in); 99 return -1; 100 } 101 102 if ( roar_stream_connect2(con, s, ROAR_DIR_PLAY, -1) == -1 ) { 103 close(in); 104 return -1; 105 } 106 107 if ( roar_stream_passfh(con, s, in) == -1 ) { 108 close(in); 109 roar_kick(con, ROAR_OT_STREAM, roar_stream_get_id(s)); 110 return -1; 111 } 112 113 close(out); 114 close(in); 115 return 0; 116 117 return r; 118 #else 119 roar_err_set(ROAR_ERROR_NOSYS); 120 return -1; 121 #endif 40 122 } 41 123 … … 44 126 struct roar_stream stream[1]; 45 127 46 if ( !con)128 if ( con == NULL ) 47 129 return YIDNULL; 48 130 49 if ( !path)131 if ( path == NULL ) 50 132 return YIDNULL; 51 133 … … 56 138 // in background 57 139 58 if ( roar_file_play_full(&rcon, (char*)path, 0, 1, stream) == -1 ) {140 if ( _file_play(&rcon, path, stream) == -1 ) { 59 141 ROAR_ERR("Can not start playback"); 60 142 return YIDNULL; -
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.