diff options
author | Christian Grothoff <christian@grothoff.org> | 2013-12-07 21:01:44 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2013-12-07 21:01:44 +0000 |
commit | 4d14f67cd579bf4831293b75b4f24a135cff05b3 (patch) | |
tree | 21087e559cc4e9333b6c3366ed4a21040719b199 /src/conversation/conversation_api.c | |
parent | eb48b0fb4f5e61a5a4b65378a647b7717b011020 (diff) | |
download | gnunet-4d14f67cd579bf4831293b75b4f24a135cff05b3.tar.gz gnunet-4d14f67cd579bf4831293b75b4f24a135cff05b3.zip |
-perform mic/speaker operations before event callbacks
Diffstat (limited to 'src/conversation/conversation_api.c')
-rw-r--r-- | src/conversation/conversation_api.c | 52 |
1 files changed, 32 insertions, 20 deletions
diff --git a/src/conversation/conversation_api.c b/src/conversation/conversation_api.c index 31245b6cd..24cd52eb2 100644 --- a/src/conversation/conversation_api.c +++ b/src/conversation/conversation_api.c | |||
@@ -560,6 +560,34 @@ phone_error_handler (void *cls, | |||
560 | 560 | ||
561 | 561 | ||
562 | /** | 562 | /** |
563 | * Clean up all callers of the given phone. | ||
564 | * | ||
565 | * @param phone phone to clean up callers for | ||
566 | */ | ||
567 | static void | ||
568 | clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone) | ||
569 | { | ||
570 | struct GNUNET_CONVERSATION_Caller *caller; | ||
571 | |||
572 | while (NULL != (caller = phone->caller_head)) | ||
573 | { | ||
574 | /* make sure mic/speaker are disabled *before* callback */ | ||
575 | if (CS_ACTIVE == caller->state) | ||
576 | { | ||
577 | caller->speaker->disable_speaker (caller->speaker->cls); | ||
578 | caller->mic->disable_microphone (caller->mic->cls); | ||
579 | caller->state = CS_CALLER_SUSPENDED; | ||
580 | } | ||
581 | phone->event_handler (phone->event_handler_cls, | ||
582 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | ||
583 | caller, | ||
584 | caller->caller_id_str); | ||
585 | GNUNET_CONVERSATION_caller_hang_up (caller); | ||
586 | } | ||
587 | } | ||
588 | |||
589 | |||
590 | /** | ||
563 | * The phone got disconnected, reconnect to the service. | 591 | * The phone got disconnected, reconnect to the service. |
564 | * | 592 | * |
565 | * @param phone phone to reconnect | 593 | * @param phone phone to reconnect |
@@ -588,16 +616,8 @@ reconnect_phone (struct GNUNET_CONVERSATION_Phone *phone) | |||
588 | }; | 616 | }; |
589 | struct GNUNET_MQ_Envelope *e; | 617 | struct GNUNET_MQ_Envelope *e; |
590 | struct ClientPhoneRegisterMessage *reg; | 618 | struct ClientPhoneRegisterMessage *reg; |
591 | struct GNUNET_CONVERSATION_Caller *caller; | ||
592 | 619 | ||
593 | while (NULL != (caller = phone->caller_head)) | 620 | clean_up_callers (phone); |
594 | { | ||
595 | phone->event_handler (phone->event_handler_cls, | ||
596 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | ||
597 | caller, | ||
598 | caller->caller_id_str); | ||
599 | GNUNET_CONVERSATION_caller_hang_up (caller); | ||
600 | } | ||
601 | if (NULL != phone->mq) | 621 | if (NULL != phone->mq) |
602 | { | 622 | { |
603 | GNUNET_MQ_destroy (phone->mq); | 623 | GNUNET_MQ_destroy (phone->mq); |
@@ -766,7 +786,8 @@ GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | |||
766 | caller); | 786 | caller); |
767 | GNUNET_free_non_null (caller->caller_id_str); | 787 | GNUNET_free_non_null (caller->caller_id_str); |
768 | GNUNET_free (caller); | 788 | GNUNET_free (caller); |
769 | e = GNUNET_MQ_msg (hang, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | 789 | e = GNUNET_MQ_msg (hang, |
790 | GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP); | ||
770 | GNUNET_MQ_send (phone->mq, e); | 791 | GNUNET_MQ_send (phone->mq, e); |
771 | } | 792 | } |
772 | 793 | ||
@@ -779,16 +800,7 @@ GNUNET_CONVERSATION_caller_hang_up (struct GNUNET_CONVERSATION_Caller *caller) | |||
779 | void | 800 | void |
780 | GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone) | 801 | GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone) |
781 | { | 802 | { |
782 | struct GNUNET_CONVERSATION_Caller *caller; | 803 | clean_up_callers (phone); |
783 | |||
784 | while (NULL != (caller = phone->caller_head)) | ||
785 | { | ||
786 | phone->event_handler (phone->event_handler_cls, | ||
787 | GNUNET_CONVERSATION_EC_PHONE_HUNG_UP, | ||
788 | caller, | ||
789 | caller->caller_id_str); | ||
790 | GNUNET_CONVERSATION_caller_hang_up (caller); | ||
791 | } | ||
792 | if (NULL != phone->ns) | 804 | if (NULL != phone->ns) |
793 | { | 805 | { |
794 | GNUNET_NAMESTORE_disconnect (phone->ns); | 806 | GNUNET_NAMESTORE_disconnect (phone->ns); |