Changeset 197 for pjproject/trunk/pjsip/src/pjsua/pjsua_core.c
- Timestamp:
- Feb 19, 2006 1:38:06 AM (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjsip/src/pjsua/pjsua_core.c
r184 r197 80 80 81 81 pj_list_init(&pjsua.inv_list); 82 83 /* Init server presence subscription list: */ 84 85 pj_list_init(&pjsua.pres_srv_list); 86 82 87 } 83 88 … … 392 397 393 398 394 static int PJ_THREAD_FUNC pjsua_ worker_thread(void *arg)399 static int PJ_THREAD_FUNC pjsua_poll(void *arg) 395 400 { 396 401 PJ_UNUSED_ARG(arg); 397 402 398 while (!pjsua.quit_flag){403 do { 399 404 pj_time_val timeout = { 0, 10 }; 400 405 pjsip_endpt_handle_events (pjsua.endpt, &timeout); 401 } 406 } while (!pjsua.quit_flag); 402 407 403 408 return 0; … … 436 441 437 442 438 /* Init PJSIP and all the modules: */443 /* Init PJSIP : */ 439 444 440 445 status = init_stack(); … … 444 449 return status; 445 450 } 451 452 453 /* Init core SIMPLE module : */ 454 455 pjsip_evsub_init_module(pjsua.endpt); 456 457 /* Init presence module: */ 458 459 pjsip_pres_init_module( pjsua.endpt, pjsip_evsub_instance()); 460 461 462 /* Init pjsua presence handler: */ 463 464 pjsua_pres_init(); 446 465 447 466 … … 610 629 611 630 for (i=0; i<pjsua.thread_cnt; ++i) { 612 status = pj_thread_create( pjsua.pool, "pjsua", &pjsua_ worker_thread,631 status = pj_thread_create( pjsua.pool, "pjsua", &pjsua_poll, 613 632 NULL, 0, 0, &pjsua.threads[i]); 614 633 if (status != PJ_SUCCESS) { … … 636 655 637 656 638 657 PJ_LOG(3,(THIS_FILE, "PJSUA version %s started", PJ_VERSION)); 639 658 return PJ_SUCCESS; 640 659 } 641 660 661 662 /* Sleep with polling */ 663 static void busy_sleep(unsigned msec) 664 { 665 pj_time_val timeout, now; 666 667 pj_gettimeofday(&timeout); 668 timeout.msec += msec; 669 pj_time_val_normalize(&timeout); 670 671 do { 672 pjsua_poll(NULL); 673 pj_gettimeofday(&now); 674 } while (PJ_TIME_VAL_LT(now, timeout)); 675 } 642 676 643 677 /* … … 648 682 int i; 649 683 650 /* Unregister, if required: */651 if (pjsua.regc) {652 653 pjsua_regc_update(0);654 655 /* Wait for some time to allow unregistration to complete: */656 657 pj_thread_sleep(500);658 }659 660 684 /* Signal threads to quit: */ 661 662 685 pjsua.quit_flag = 1; 663 686 664 665 /* Shutdown pjmedia-codec: */666 667 pjmedia_codec_deinit();668 669 670 /* Destroy sound framework:671 * (this should be done in pjmedia_shutdown())672 */673 pj_snd_deinit();674 675 687 /* Wait worker threads to quit: */ 676 677 688 for (i=0; i<pjsua.thread_cnt; ++i) { 678 689 … … 684 695 } 685 696 697 698 /* Terminate all calls. */ 699 pjsua_inv_shutdown(); 700 701 /* Terminate all presence subscriptions. */ 702 pjsua_pres_shutdown(); 703 704 /* Unregister, if required: */ 705 if (pjsua.regc) { 706 pjsua_regc_update(0); 707 } 708 709 /* Wait for some time to allow unregistration to complete: */ 710 PJ_LOG(4,(THIS_FILE, "Shutting down...")); 711 busy_sleep(1000); 712 713 /* Shutdown pjmedia-codec: */ 714 pjmedia_codec_deinit(); 715 716 /* Destroy sound framework: 717 * (this should be done in pjmedia_shutdown()) 718 */ 719 pj_snd_deinit(); 720 686 721 /* Destroy endpoint. */ 687 722
Note: See TracChangeset
for help on using the changeset viewer.