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 | |
parent | eb48b0fb4f5e61a5a4b65378a647b7717b011020 (diff) | |
download | gnunet-4d14f67cd579bf4831293b75b4f24a135cff05b3.tar.gz gnunet-4d14f67cd579bf4831293b75b4f24a135cff05b3.zip |
-perform mic/speaker operations before event callbacks
Diffstat (limited to 'src')
-rw-r--r-- | src/conversation/conversation_api.c | 52 | ||||
-rw-r--r-- | src/conversation/conversation_api_call.c | 11 |
2 files changed, 39 insertions, 24 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); |
diff --git a/src/conversation/conversation_api_call.c b/src/conversation/conversation_api_call.c index 8722e2452..c3d414a50 100644 --- a/src/conversation/conversation_api_call.c +++ b/src/conversation/conversation_api_call.c | |||
@@ -215,10 +215,10 @@ handle_call_suspend (void *cls, | |||
215 | break; | 215 | break; |
216 | case CS_ACTIVE: | 216 | case CS_ACTIVE: |
217 | call->state = CS_SUSPENDED_CALLEE; | 217 | call->state = CS_SUSPENDED_CALLEE; |
218 | call->event_handler (call->event_handler_cls, | ||
219 | GNUNET_CONVERSATION_EC_CALL_SUSPENDED); | ||
220 | call->speaker->disable_speaker (call->speaker->cls); | 218 | call->speaker->disable_speaker (call->speaker->cls); |
221 | call->mic->disable_microphone (call->mic->cls); | 219 | call->mic->disable_microphone (call->mic->cls); |
220 | call->event_handler (call->event_handler_cls, | ||
221 | GNUNET_CONVERSATION_EC_CALL_SUSPENDED); | ||
222 | break; | 222 | break; |
223 | case CS_SHUTDOWN: | 223 | case CS_SHUTDOWN: |
224 | GNUNET_CONVERSATION_call_stop (call); | 224 | GNUNET_CONVERSATION_call_stop (call); |
@@ -328,6 +328,8 @@ handle_call_hangup (void *cls, | |||
328 | const struct GNUNET_MessageHeader *msg) | 328 | const struct GNUNET_MessageHeader *msg) |
329 | { | 329 | { |
330 | struct GNUNET_CONVERSATION_Call *call = cls; | 330 | struct GNUNET_CONVERSATION_Call *call = cls; |
331 | GNUNET_CONVERSATION_CallEventHandler eh; | ||
332 | void *eh_cls; | ||
331 | 333 | ||
332 | switch (call->state) | 334 | switch (call->state) |
333 | { | 335 | { |
@@ -340,9 +342,10 @@ handle_call_hangup (void *cls, | |||
340 | case CS_SUSPENDED_CALLEE: | 342 | case CS_SUSPENDED_CALLEE: |
341 | case CS_SUSPENDED_BOTH: | 343 | case CS_SUSPENDED_BOTH: |
342 | case CS_ACTIVE: | 344 | case CS_ACTIVE: |
343 | call->event_handler (call->event_handler_cls, | 345 | eh = call->event_handler; |
344 | GNUNET_CONVERSATION_EC_CALL_HUNG_UP); | 346 | eh_cls = call->event_handler_cls; |
345 | GNUNET_CONVERSATION_call_stop (call); | 347 | GNUNET_CONVERSATION_call_stop (call); |
348 | eh (eh_cls, GNUNET_CONVERSATION_EC_CALL_HUNG_UP); | ||
346 | return; | 349 | return; |
347 | case CS_SHUTDOWN: | 350 | case CS_SHUTDOWN: |
348 | GNUNET_CONVERSATION_call_stop (call); | 351 | GNUNET_CONVERSATION_call_stop (call); |