Changeset 5296:b7fd2c45243e in roaraudio for libroar
- Timestamp:
- 11/25/11 02:27:12 (12 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- libroar
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
libroar/basic.c
r5267 r5296 262 262 int roar_connect (struct roar_connection * con, const char * server, int flags, uint_least32_t timeout) { 263 263 int fh; 264 int err; 264 265 265 266 if ( con == NULL ) { … … 274 275 return -1; 275 276 276 return roar_connect_fh(con, fh); 277 if ( roar_connect_fh(con, fh) == -1 ) { 278 err = roar_error; 279 #ifdef ROAR_TARGET_WIN32 280 closesocket(fh); 281 #else 282 close(fh); 283 #endif 284 roar_error = err; 285 return -1; 286 } 287 288 if ( server != NULL ) { 289 con->server_name = roar_mm_strdup(server); 290 } 291 292 return 0; 277 293 } 278 294 … … 289 305 290 306 memset(con, 0, sizeof(struct roar_connection)); 291 con->refc = 0;307 con->refc = 1; 292 308 con->flags = ROAR_CON_FLAGS_NONE; 293 309 con->version = 0; 294 310 con->cb_userdata = NULL; 295 311 con->cb = NULL; 312 con->server_stds = NULL; 313 con->server_name = NULL; 296 314 297 315 roar_err_init(&(con->errorframe)); 298 316 299 if ( roar_vio_open_fh_socket(&(con->viocon), fh) != -1 ) { 317 con->viocon = &(con->viocon_store); 318 319 if ( roar_vio_open_fh_socket(con->viocon, fh) != -1 ) { 300 320 con->flags |= ROAR_CON_FLAGS_VIO; 301 321 } … … 317 337 ROAR_DBG("roar_get_connection_fh(con=%p) = ?", con); 318 338 319 if ( roar_vio_ctl( &(con->viocon), ROAR_VIO_CTL_GET_FH, &fh) == -1 )339 if ( roar_vio_ctl(con->viocon, ROAR_VIO_CTL_GET_FH, &fh) == -1 ) 320 340 return -1; 321 341 … … 330 350 331 351 if ( con->flags & ROAR_CON_FLAGS_VIO ) 332 return &(con->viocon);352 return con->viocon; 333 353 334 354 // TODO: try to open the VIO. … … 337 357 } 338 358 339 int roar_disconnect (struct roar_connection * con) { 359 const char * roar_get_connection_server(struct roar_connection * con) { 360 if ( con == NULL ) { 361 roar_err_set(ROAR_ERROR_FAULT); 362 return NULL; 363 } 364 365 return con->server_name; 366 } 367 368 int roar_connectionref(struct roar_connection * con) { 369 if ( con == NULL ) { 370 roar_err_set(ROAR_ERROR_FAULT); 371 return -1; 372 } 373 374 con->refc++; 375 376 return 0; 377 } 378 379 int roar_connectionunref(struct roar_connection * con) { 340 380 struct roar_vio_calls * vio; 341 381 struct roar_message m; 382 383 if ( con == NULL ) { 384 roar_err_set(ROAR_ERROR_FAULT); 385 return -1; 386 } 387 388 con->refc--; 389 390 if ( con->refc ) 391 return 0; 342 392 343 393 memset(&m, 0, sizeof(m)); … … 354 404 } 355 405 356 roar_connect_fh(con, -2); 357 358 roar_err_set(ROAR_ERROR_NONE); 406 if ( con->server_stds != NULL ) { 407 roar_stds_free(con->server_stds); 408 con->server_stds = NULL; 409 } 410 411 if ( con->server_name != NULL ) { 412 roar_mm_free(con->server_name); 413 con->server_name = NULL; 414 } 415 416 if ( con->flags & ROAR_CON_FLAGS_FREESELF ) { 417 roar_mm_free(con); 418 } else { 419 roar_connect_fh(con, -2); 420 } 359 421 360 422 return 0; -
libroar/simple.c
r5289 r5296 120 120 int fh; 121 121 122 if ( (fh = roar_simple_stream_obj(s, rate, channels, bits, codec, NULL /* server, we hope this is ok here... */,122 if ( (fh = roar_simple_stream_obj(s, rate, channels, bits, codec, roar_get_connection_server(con), 123 123 dir, "libroar temp stream", mixer)) == -1 ) 124 124 return -1;
Note: See TracChangeset
for help on using the changeset viewer.