Changeset 4686:ebb913191f38 in roaraudio
- Timestamp:
- 12/22/10 03:47:59 (13 years ago)
- Branch:
- default
- Phase:
- public
- Location:
- roard
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
roard/clients.c
r4684 r4686 29 29 #ifndef ROAR_WITHOUT_DCOMP_EMUL_ESD 30 30 #ifdef ROAR_HAVE_H_ESD 31 {ROAR_PROTO_ESOUND, NULL, emul_esd_check_client },31 {ROAR_PROTO_ESOUND, NULL, emul_esd_check_client, NULL, NULL}, 32 32 #endif 33 33 #endif 34 34 #ifndef ROAR_WITHOUT_DCOMP_EMUL_RPLAY 35 {ROAR_PROTO_RPLAY, NULL, emul_rplay_check_client },35 {ROAR_PROTO_RPLAY, NULL, emul_rplay_check_client, NULL, NULL}, 36 36 #endif 37 37 {-1, NULL} … … 344 344 struct roar_client * c; 345 345 struct timeval tv; 346 fd_set r, e;346 fd_set r, w, e; 347 347 int i, j; 348 348 int ret; … … 358 358 359 359 FD_ZERO(&r); 360 FD_ZERO(&w); 360 361 FD_ZERO(&e); 361 362 … … 374 375 FD_SET(fh, &r); 375 376 FD_SET(fh, &e); 377 378 if ( g_clients[i]->outbuf != NULL ) { 379 FD_SET(fh, &w); 380 } 376 381 377 382 if ( fh > max_fh ) … … 408 413 return 0; 409 414 410 if ( (ret = select(max_fh + 1, &r, NULL, &e, &tv)) < 1 ) {415 if ( (ret = select(max_fh + 1, &r, &w, &e, &tv)) < 1 ) { 411 416 return ret < 0 ? ret : have; 412 417 } … … 429 434 } 430 435 } 436 if ( FD_ISSET(fh, &w) ) { 437 clients_flush(i); 438 } 431 439 432 440 if ( FD_ISSET(fh, &e) ) { … … 458 466 if ( have_streamless ) { 459 467 FD_ZERO(&r); 468 FD_ZERO(&w); 460 469 461 470 tv.tv_sec = 0; … … 476 485 FD_SET(fh, &r); 477 486 487 if ( g_clients[i]->outbuf != NULL ) { 488 FD_SET(fh, &w); 489 } 490 478 491 if ( fh > max_fh ) 479 492 max_fh = fh; 480 493 } 481 494 482 if ( (ret = select(max_fh + 1, &r, NULL, NULL, &tv)) < 0 ) {495 if ( (ret = select(max_fh + 1, &r, &w, NULL, &tv)) < 0 ) { 483 496 return ret; 484 497 } … … 487 500 if ( FD_ISSET(streamless[i].fh, &r) ) { 488 501 clients_check(streamless[i].id); 502 } 503 if ( FD_ISSET(streamless[i].fh, &w) ) { 504 clients_flush(streamless[i].id); 489 505 } 490 506 } … … 602 618 } 603 619 620 int clients_flush (int id) { 621 struct roar_vio_calls vio; 622 struct roar_client_server * cs; 623 struct roar_client * c; 624 struct roard_proto * p = NULL; 625 size_t i; 626 size_t len; 627 ssize_t ret; 628 void * buf; 629 630 _CHECK_CID(id); 631 632 c = ROAR_CLIENT(cs = g_clients[id]); 633 634 for (i = 0; g_proto[i].proto != -1; i++) { 635 if ( g_proto[i].proto == c->proto ) { 636 p = &(g_proto[i]); 637 break; 638 } 639 } 640 641 if ( p == NULL ) 642 return -1; 643 644 roar_vio_open_fh_socket(&vio, clients_get_fh(id)); 645 646 if ( p->flush_client != NULL ) { 647 return p->flush_client(id, &vio); 648 } 649 650 if ( roar_buffer_get_len(cs->outbuf, &len) == -1 ) 651 return -1; 652 653 if ( roar_buffer_get_data(cs->outbuf, &buf) == -1 ) 654 return -1; 655 656 ret = roar_vio_write(&vio, buf, len); 657 658 if ( ret < 1 ) { 659 clients_delete(id); 660 return -1; 661 } 662 663 if ( ret == len ) { 664 roar_buffer_next(&(cs->outbuf)); 665 } else { 666 if ( roar_buffer_set_offset(cs->outbuf, ret) == -1 ) { 667 clients_delete(id); 668 return -1; 669 } 670 } 671 672 if ( cs->outbuf == NULL ) { 673 if ( p->flushed_client != NULL ) { 674 return p->flushed_client(id, &vio); 675 } 676 } 677 678 return 0; 679 } 680 604 681 int clients_send_mon (struct roar_audio_info * sa, uint32_t pos) { 605 682 int i; … … 674 751 675 752 return -1; 753 } 754 755 int clients_add_output (int id, struct roar_buffer * buf) { 756 struct roar_client_server * cs; 757 758 _CHECK_CID(id); 759 cs = g_clients[id]; 760 761 if ( cs->outbuf == NULL ) { 762 cs->outbuf = buf; 763 } else { 764 return roar_buffer_add(cs->outbuf, buf); 765 } 766 767 return 0; 676 768 } 677 769 -
roard/include/client.h
r4684 r4686 77 77 int (*new_client)(int client, struct roar_vio_calls * vio, struct roard_listen * lsock); 78 78 int (*check_client)(int client, struct roar_vio_calls * vio); 79 int (*flush_client)(int client, struct roar_vio_calls * vio); 80 int (*flushed_client)(int client, struct roar_vio_calls * vio); 79 81 }; 80 82 … … 104 106 int clients_check_all (void); 105 107 int clients_check (int id); 108 int clients_flush (int id); 106 109 int clients_send_mon (struct roar_audio_info * sa, uint32_t pos); 107 110 int clients_send_filter(struct roar_audio_info * sa, uint32_t pos); 111 112 int clients_add_output (int id, struct roar_buffer * buf); 108 113 109 114 // proto support
Note: See TracChangeset
for help on using the changeset viewer.