gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r31162 - gnunet/src/conversation


From: gnunet
Subject: [GNUnet-SVN] r31162 - gnunet/src/conversation
Date: Sat, 7 Dec 2013 22:01:44 +0100

Author: grothoff
Date: 2013-12-07 22:01:44 +0100 (Sat, 07 Dec 2013)
New Revision: 31162

Modified:
   gnunet/src/conversation/conversation_api.c
   gnunet/src/conversation/conversation_api_call.c
Log:
-perform mic/speaker operations before event callbacks

Modified: gnunet/src/conversation/conversation_api.c
===================================================================
--- gnunet/src/conversation/conversation_api.c  2013-12-07 00:15:19 UTC (rev 
31161)
+++ gnunet/src/conversation/conversation_api.c  2013-12-07 21:01:44 UTC (rev 
31162)
@@ -560,6 +560,34 @@
 
 
 /**
+ * Clean up all callers of the given phone.
+ *
+ * @param phone phone to clean up callers for
+ */
+static void
+clean_up_callers (struct GNUNET_CONVERSATION_Phone *phone)
+{
+  struct GNUNET_CONVERSATION_Caller *caller;
+
+  while (NULL != (caller = phone->caller_head))
+  {
+    /* make sure mic/speaker are disabled *before* callback */
+    if (CS_ACTIVE == caller->state)
+    {
+      caller->speaker->disable_speaker (caller->speaker->cls);
+      caller->mic->disable_microphone (caller->mic->cls);
+      caller->state = CS_CALLER_SUSPENDED;
+    }
+    phone->event_handler (phone->event_handler_cls,
+                          GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
+                          caller,
+                          caller->caller_id_str);
+    GNUNET_CONVERSATION_caller_hang_up (caller);
+  }
+}
+
+
+/**
  * The phone got disconnected, reconnect to the service.
  *
  * @param phone phone to reconnect
@@ -588,16 +616,8 @@
   };
   struct GNUNET_MQ_Envelope *e;
   struct ClientPhoneRegisterMessage *reg;
-  struct GNUNET_CONVERSATION_Caller *caller;
 
-  while (NULL != (caller = phone->caller_head))
-  {
-    phone->event_handler (phone->event_handler_cls,
-                          GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
-                          caller,
-                          caller->caller_id_str);
-    GNUNET_CONVERSATION_caller_hang_up (caller);
-  }
+  clean_up_callers (phone);
   if (NULL != phone->mq)
   {
     GNUNET_MQ_destroy (phone->mq);
@@ -766,7 +786,8 @@
                                caller);
   GNUNET_free_non_null (caller->caller_id_str);
   GNUNET_free (caller);
-  e = GNUNET_MQ_msg (hang, GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
+  e = GNUNET_MQ_msg (hang,
+                     GNUNET_MESSAGE_TYPE_CONVERSATION_CS_PHONE_HANG_UP);
   GNUNET_MQ_send (phone->mq, e);
 }
 
@@ -779,16 +800,7 @@
 void
 GNUNET_CONVERSATION_phone_destroy (struct GNUNET_CONVERSATION_Phone *phone)
 {
-  struct GNUNET_CONVERSATION_Caller *caller;
-
-  while (NULL != (caller = phone->caller_head))
-  {
-    phone->event_handler (phone->event_handler_cls,
-                          GNUNET_CONVERSATION_EC_PHONE_HUNG_UP,
-                          caller,
-                          caller->caller_id_str);
-    GNUNET_CONVERSATION_caller_hang_up (caller);
-  }
+  clean_up_callers (phone);
   if (NULL != phone->ns)
   {
     GNUNET_NAMESTORE_disconnect (phone->ns);

Modified: gnunet/src/conversation/conversation_api_call.c
===================================================================
--- gnunet/src/conversation/conversation_api_call.c     2013-12-07 00:15:19 UTC 
(rev 31161)
+++ gnunet/src/conversation/conversation_api_call.c     2013-12-07 21:01:44 UTC 
(rev 31162)
@@ -215,10 +215,10 @@
     break;
   case CS_ACTIVE:
     call->state = CS_SUSPENDED_CALLEE;
+    call->speaker->disable_speaker (call->speaker->cls);
+    call->mic->disable_microphone (call->mic->cls);
     call->event_handler (call->event_handler_cls,
                          GNUNET_CONVERSATION_EC_CALL_SUSPENDED);
-    call->speaker->disable_speaker (call->speaker->cls);
-    call->mic->disable_microphone (call->mic->cls);
     break;
   case CS_SHUTDOWN:
     GNUNET_CONVERSATION_call_stop (call);
@@ -328,6 +328,8 @@
                     const struct GNUNET_MessageHeader *msg)
 {
   struct GNUNET_CONVERSATION_Call *call = cls;
+  GNUNET_CONVERSATION_CallEventHandler eh;
+  void *eh_cls;
 
   switch (call->state)
   {
@@ -340,9 +342,10 @@
   case CS_SUSPENDED_CALLEE:
   case CS_SUSPENDED_BOTH:
   case CS_ACTIVE:
-    call->event_handler (call->event_handler_cls,
-                         GNUNET_CONVERSATION_EC_CALL_HUNG_UP);
+    eh = call->event_handler;
+    eh_cls = call->event_handler_cls;
     GNUNET_CONVERSATION_call_stop (call);
+    eh (eh_cls, GNUNET_CONVERSATION_EC_CALL_HUNG_UP);
     return;
   case CS_SHUTDOWN:
     GNUNET_CONVERSATION_call_stop (call);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]