[5115] | 1 | //vio_stream.c: |
---|
| 2 | |
---|
| 3 | /* |
---|
[5961] | 4 | * Copyright (C) Philipp 'ph3-der-loewe' Schafft - 2010-2014 |
---|
[5115] | 5 | * |
---|
| 6 | * This file is part of libroar a part of RoarAudio, |
---|
| 7 | * a cross-platform sound system for both, home and professional use. |
---|
| 8 | * See README for details. |
---|
| 9 | * |
---|
| 10 | * This file is free software; you can redistribute it and/or modify |
---|
| 11 | * it under the terms of the GNU General Public License version 3 |
---|
| 12 | * as published by the Free Software Foundation. |
---|
| 13 | * |
---|
| 14 | * libroar is distributed in the hope that it will be useful, |
---|
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 17 | * GNU General Public License for more details. |
---|
| 18 | * |
---|
| 19 | * You should have received a copy of the GNU General Public License |
---|
| 20 | * along with this software; see the file COPYING. If not, write to |
---|
| 21 | * the Free Software Foundation, 51 Franklin Street, Fifth Floor, |
---|
| 22 | * Boston, MA 02110-1301, USA. |
---|
| 23 | * |
---|
| 24 | * NOTE for everyone want's to change something and send patches: |
---|
| 25 | * read README and HACKING! There a addition information on |
---|
| 26 | * the license of this document you need to read before you send |
---|
| 27 | * any patches. |
---|
| 28 | * |
---|
| 29 | * NOTE for uses of non-GPL (LGPL,...) software using libesd, libartsc |
---|
| 30 | * or libpulse*: |
---|
| 31 | * The libs libroaresd, libroararts and libroarpulse link this lib |
---|
| 32 | * and are therefore GPL. Because of this it may be illigal to use |
---|
| 33 | * them with any software that uses libesd, libartsc or libpulse*. |
---|
| 34 | */ |
---|
| 35 | |
---|
| 36 | #include "libroar.h" |
---|
| 37 | |
---|
[5116] | 38 | static ssize_t _vio_stream_read (struct roar_vio_calls * vio, void *buf, size_t count) { |
---|
| 39 | return roar_vio_read(roar_get_connection_vio2(vio->inst), buf, count); |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | static ssize_t _vio_stream_write (struct roar_vio_calls * vio, void *buf, size_t count) { |
---|
| 43 | return roar_vio_write(roar_get_connection_vio2(vio->inst), buf, count); |
---|
| 44 | } |
---|
| 45 | |
---|
[5278] | 46 | static roar_off_t _vio_stream_lseek (struct roar_vio_calls * vio, roar_off_t offset, int whence) { |
---|
[5116] | 47 | return roar_vio_lseek(roar_get_connection_vio2(vio->inst), offset, whence); |
---|
| 48 | } |
---|
| 49 | static int _vio_stream_sync (struct roar_vio_calls * vio) { |
---|
| 50 | return roar_vio_sync(roar_get_connection_vio2(vio->inst)); |
---|
| 51 | } |
---|
[5278] | 52 | static int _vio_stream_ctl (struct roar_vio_calls * vio, roar_vio_ctl_t cmd, void * data) { |
---|
[5116] | 53 | if (vio == NULL) { |
---|
| 54 | roar_err_set(ROAR_ERROR_FAULT); |
---|
| 55 | return -1; |
---|
| 56 | } |
---|
| 57 | |
---|
| 58 | if (cmd == -1) { |
---|
| 59 | roar_err_set(ROAR_ERROR_INVAL); |
---|
| 60 | return -1; |
---|
| 61 | } |
---|
| 62 | |
---|
| 63 | switch (cmd) { |
---|
| 64 | case ROAR_VIO_CTL_GET_NAME: |
---|
| 65 | if ( data == NULL ) { |
---|
| 66 | roar_err_set(ROAR_ERROR_FAULT); |
---|
| 67 | return -1; |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | *(char**)data = "stream"; |
---|
| 71 | return 0; |
---|
| 72 | break; |
---|
| 73 | case ROAR_VIO_CTL_GET_NEXT: |
---|
| 74 | *(struct roar_vio_calls **)data = roar_get_connection_vio2(vio->inst); |
---|
| 75 | return 0; |
---|
| 76 | break; |
---|
| 77 | case ROAR_VIO_CTL_SET_NEXT: |
---|
| 78 | roar_err_set(ROAR_ERROR_NOTSUP); |
---|
| 79 | return -1; |
---|
| 80 | break; |
---|
[5276] | 81 | case ROAR_VIO_CTL_NONBLOCK: |
---|
| 82 | return roar_vio_ctl(roar_get_connection_vio2(vio->inst), ROAR_VIO_CTL_NONBLOCK, data); |
---|
| 83 | break; |
---|
[5116] | 84 | } |
---|
| 85 | |
---|
| 86 | return roar_vio_ctl(roar_get_connection_vio2(vio->inst), cmd, data); |
---|
| 87 | } |
---|
| 88 | |
---|
| 89 | static int _vio_stream_close (struct roar_vio_calls * vio) { |
---|
| 90 | roar_vio_close(roar_get_connection_vio2(vio->inst)); |
---|
| 91 | roar_mm_free(vio->inst); |
---|
| 92 | |
---|
| 93 | return 0; |
---|
| 94 | } |
---|
[5115] | 95 | |
---|
[5289] | 96 | int roar_vio_simple_stream (struct roar_vio_calls * calls, |
---|
| 97 | uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, |
---|
| 98 | const char * server, int dir, const char * name, int mixer) { |
---|
[5116] | 99 | struct roar_connection * con = NULL; |
---|
| 100 | struct roar_stream stream; |
---|
| 101 | int err; |
---|
[5115] | 102 | |
---|
| 103 | if ( calls == NULL ) { |
---|
| 104 | roar_err_set(ROAR_ERROR_FAULT); |
---|
| 105 | return -1; |
---|
| 106 | } |
---|
| 107 | |
---|
[5116] | 108 | if ( roar_stream_new(&stream, rate, channels, bits, codec) == -1 ) |
---|
| 109 | return -1; |
---|
| 110 | |
---|
| 111 | con = roar_mm_malloc(sizeof(struct roar_connection)); |
---|
| 112 | if ( con == NULL ) |
---|
| 113 | return -1; |
---|
| 114 | |
---|
| 115 | memset(con, 0, sizeof(struct roar_connection)); |
---|
| 116 | |
---|
| 117 | if ( roar_simple_connect(con, server, name) == -1 ) { |
---|
[5901] | 118 | roar_mm_free_noerror(con); |
---|
[5116] | 119 | return -1; |
---|
| 120 | } |
---|
| 121 | |
---|
[5289] | 122 | if ( roar_stream_connect(con, &stream, dir, mixer) == -1 ) { |
---|
[5116] | 123 | err = roar_error; |
---|
| 124 | roar_disconnect(con); |
---|
| 125 | roar_mm_free(con); |
---|
| 126 | roar_error = err; |
---|
[5115] | 127 | return -1; |
---|
| 128 | } |
---|
[5116] | 129 | |
---|
| 130 | if ( roar_stream_exec(con, &stream) == -1 ) { |
---|
| 131 | err = roar_error; |
---|
| 132 | roar_disconnect(con); |
---|
| 133 | roar_mm_free(con); |
---|
| 134 | roar_error = err; |
---|
| 135 | return -1; |
---|
| 136 | } |
---|
| 137 | |
---|
| 138 | roar_vio_clear_calls(calls); |
---|
[5115] | 139 | |
---|
[5116] | 140 | calls->inst = con; |
---|
| 141 | calls->read = _vio_stream_read; |
---|
| 142 | calls->write = _vio_stream_write; |
---|
| 143 | calls->lseek = _vio_stream_lseek; |
---|
| 144 | calls->sync = _vio_stream_sync; |
---|
| 145 | calls->ctl = _vio_stream_ctl; |
---|
| 146 | calls->close = _vio_stream_close; |
---|
| 147 | |
---|
| 148 | if ( dir == ROAR_DIR_PLAY ) { |
---|
| 149 | roar_vio_shutdown(calls, SHUT_RD); |
---|
| 150 | } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { |
---|
| 151 | roar_vio_shutdown(calls, SHUT_WR); |
---|
| 152 | } |
---|
| 153 | |
---|
| 154 | return 0; |
---|
[5115] | 155 | } |
---|
| 156 | |
---|
[6028] | 157 | static inline int _roar_simple_new_stream_obj_try_select (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer, struct roar_sockname * sockname, int * fh, int * can_go_on) { |
---|
[6027] | 158 | #ifdef ROAR_HAVE_SELECT |
---|
| 159 | int confh; |
---|
| 160 | fd_set fds; |
---|
| 161 | struct timeval timeout = {10, 0}; |
---|
| 162 | struct roar_message mes; |
---|
| 163 | int listen; |
---|
| 164 | int port = 0; |
---|
[5896] | 165 | char file[80] = ""; |
---|
[5377] | 166 | static int count = 0; |
---|
[6027] | 167 | char socketaddr[80]; |
---|
| 168 | ssize_t socketaddr_len = -1; |
---|
[5377] | 169 | #if defined(ROAR_HAVE_IPV4) || defined(ROAR_HAVE_LIBDNET) |
---|
| 170 | int opt = 1; |
---|
| 171 | #endif |
---|
[6026] | 172 | #ifdef ROAR_HAVE_LIBDNET |
---|
| 173 | struct dn_naddr *binaddr; |
---|
| 174 | #endif |
---|
[5377] | 175 | #ifdef ROAR_HAVE_IPV4 |
---|
| 176 | struct sockaddr_in socket_addr; |
---|
| 177 | socklen_t len = sizeof(struct sockaddr_in); |
---|
| 178 | #else |
---|
| 179 | struct sockaddr socket_addr; |
---|
| 180 | socklen_t len = sizeof(struct sockaddr); |
---|
| 181 | #endif |
---|
[6027] | 182 | |
---|
| 183 | memset(&mes, 0, sizeof(mes)); |
---|
| 184 | memset(&socket_addr, 0, sizeof(socket_addr)); |
---|
| 185 | |
---|
[6028] | 186 | *can_go_on = 0; |
---|
| 187 | |
---|
| 188 | switch (sockname->type) { |
---|
[6027] | 189 | #ifdef ROAR_HAVE_LIBDNET |
---|
[6028] | 190 | case ROAR_SOCKET_TYPE_DECNET: |
---|
| 191 | if ( roar_socket_get_local_nodename() != NULL && (binaddr = getnodeadd()) != NULL ) { |
---|
| 192 | snprintf(socketaddr+3, sizeof(socketaddr)-3, "roar$TMP%04x%02x", getpid(), count++); |
---|
| 193 | snprintf(file, sizeof(file), "%s::%s", roar_socket_get_local_nodename(), socketaddr+3); |
---|
| 194 | memcpy(socketaddr, binaddr->a_addr, 2); |
---|
| 195 | socketaddr[2] = 0; // object 0. |
---|
| 196 | socketaddr_len = 3 + roar_mm_strlen(socketaddr+3); |
---|
| 197 | } else { |
---|
| 198 | return -1; |
---|
| 199 | } |
---|
| 200 | break; |
---|
[6027] | 201 | #endif |
---|
| 202 | #ifdef ROAR_HAVE_IPV4 |
---|
[6028] | 203 | case ROAR_SOCKET_TYPE_TCP: |
---|
| 204 | strncpy(file, sockname->addr, sizeof(file) - 1); |
---|
| 205 | roar_err_set(ROAR_ERROR_NONE); |
---|
| 206 | if ( inet_aton(sockname->addr, &socket_addr.sin_addr) == 0 ) { |
---|
| 207 | roar_err_update(); |
---|
| 208 | return -1; |
---|
| 209 | } |
---|
| 210 | memcpy(socketaddr, &socket_addr.sin_addr.s_addr, 4); |
---|
| 211 | socketaddr_len = 6; |
---|
| 212 | break; |
---|
[6027] | 213 | #endif |
---|
[6028] | 214 | default: |
---|
| 215 | roar_err_set(ROAR_ERROR_AFNOTSUP); |
---|
| 216 | return -1; |
---|
| 217 | break; |
---|
[6027] | 218 | } |
---|
| 219 | |
---|
| 220 | roar_libroar_nowarn(); |
---|
| 221 | if ( (listen = roar_socket_listen(sockname->type, file, port)) == -1 ) { |
---|
| 222 | roar_libroar_warn(); |
---|
| 223 | return -1; |
---|
| 224 | } |
---|
| 225 | roar_libroar_warn(); |
---|
| 226 | |
---|
[6028] | 227 | switch (sockname->type) { |
---|
[6027] | 228 | #ifdef ROAR_HAVE_IPV4 |
---|
[6028] | 229 | case ROAR_SOCKET_TYPE_TCP: |
---|
| 230 | setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, (void*)&opt, sizeof(int)); |
---|
[6027] | 231 | |
---|
[6028] | 232 | len = sizeof(struct sockaddr_in); |
---|
| 233 | if ( getsockname(listen, (struct sockaddr *)&socket_addr, &len) == -1 ) { |
---|
| 234 | return -1; |
---|
| 235 | } |
---|
| 236 | ((uint16_t*)socketaddr)[3] = socket_addr.sin_port; |
---|
| 237 | port = ROAR_NET2HOST16(socket_addr.sin_port); |
---|
| 238 | ROAR_DBG("roar_simple_new_stream_obj(*): port=%i", port); |
---|
| 239 | break; |
---|
[6027] | 240 | #endif |
---|
| 241 | #ifdef ROAR_HAVE_LIBDNET |
---|
[6028] | 242 | case ROAR_SOCKET_TYPE_DECNET: |
---|
| 243 | setsockopt(listen, SOL_SOCKET, SO_REUSEADDR, &opt, sizeof(int)); |
---|
| 244 | break; |
---|
[5377] | 245 | #endif |
---|
[6027] | 246 | } |
---|
| 247 | |
---|
[6028] | 248 | if ( roar_stream_connect_to_advanced(con, s, 0, 1, 0, sockname->type, socketaddr_len, socketaddr, ROAR_PROTO_NONE, -1, NULL, 0, NULL) == -1 ) { |
---|
| 249 | close(listen); |
---|
| 250 | *can_go_on = 1; |
---|
| 251 | return -1; |
---|
| 252 | } else { |
---|
[6027] | 253 | |
---|
| 254 | FD_ZERO(&fds); |
---|
| 255 | FD_SET(listen, &fds); |
---|
| 256 | |
---|
| 257 | confh = roar_get_connection_fh(con); |
---|
| 258 | |
---|
| 259 | if ( confh != -1 ) { |
---|
| 260 | FD_SET(confh, &fds); |
---|
| 261 | } |
---|
| 262 | |
---|
| 263 | if ( select((confh > listen ? confh : listen) + 1, &fds, NULL, NULL, &timeout) < 1 ) { |
---|
| 264 | close(listen); |
---|
| 265 | |
---|
| 266 | // we don't need to check the content as we know it failed... |
---|
| 267 | if ( roar_recv_message(con, &mes, NULL) == -1 ) |
---|
| 268 | return -1; |
---|
| 269 | |
---|
| 270 | if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) |
---|
| 271 | return -1; |
---|
| 272 | |
---|
[6028] | 273 | *can_go_on = 1; |
---|
| 274 | return -1; |
---|
[6027] | 275 | } |
---|
| 276 | |
---|
| 277 | if ( FD_ISSET(listen, &fds) ) { |
---|
| 278 | if ( (*fh = accept(listen, NULL, NULL)) != -1 ) { |
---|
| 279 | /* TODO: FIXME: XXX: errr, do we need any error handling here? */ |
---|
| 280 | } |
---|
| 281 | |
---|
| 282 | if ( roar_recv_message(con, &mes, NULL) == -1 ) { |
---|
| 283 | if ( *fh != -1 ) |
---|
| 284 | close(*fh); |
---|
| 285 | *fh = -1; |
---|
| 286 | } else if ( mes.cmd != ROAR_CMD_OK ) { |
---|
| 287 | if ( *fh != -1 ) |
---|
| 288 | close(*fh); |
---|
| 289 | *fh = -1; |
---|
| 290 | } |
---|
| 291 | } else { |
---|
| 292 | // we don't need to check the content as we know it failed... |
---|
| 293 | if ( roar_recv_message(con, &mes, NULL) == -1 ) { |
---|
| 294 | close(listen); |
---|
| 295 | return -1; |
---|
| 296 | } |
---|
| 297 | |
---|
| 298 | if ( mes.cmd != ROAR_CMD_OK ) { |
---|
| 299 | close(listen); |
---|
| 300 | if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) |
---|
| 301 | return -1; |
---|
| 302 | |
---|
[6028] | 303 | *can_go_on = 1; |
---|
| 304 | return -1; |
---|
[6027] | 305 | } else { // seems like we have a positive reply. So we retry the listen socket: |
---|
| 306 | FD_ZERO(&fds); |
---|
| 307 | FD_SET(listen, &fds); |
---|
| 308 | timeout.tv_sec = 0; |
---|
| 309 | timeout.tv_usec = 128000L; |
---|
| 310 | *fh = -1; |
---|
| 311 | if ( select(listen + 1, &fds, NULL, NULL, &timeout) > 0 ) { |
---|
| 312 | if ( (*fh = accept(listen, NULL, NULL)) == -1 ) { |
---|
| 313 | close(listen); |
---|
| 314 | if ( roar_kick(con, ROAR_OT_STREAM, s->id) == -1 ) |
---|
| 315 | return -1; |
---|
| 316 | |
---|
[6028] | 317 | *can_go_on = 1; |
---|
| 318 | return -1; |
---|
[6027] | 319 | } |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | } |
---|
[6028] | 323 | close(listen); |
---|
| 324 | return 0; |
---|
[6027] | 325 | } |
---|
| 326 | |
---|
| 327 | #else |
---|
[6028] | 328 | roar_err_set(ROAR_ERROR_NOSYS); |
---|
| 329 | return -1; |
---|
[6027] | 330 | #endif |
---|
| 331 | } |
---|
| 332 | |
---|
| 333 | static int _roar_simple_new_stream_obj (struct roar_connection * con, struct roar_stream * s, uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, int dir, int mixer) { |
---|
| 334 | struct roar_libroar_config * config = roar_libroar_get_config(); |
---|
| 335 | int fh = -1; |
---|
[5377] | 336 | #ifdef ROAR_HAVE_UNIX |
---|
| 337 | int socks[2]; // for socketpair() |
---|
| 338 | #endif |
---|
[5408] | 339 | struct roar_sockname sockname; |
---|
[6028] | 340 | int can_go_on = 0; |
---|
[5377] | 341 | |
---|
[5408] | 342 | ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer); |
---|
| 343 | |
---|
[5377] | 344 | if ( config != NULL ) { |
---|
| 345 | if ( config->workaround.workarounds & ROAR_LIBROAR_CONFIG_WAS_USE_EXECED ) { |
---|
| 346 | return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); |
---|
| 347 | } |
---|
| 348 | } |
---|
| 349 | |
---|
[5408] | 350 | ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer); |
---|
| 351 | |
---|
[5377] | 352 | roar_libroar_nowarn(); |
---|
[5408] | 353 | if ( roar_vio_ctl(roar_get_connection_vio2(con), ROAR_VIO_CTL_GET_SOCKNAME, &sockname) == -1 ) { |
---|
[5377] | 354 | roar_libroar_warn(); |
---|
[5408] | 355 | #ifdef ROAR_OS_OPENBSD |
---|
| 356 | sockname.type = ROAR_SOCKET_TYPE_UNIX; |
---|
[5377] | 357 | #else |
---|
[5408] | 358 | ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = -1", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer); |
---|
[5377] | 359 | |
---|
| 360 | return -1; |
---|
| 361 | #endif |
---|
| 362 | } |
---|
[5408] | 363 | roar_libroar_warn(); |
---|
[5377] | 364 | |
---|
[5408] | 365 | ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = ?", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer); |
---|
[5377] | 366 | |
---|
| 367 | if ( roar_stream_new(s, rate, channels, bits, codec) == -1 ) { |
---|
| 368 | return -1; |
---|
| 369 | } |
---|
| 370 | |
---|
| 371 | if ( roar_stream_connect(con, s, dir, mixer) == -1 ) { |
---|
| 372 | return -1; |
---|
| 373 | } |
---|
| 374 | |
---|
[5408] | 375 | if ( sockname.type != ROAR_SOCKET_TYPE_UNIX ) { |
---|
[6028] | 376 | do { |
---|
| 377 | if ( _roar_simple_new_stream_obj_try_select(con, s, |
---|
| 378 | rate, channels, bits, codec, dir, mixer, |
---|
| 379 | &sockname, &fh, &can_go_on) != -1 ) |
---|
| 380 | break; |
---|
| 381 | if ( !can_go_on ) |
---|
| 382 | return -1; |
---|
| 383 | |
---|
| 384 | return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); |
---|
| 385 | } while (0); |
---|
[5408] | 386 | } else { // this is sockname.type == ROAR_SOCKET_TYPE_UNIX |
---|
[5377] | 387 | #ifdef ROAR_HAVE_UNIX |
---|
| 388 | if ( socketpair(AF_UNIX, SOCK_STREAM, 0, socks) == -1 ) { |
---|
| 389 | roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors |
---|
| 390 | // as we return -1 in both whys |
---|
| 391 | return -1; |
---|
| 392 | } |
---|
| 393 | |
---|
| 394 | if ( roar_stream_passfh(con, s, socks[0]) == -1 ) { |
---|
| 395 | roar_kick(con, ROAR_OT_STREAM, s->id); // we do not need to check for errors |
---|
| 396 | // as we return -1 anyway. |
---|
| 397 | close(socks[0]); |
---|
| 398 | close(socks[1]); |
---|
[5526] | 399 | |
---|
| 400 | return roar_simple_new_stream_attachexeced_obj(con, s, rate, channels, bits, codec, dir, mixer); |
---|
[5377] | 401 | } |
---|
| 402 | |
---|
| 403 | close(socks[0]); |
---|
| 404 | fh = socks[1]; |
---|
| 405 | #else |
---|
| 406 | roar_kick(con, ROAR_OT_STREAM, s->id); |
---|
| 407 | return -1; |
---|
| 408 | #endif |
---|
| 409 | } |
---|
| 410 | |
---|
| 411 | if ( fh != -1 ) { |
---|
| 412 | if ( dir == ROAR_DIR_PLAY ) { |
---|
| 413 | (void)ROAR_SHUTDOWN(fh, SHUT_RD); |
---|
| 414 | } else if ( dir == ROAR_DIR_MONITOR || dir == ROAR_DIR_RECORD ) { |
---|
| 415 | (void)ROAR_SHUTDOWN(fh, SHUT_WR); |
---|
| 416 | } |
---|
| 417 | } |
---|
| 418 | |
---|
| 419 | s->fh = fh; |
---|
| 420 | |
---|
[5408] | 421 | ROAR_DBG("_roar_simple_new_stream_obj(con=%p, s=%p, rate=%i, channels=%i, bits=%i, codec=%i, dir=%i, mixer=%i) = %i", con, s, (int)rate, (int)channels, (int)bits, (int)codec, dir, mixer, fh); |
---|
[5377] | 422 | return fh; |
---|
| 423 | } |
---|
| 424 | |
---|
[5115] | 425 | int roar_vio_simple_new_stream_obj (struct roar_vio_calls * calls, |
---|
| 426 | struct roar_connection * con, |
---|
| 427 | struct roar_stream * s, |
---|
[5289] | 428 | uint32_t rate, uint32_t channels, uint32_t bits, uint32_t codec, |
---|
| 429 | int dir, int mixer) { |
---|
[5115] | 430 | struct roar_stream stream; |
---|
| 431 | int fh; |
---|
| 432 | |
---|
| 433 | ROAR_DBG("roar_vio_simple_new_stream_obj(*) = ?"); |
---|
| 434 | |
---|
| 435 | if ( calls == NULL ) { |
---|
| 436 | roar_err_set(ROAR_ERROR_FAULT); |
---|
| 437 | return -1; |
---|
| 438 | } |
---|
| 439 | |
---|
| 440 | if ( s == NULL ) |
---|
| 441 | s = &stream; |
---|
| 442 | |
---|
[5377] | 443 | if ( (fh = _roar_simple_new_stream_obj(con, s, rate, channels, bits, codec, dir, mixer)) == -1 ) { |
---|
[5115] | 444 | ROAR_DBG("roar_vio_simple_new_stream_obj(*) = -1"); |
---|
| 445 | return -1; |
---|
| 446 | } |
---|
| 447 | |
---|
| 448 | ROAR_DBG("roar_vio_simple_new_stream_obj(*): fh=%i", fh); |
---|
| 449 | |
---|
| 450 | return roar_vio_open_fh_socket(calls, fh); |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | //ll |
---|