Changeset 487:a25cdf58b8fe in roaraudio
- Timestamp:
- 08/13/08 17:59:27 (16 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libroar
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/simple.c
r451 r487 69 69 static int count = 0; 70 70 struct group * grp = NULL; 71 int type = ROAR_SOCKET_TYPE_UNIX; 72 int port = 0; 73 struct sockaddr_in socket_addr; 74 socklen_t len = sizeof(struct sockaddr_in); 71 75 72 sprintf(file, "/tmp/.libroar-simple-stream.%i-%i", getpid(), count++); 73 74 if ( (listen = roar_socket_listen(ROAR_SOCKET_TYPE_UNIX, file, 0)) == -1 ) { 76 if ( getsockname(con->fh, (struct sockaddr *)&socket_addr, &len) == -1 ) { 75 77 return -1; 76 78 } 77 79 78 chmod(file, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); 80 if ( socket_addr.sin_family == AF_INET ) { 81 type = ROAR_SOCKET_TYPE_INET; 82 } 79 83 80 grp = getgrnam(ROAR_DEFAULT_SOCKGRP); 84 if ( type == ROAR_SOCKET_TYPE_UNIX ) { 85 sprintf(file, "/tmp/.libroar-simple-stream.%i-%i", getpid(), count++); 86 } else { 87 strcpy(file, inet_ntoa(socket_addr.sin_addr)); 88 } 81 89 82 if ( grp ) 83 chown(file, -1, grp->gr_gid); 90 if ( (listen = roar_socket_listen(type, file, port)) == -1 ) { 91 return -1; 92 } 93 94 if ( type == ROAR_SOCKET_TYPE_INET ) { 95 len = sizeof(struct sockaddr_in); 96 if ( getsockname(listen, (struct sockaddr *)&socket_addr, &len) == -1 ) { 97 return -1; 98 } 99 port = ROAR_NET2HOST16(socket_addr.sin_port); 100 ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port); 101 } 102 103 if ( type == ROAR_SOCKET_TYPE_UNIX ) { 104 chmod(file, S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP); 105 106 grp = getgrnam(ROAR_DEFAULT_SOCKGRP); 107 108 if ( grp ) 109 chown(file, -1, grp->gr_gid); 110 } 84 111 85 112 if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { … … 91 118 } 92 119 93 if ( roar_stream_connect_to_ask(con, s, ROAR_SOCKET_TYPE_UNIX, file, 0) != -1 ) {120 if ( roar_stream_connect_to_ask(con, s, type, file, port) != -1 ) { 94 121 95 122 if ( (fh = accept(listen, NULL, NULL)) != -1 ) { … … 110 137 111 138 close(listen); 112 unlink(file); 139 140 if ( type == ROAR_SOCKET_TYPE_UNIX ) { 141 unlink(file); 142 } 113 143 114 144 return fh; -
libroar/stream.c
r465 r487 93 93 if ( host == NULL ) 94 94 return -1; 95 96 ROAR_DBG("roar_stream_connect_to_ask(*): Ask the server to connect to: %s:%i", host, port); 95 97 96 98 m.cmd = ROAR_CMD_CON_STREAM;
Note: See TracChangeset
for help on using the changeset viewer.