Changeset 82:395b9657ca85 in roaraudio
- Timestamp:
- 07/12/08 18:49:34 (16 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
include/libroar/simple.h
r0 r82 9 9 10 10 int roar_simple_stream (int rate, int channels, int bits, int codec, char * server, int dir, char * name); 11 12 int roar_simple_new_stream (struct roar_connection * con, int rate, int channels, int bits, int codec, int dir); 11 13 12 14 int roar_simple_play (int rate, int channels, int bits, int codec, char * server, char * name); -
include/libroar/stream.h
r81 r82 19 19 int roar_stream_exec (struct roar_connection * con, struct roar_stream * s); 20 20 int roar_stream_connect_to (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port); 21 int roar_stream_connect_to_ask (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port); 21 22 22 23 int roar_stream_add_data (struct roar_connection * con, struct roar_stream * s, char * data, size_t len); -
libroar/simple.c
r54 r82 58 58 } 59 59 60 int roar_simple_new_stream (struct roar_connection * con, int rate, int channels, int bits, int codec, int dir) { 61 struct roar_stream s; 62 struct roar_message mes; 63 char file[80]; 64 int fh = -1, listen; 65 static int count = 0; 66 67 sprintf(file, "/tmp/.libroar-simple-stream.%i-%i", getpid(), count++); 68 69 if ( (listen = roar_socket_listen(ROAR_SOCKET_TYPE_UNIX, file, 0)) == -1 ) { 70 return -1; 71 } 72 73 if ( roar_stream_new(&s, rate, channels, bits, codec) == -1 ) { 74 return -1; 75 } 76 77 if ( roar_stream_connect(con, &s, dir) == -1 ) { 78 return -1; 79 } 80 81 if ( roar_stream_connect_to_ask(con, &s, ROAR_SOCKET_TYPE_UNIX, file, 0) != -1 ) { 82 83 if ( (fh = accept(listen, NULL, NULL)) != -1 ) { 84 if ( dir == ROAR_DIR_PLAY ) { 85 shutdown(fh, SHUT_RD); 86 } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { 87 shutdown(fh, SHUT_WR); 88 } 89 } 90 if ( roar_recv_message(con, &mes, NULL) == -1 ) { 91 close(fh); 92 fh = -1; 93 } else if ( mes.cmd != ROAR_CMD_OK ) { 94 close(fh); 95 fh = -1; 96 } 97 } 98 99 close(listen); 100 unlink(file); 101 102 return fh; 103 } 104 60 105 int roar_simple_play(int rate, int channels, int bits, int codec, char * server, char * name) { 61 106 return roar_simple_stream(rate, channels, bits, codec, server, ROAR_DIR_PLAY, name); -
libroar/stream.c
r81 r82 75 75 int roar_stream_connect_to (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) { 76 76 struct roar_message m; 77 78 if ( roar_stream_connect_to_ask(con, s, type, host, port) == -1 ) 79 return -1; 80 81 if ( roar_recv_message(con, &m, NULL) == -1 ) 82 return -1; 83 84 if ( m.cmd == ROAR_CMD_OK ) 85 return 0; 86 return -1; 87 } 88 89 int roar_stream_connect_to_ask (struct roar_connection * con, struct roar_stream * s, int type, char * host, int port) { 90 struct roar_message m; 77 91 int len = 0; 78 92 … … 97 111 m.datalen = len + 4; 98 112 99 if ( roar_ req(con, &m, NULL) == -1 )113 if ( roar_send_message(con, &m, NULL) == -1 ) 100 114 return -1; 101 115 102 if ( m.cmd == ROAR_CMD_OK ) 103 return 0; 104 return -1; 116 return 0; 105 117 } 106 118
Note: See TracChangeset
for help on using the changeset viewer.