Changeset 5571:b46ece5b30bf in roaraudio for roard/network.c
- Timestamp:
- 07/17/12 15:03:29 (12 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/network.c
r5567 r5571 70 70 71 71 int net_get_new_client (struct roard_listen * lsock) { 72 const struct roard_proto_handle * proto ;72 const struct roard_proto_handle * protohandle; 73 73 int fh; 74 74 int client; … … 79 79 socklen_t addrlen = sizeof(addr); 80 80 int supported = 0; 81 int proto = lsock->proto; 81 82 82 83 if ( roar_vio_ctl(&(lsock->sock), ROAR_VIO_CTL_GET_FH, &socket) == -1 ) { … … 95 96 return -1; 96 97 97 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND 98 if ( lsock->proto == ROAR_PROTO_RSOUND ) { 99 client = emul_rsound_on_connect(fh, lsock); 100 switch (client) { 101 case -1: return -1; break; 102 case -2: return 0; break; 103 default: // TODO: write error handling 104 clients_get(client, &c); 105 fh = c->fh; 106 break; 98 if ( clients_new_from_fh2(fh, lsock->proto, ROAR_BYTEORDER_NETWORK, 1, lsock, (struct sockaddr*)&addr, &addrlen) == -1 ) { 99 if ( roar_vio_open_fh_socket(&vio, fh) == -1 ) { 100 close(fh); 101 return -1; 107 102 } 108 } else { 109 #endif 110 111 client = clients_new(); 112 113 if ( client == -1 ) { 114 ROAR_DBG("net_get_new_client(void) = -1 // can not create new client"); 115 close(fh); 103 roar_vio_close(&vio); 116 104 return -1; 117 105 } 118 119 if ( clients_set_fh(client, fh) == -1 ) {120 ROAR_ERR("net_get_new_client(void): Can not set client's fh");121 122 clients_delete(client);123 close(fh);124 125 ROAR_DBG("net_get_new_client(void) = -1");126 return -1;127 }128 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND129 }130 #endif131 132 if ( clients_get(client, &c) != -1 ) {133 if ( roar_nnode_free(&(c->nnode)) == -1 )134 return -1;135 136 if ( roar_nnode_new_from_sockaddr(&(c->nnode), (struct sockaddr*)&addr, addrlen) == -1 )137 return -1;138 }139 140 ROAR_DBG("net_get_new_client(*): proto=0x%.4x", lsock->proto);141 142 if ( clients_set_proto(client, lsock->proto) == -1 ) {143 ROAR_WARN("net_get_new_client(*): Setting proto(0x%.4x) of client %i failed.", lsock->proto, client);144 return -1;145 }146 147 switch (lsock->proto) {148 case ROAR_PROTO_ROARAUDIO:149 // nothing needed to be done here150 break;151 #ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD152 #ifdef ROAR_HAVE_H_ESD153 case ROAR_PROTO_ESOUND:154 ROAR_DBG("net_get_new_client(*): execing ESD CONNECT command");155 156 if ( roar_vio_open_fh_socket(&vio, fh) == -1 )157 return -1;158 159 ROAR_DBG("net_get_new_client(*): creating VIO OK");160 161 if ( emul_esd_exec_command(client, ESD_PROTO_CONNECT, &vio) == -1 )162 return -1;163 164 ROAR_DBG("net_get_new_client(*): CONNECT execed sucessfully");165 break;166 #endif167 #endif168 #ifndef ROAR_WITHOUT_DCOMP_EMUL_SIMPLE169 case ROAR_PROTO_SIMPLE:170 if ( emul_simple_on_connect(client, lsock) == -1 )171 return -1;172 break;173 #endif174 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RSOUND175 case ROAR_PROTO_RSOUND: // nothing to do here.176 break;177 #endif178 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY179 case ROAR_PROTO_RPLAY: // nothing to do here.180 181 if ( roar_vio_open_fh_socket(&vio, fh) == -1 )182 return -1;183 184 if ( emul_rplay_on_status(client, NULL, &vio, NULL, 0) == -1 )185 return -1;186 break;187 #endif188 default:189 // OS independiend code to close the socket:190 if ( roar_vio_open_fh_socket(&vio, fh) == -1 )191 return -1;192 193 proto = clients_get_protohandle(lsock->proto);194 supported = 0;195 if ( proto != NULL ) {196 switch (proto->type) {197 case ROARD_PROTO_TYPE_BUILDIN:198 //this should not end up here.199 ROAR_WARN("net_get_new_client(lsock=%p): proto(%i) marked as buildin but isn't. BAD.", lsock, lsock->proto);200 supported = 0;201 break;202 case ROARD_PROTO_TYPE_ROARDPROTO:203 supported = 1;204 if ( proto->impl.roardproto.new_client != NULL ) {205 if ( proto->impl.roardproto.new_client(client, &vio, lsock) == -1 ) {206 supported = 0;207 }208 }209 break;210 }211 }212 213 if ( !supported ) {214 clients_delete(client);215 //roar_vio_close(&vio);216 return -1;217 }218 break;219 }220 221 // close(fh);222 106 223 107 return 0;
Note: See TracChangeset
for help on using the changeset viewer.