[Freeswitch-svn] [commit] r11708 - freeswitch/branches/gmaruzz/mod_skypiax/asterisk

FreeSWITCH SVN gmaruzz at freeswitch.org
Mon Feb 9 09:22:53 PST 2009


Author: gmaruzz
Date: Mon Feb  9 11:22:53 2009
New Revision: 11708

Log:
skypiax: cleaning skypiax_protocol.c

Modified:
   freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c

Modified: freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c
==============================================================================
--- freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c	(original)
+++ freeswitch/branches/gmaruzz/mod_skypiax/asterisk/chan_skypiax.c	Mon Feb  9 11:22:53 2009
@@ -180,16 +180,10 @@
 {
   struct skypiax_pvt *p = c->tech_pvt;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 /* queue the frame */
   if (p)
     p->control_to_send = control;
   else {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return 0;
   }
   DEBUGA_PBX("Queued CONTROL FRAME %d\n", SKYPIAX_P_LOG, control);
@@ -198,9 +192,6 @@
   while (p->control_to_send)
     usleep(1);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -210,14 +201,8 @@
   char *name = data;
   int res = AST_DEVICE_INVALID;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (!data) {
     ERRORA("Devicestate requested with no data\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return res;
   }
 
@@ -253,9 +238,6 @@
     ERRORA("Checking device state for interface [%s] returning AST_DEVICE_INVALID\n",
            SKYPIAX_P_LOG, name);
   }
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return res;
 }
 
@@ -268,9 +250,6 @@
   struct skypiax_pvt *p = c->tech_pvt;
   int res = 0;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   NOTICA("Let's INDICATE %d\n", SKYPIAX_P_LOG, cond);
 
   switch (cond) {
@@ -296,9 +275,6 @@
     res = -1;
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return res;
 }
 
@@ -310,18 +286,12 @@
   struct ast_channel *tmp = NULL;
   char *name = data;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
   DEBUGA_PBX("Try to request type: %s, name: %s, cause: %d," " format: %d\n",
              SKYPIAX_P_LOG, type, name, *cause, format);
 
   if (!data) {
     ERRORA("Channel requested with no data\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return NULL;
   }
 
@@ -372,9 +342,6 @@
     WARNINGA("Unable to create new Skypiax channel %s\n", SKYPIAX_P_LOG, name);
   }
   /* return the newly created channel */
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return tmp;
 }
 
@@ -390,15 +357,9 @@
   /* if there is not skypiax pvt why we are here ? */
   if (!p) {
     ERRORA("Asked to hangup channel not connected\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return 0;
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (p->skype && p->interface_state != SKYPIAX_STATE_DOWN) {
     char msg_to_skype[1024];
     p->interface_state = SKYPIAX_STATE_HANGUP_REQUESTED;
@@ -457,26 +418,15 @@
   /* set the channel state to DOWN, eg. available, not in active use */
   if (ast_setstate(c, SKYPIAX_STATE_DOWN)) {
     ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
-  if (option_debug)
-    DEBUGA_PBX("Hanged Up\n", SKYPIAX_P_LOG);
   /* restart the monitor thread, so it can recheck which interfaces it have to watch during its loop (the interfaces that are not owned by channels) */
   if (skypiax_restart_monitor()) {
     ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -487,9 +437,6 @@
   struct skypiax_pvt *p = c->tech_pvt;
   int res;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   /* whle ringing, we just wait, the skype thread will answer */
   while (p->interface_state == SKYPIAX_STATE_RING) {
     usleep(10000);              //10msec
@@ -498,13 +445,9 @@
     ERRORA("call answering failed, we want it to be into interface_state=%d, got %d\n", SKYPIAX_P_LOG, SKYPIAX_STATE_UP, p->interface_state);
     res = -1;
   } else {
-    if (option_debug)
       DEBUGA_PBX("call answered\n", SKYPIAX_P_LOG);
     res = 0;
   }
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return res;
 }
 
@@ -512,15 +455,9 @@
 int skypiax_senddigit_begin(struct ast_channel *c, char digit)
 {
   struct skypiax_pvt *p = c->tech_pvt;
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
   DEBUGA_PBX("DIGIT BEGIN received: %c\n", SKYPIAX_P_LOG, digit);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -528,9 +465,6 @@
 {
   struct skypiax_pvt *p = c->tech_pvt;
   char msg_to_skype[1024];
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
   NOTICA("DIGIT END received: %c %d\n", SKYPIAX_P_LOG, digit, duration);
 
@@ -538,9 +472,6 @@
 
   skypiax_skype_write(p, msg_to_skype);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 #else /* ASTERISK_VERSION_1_4 */
@@ -549,18 +480,12 @@
   struct skypiax_pvt *p = c->tech_pvt;
   char msg_to_skype[1024];
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   NOTICA("DIGIT received: %c\n", SKYPIAX_P_LOG, digit);
 
   sprintf(msg_to_skype, "SET CALL %s DTMF %c", p->skype_call_id, digit);
 
   skypiax_skype_write(p, msg_to_skype);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -576,9 +501,6 @@
   short *buf;
   int samples;
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
 /* if there are control frames queued to be sent by skypiax_queue_control, send it the first */
 //TODO maybe better a real queue?
@@ -605,9 +527,6 @@
 
 /* if the call is not active (ie: answered), do not send audio frames, they would pile up in a lag queue */
   if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
-    if (option_debug > 100) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return &f;
   }
 
@@ -632,10 +551,6 @@
       skypiax_sound_boost(&f, p->capture_boost);
   }
 
-  if (option_debug > 100) {
-    DEBUGA_SOUND("samples=%d\n", SKYPIAX_P_LOG, samples);
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return &f;
 }
 
@@ -650,20 +565,13 @@
   char *stringp = NULL;
   int status;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if ((c->_state != SKYPIAX_STATE_DOWN)
       && (c->_state != SKYPIAX_STATE_RESERVED)) {
     ERRORA("skypiax_call called on %s, neither down nor reserved\n", SKYPIAX_P_LOG,
            c->name);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
-  if (option_debug > 1)
     DEBUGA_PBX("skypiax_call to call idest: %s, timeout: %d!\n", SKYPIAX_P_LOG, idest,
                timeout);
 
@@ -674,14 +582,10 @@
   if (!where) {
     ERRORA("Destination %s requires an actual destination (Skypiax/device/destination)\n",
            SKYPIAX_P_LOG, idest);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
   strncpy(dstr, where + p->stripmsd, sizeof(dstr) - 1);
-  if (option_debug > 1)
     DEBUGA_PBX("skypiax_call dialing idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
                idest, timeout, dstr);
 
@@ -689,20 +593,13 @@
   status = skypiax_skype_call(p, dstr, timeout);
   if (status) {
     WARNINGA("skypiax_call dialing failed: %d!\n", SKYPIAX_P_LOG, status);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
-  if (option_debug > 1)
     DEBUGA_PBX("skypiax_call dialed idest: %s, timeout: %d, dstr: %s!\n", SKYPIAX_P_LOG,
                idest, timeout, dstr);
 
   ast_setstate(p->owner, SKYPIAX_STATE_DIALING);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -731,13 +628,7 @@
   struct skypiax_pvt *p = c->tech_pvt;
   int sent;
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (p->owner && p->owner->_state != SKYPIAX_STATE_UP) {
-    if (option_debug > 100) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return 0;
   }
   if (p->playback_boost)
@@ -746,10 +637,6 @@
   sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
   //skypiax_sound_write(p, f);
 
-  if (option_debug > 100) {
-    DEBUGA_SOUND("sent=%d\n", SKYPIAX_P_LOG, sent);
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -759,29 +646,17 @@
 {
   struct skypiax_pvt *p = newchan->tech_pvt;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (!p) {
     ERRORA("No pvt after masquerade. Strange things may happen\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
   if (p->owner != oldchan) {
     ERRORA("old channel wasn't %p but was %p\n", SKYPIAX_P_LOG, oldchan, p->owner);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 
   p->owner = newchan;
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -789,9 +664,6 @@
 {
   struct ast_channel *tmp;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   /* alloc a generic channel struct */
 #ifndef ASTERISK_VERSION_1_4
   tmp = ast_channel_alloc(1);
@@ -858,9 +730,6 @@
       ERRORA("ast_setstate failed, BAD\n", SKYPIAX_P_LOG);
       //ast_dsp_free(p->dsp);
       ast_channel_free(tmp);
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-      }
       return NULL;
     }
     /* if the requested state is different from DOWN, let the pbx manage this interface (now part of the newly created channel) */
@@ -869,9 +738,6 @@
       if (ast_pbx_start(tmp)) {
         ERRORA("Unable to start PBX on %s\n", SKYPIAX_P_LOG, tmp->name);
         ast_channel_free(tmp);
-        if (option_debug > 10) {
-          DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-        }
         return NULL;
       }
     }
@@ -893,15 +759,9 @@
     ast_update_use_count();
 
     /* return the newly created channel */
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return tmp;
   }
   ERRORA("failed memory allocation for Skypiax channel\n", SKYPIAX_P_LOG);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return NULL;
 }
 
@@ -927,10 +787,6 @@
   struct ast_flags config_flags = { 0 };
 #endif /* ASTERISK_VERSION_1_6 */
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-    ast_log(LOG_DEBUG, "ENTERING FUNC\n");
-  }
 #if defined(WANT_SKYPE_X11) || defined(__CYGWIN__)
 #ifndef __CYGWIN__
   if (!XInitThreads())
@@ -949,9 +805,6 @@
   i = ast_channel_register(&skypiax_tech);
   if (i < 0) {
     ERRORA("Unable to register channel type '%s'\n", SKYPIAX_P_LOG, skypiax_type);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
   /* load skypiax.conf config file */
@@ -984,9 +837,6 @@
         /* if error, unload config from memory and return */
         ast_config_destroy(cfg);
         ast_channel_unregister(&skypiax_tech);
-        if (option_debug > 10) {
-          DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-        }
         return -1;
       }
       /* do it for each category described in config */
@@ -997,9 +847,6 @@
   } else {
     ERRORA("Unable to load skypiax_config skypiax.conf\n", SKYPIAX_P_LOG);
     ast_channel_unregister(&skypiax_tech);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
 #ifndef ASTERISK_VERSION_1_6
@@ -1008,14 +855,8 @@
   /* start to monitor the interfaces (skypiax_iflist) for the first time */
   if (skypiax_restart_monitor()) {
     ERRORA("skypiax_restart_monitor failed, BAD\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -1034,9 +875,6 @@
   struct skypiax_pvt *p = NULL, *p2 = NULL;
   int res;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
   /* unregister our channel type with Asterisk */
   ast_channel_unregister(&skypiax_tech);
@@ -1060,9 +898,6 @@
       && (skypiax_monitor_thread != AST_PTHREADT_STOP)) {
     if (pthread_cancel(skypiax_monitor_thread)) {
       ERRORA("pthread_cancel failed, BAD\n", SKYPIAX_P_LOG);
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-      }
       return -1;
     }
     if (pthread_kill(skypiax_monitor_thread, SIGURG)) {
@@ -1071,9 +906,6 @@
 #ifndef __CYGWIN__              /* under cygwin, this seems to be not reliable, get stuck at times */
     if (pthread_join(skypiax_monitor_thread, NULL)) {
       ERRORA("pthread_join failed, BAD\n", SKYPIAX_P_LOG);
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-      }
       return -1;
     }
 #endif /* __CYGWIN__ */
@@ -1128,9 +960,6 @@
   sleep(5);                     /* without this pause, for some unknown (to me) reason it crashes on cygwin */
 #endif /* __CYGWIN__ */
   NOTICA("Unloaded Skypiax Module\n", SKYPIAX_P_LOG);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -1143,9 +972,6 @@
 {
   int res;
   static struct skypiax_pvt *p = &skypiax_log_struct;
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 /* lock the skypiax_usecnt lock */
   LOKKA(&skypiax_usecnt_lock);
   /* retrieve the skypiax_usecnt */
@@ -1153,9 +979,6 @@
 /* unlock the skypiax_usecnt lock */
   UNLOCKA(&skypiax_usecnt_lock);
   /* return the skypiax_usecnt */
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return res;
 }
 
@@ -1166,13 +989,6 @@
  */
 char *description()
 {
-  static struct skypiax_pvt *p = &skypiax_log_struct;
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return (char *) skypiax_desc;
 }
 
@@ -1184,16 +1000,9 @@
 char *key()
 {
   struct skypiax_pvt *p = NULL;
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
-  if (option_debug)
     NOTICA("Returning Key\n", SKYPIAX_P_LOG);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return ASTERISK_GPL_KEY;
 }
 
@@ -1228,10 +1037,6 @@
   /* alloc memory for PVT */
   tmp = malloc(sizeof(struct skypiax_pvt));
   if (tmp == NULL) {            /* fail */
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-      ast_log(LOG_DEBUG, "EXITING FUNC\n");
-    }
     return NULL;
   }
   /* clear memory for PVT */
@@ -1399,9 +1204,6 @@
   if (res == -1) {
     ERRORA("Failed initializing sound device\n", SKYPIAX_TMP_LOG);
     /* we failed, free the PVT */
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-    }
     free(tmp);
     return NULL;
   }
@@ -1421,7 +1223,6 @@
   tmp->skype_thread = AST_PTHREADT_NULL;
 
   if (tmp->skype) {
-    if (option_debug > 1)
       ast_log(LOG_DEBUG, "TO BE started skype_thread=%lu STOP=%lu NULL=%lu\n",
               (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
               (unsigned long) AST_PTHREADT_NULL);
@@ -1429,21 +1230,14 @@
     if (ast_pthread_create
         (&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-      }
       free(tmp);
       return NULL;
     }
 #else /* __CYGWIN__ */
 #ifdef WANT_SKYPE_X11
-    if (option_debug > 1)
       ast_log(LOG_DEBUG, "AsteriskHandlesfd: %d\n", tmp->SkypiaxHandles.fdesc[1]);
     if (ast_pthread_create(&tmp->skype_thread, NULL, do_skypeapi_thread, tmp) < 0) {
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-      }
       free(tmp);
       return NULL;
     }
@@ -1452,13 +1246,9 @@
     usleep(100000); //0.1 sec
     if( tmp->skype_thread == AST_PTHREADT_NULL){
       ast_log(LOG_ERROR, "Unable to start skype_main thread.\n");
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-      }
       free(tmp);
       return NULL;
     }
-    if (option_debug > 1)
       ast_log(LOG_DEBUG, "STARTED skype_thread=%lu STOP=%lu NULL=%lu\n",
               (unsigned long) tmp->skype_thread, (unsigned long) AST_PTHREADT_STOP,
               (unsigned long) AST_PTHREADT_NULL);
@@ -1516,9 +1306,6 @@
 
 
   /* return the newly created skypiax_pvt */
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_TMP_LOG);
-  }
   return tmp;
 }
 
@@ -1527,14 +1314,8 @@
 {
   static struct skypiax_pvt *p = &skypiax_log_struct;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   /* If we're supposed to be stopped -- stay stopped */
   if (skypiax_monitor_thread == AST_PTHREADT_STOP) {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return 0;
   }
   LOKKA(&skypiax_monlock);
@@ -1542,9 +1323,6 @@
   if (skypiax_monitor_thread == pthread_self()) {
     UNLOCKA(&skypiax_monlock);
     ERRORA("Cannot kill myself\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return -1;
   }
   /* if the monitor thread exists */
@@ -1556,16 +1334,10 @@
     if (ast_pthread_create(&skypiax_monitor_thread, NULL, skypiax_do_monitor, NULL) < 0) {
       UNLOCKA(&skypiax_monlock);
       ERRORA("Unable to start monitor thread.\n", SKYPIAX_P_LOG);
-      if (option_debug > 10) {
-        DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-      }
       return -1;
     }
   }
   UNLOCKA(&skypiax_monlock);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 
@@ -1582,14 +1354,8 @@
   struct timeval to;
   time_t now_timestamp;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
     ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return NULL;
   }
 
@@ -1657,9 +1423,6 @@
         continue;
       else {
         ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, res, strerror(errno));
-        if (option_debug > 10) {
-          DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-        }
         return NULL;
       }
     }
@@ -1694,9 +1457,6 @@
     pthread_testcancel();
   }
 /* Never reached */
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return NULL;
 
 }
@@ -1712,12 +1472,6 @@
 
 int skypiax_sound_init(struct skypiax_pvt *p)
 {
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return skypiax_skypeaudio_init(p);
 }
 
@@ -1733,14 +1487,8 @@
 int skypiax_sound_shutdown(struct skypiax_pvt *p)
 {
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   //return skypiax_portaudio_shutdown(p);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return -1;
 }
 
@@ -1750,14 +1498,8 @@
   struct ast_frame *f = NULL;
   int res;
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   res = skypiax_skypeaudio_read(p);
   f =  &p->read_frame;
-  if (option_debug > 100) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return f;
 }
 
@@ -1766,13 +1508,7 @@
 {
   int ret = -1;
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   ret = skypiax_skypeaudio_write(p, f);
-  if (option_debug > 100) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return ret;
 }
 
@@ -1785,16 +1521,10 @@
   struct skypiax_pvt *p = data;
   int res;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   DEBUGA_SERIAL("In skypiax_do_controldev_thread: started, p=%p\n", SKYPIAX_P_LOG, p);
 
   if (pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED, NULL)) {
     ERRORA("Unable to set cancel type to deferred\n", SKYPIAX_P_LOG);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return NULL;
   }
 
@@ -1804,7 +1534,6 @@
     if (p->skype) {
       res = skypiax_skype_read(p);
       if (res == CALLFLOW_INCOMING_HANGUP) {
-        if (option_debug)
           DEBUGA_SKYPE("skype call ended\n", SKYPIAX_P_LOG);
         if (p->owner) {
           pthread_testcancel();
@@ -1814,9 +1543,6 @@
     }
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return NULL;
 
 }
@@ -1835,14 +1561,8 @@
 {
   struct skypiax_pvt *p = NULL;
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (sscanf(s, "%lf", boost) != 1) {
     ERRORA("invalid boost <%s>\n", SKYPIAX_P_LOG, s);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return;
   }
   if (*boost < -BOOST_MAX) {
@@ -1853,7 +1573,6 @@
     *boost = BOOST_MAX;
   }
   *boost = exp(log(10) * *boost / 20) * BOOST_SCALE;
-  if (option_debug > 1)
     DEBUGA_SOUND("setting boost %s to %f\n", SKYPIAX_P_LOG, s, *boost);
 }
 
@@ -1863,38 +1582,23 @@
 struct skypiax_pvt *skypiax_console_find_desc(char *dev)
 {
   struct skypiax_pvt *p = NULL;
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
 
   for (p = skypiax_iflist; p && strcmp(p->name, dev) != 0; p = p->next);
   if (p == NULL)
     WARNINGA("could not find <%s>\n", SKYPIAX_P_LOG, dev);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return p;
 }
 int skypiax_console_playback_boost(int fd, int argc, char *argv[])
 {
   struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (argc > 2) {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SHOWUSAGE;
   }
   if (!p) {
     ast_cli(fd,
             "No \"current\" skypiax_console for playback_boost, please enter 'help skypiax_console'\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   }
 
@@ -1911,30 +1615,18 @@
             20 * log10(((double) p->playback_boost / (double) BOOST_SCALE)));
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return RESULT_SUCCESS;
 }
 int skypiax_console_capture_boost(int fd, int argc, char *argv[])
 {
   struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (argc > 2) {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SHOWUSAGE;
   }
   if (!p) {
     ast_cli(fd,
             "No \"current\" skypiax_console for capture_boost, please enter 'help skypiax_console'\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   }
 
@@ -1951,9 +1643,6 @@
             20 * log10(((double) p->capture_boost / (double) BOOST_SCALE)));
   }
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return RESULT_SUCCESS;
 }
 
@@ -1961,36 +1650,21 @@
 {
   struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (argc != 1) {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SHOWUSAGE;
   }
   if (!p) {
     ast_cli(fd,
             "No \"current\" skypiax_console for hanging up, please enter 'help skypiax_console'\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   }
   if (!p->owner) {
     ast_cli(fd, "No call to hangup on the active skypiax_console, that is [%s]\n",
             skypiax_console_active);
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_FAILURE;
   }
   if (p->owner)
     ast_queue_hangup(p->owner);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return RESULT_SUCCESS;
 }
 
@@ -1999,21 +1673,12 @@
   char *s = NULL;
   struct skypiax_pvt *p = skypiax_console_find_desc(skypiax_console_active);
 
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (argc != 2) {
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SHOWUSAGE;
   }
   if (!p) {
     ast_cli(fd,
             "No \"current\" skypiax_console for dialing, please enter 'help skypiax_console'\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   }
 
@@ -2027,9 +1692,6 @@
       f.subclass = s[i];
       ast_queue_frame(p->owner, &f);
     }
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   } else
     ast_cli(fd,
@@ -2037,9 +1699,6 @@
             skypiax_console_active);
   if (s)
     free(s);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return RESULT_SUCCESS;
 }
 int skypiax_console_set_active(int fd, int argc, char *argv[])
@@ -2093,9 +1752,6 @@
                   if (ast_pthread_create
                       (&p->tcp_srv_thread, NULL, skypiax_do_tcp_srv_thread, p) < 0) {
                     ERRORA("Unable to start tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
-                    if (option_debug > 100) {
-                      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-                    }
                     return -1;
                   } else {
                     DEBUGA_SKYPE("started tcp_srv_thread thread.\n", SKYPIAX_P_LOG);
@@ -2105,9 +1761,6 @@
                   if (ast_pthread_create
                       (&p->tcp_cli_thread, NULL, skypiax_do_tcp_cli_thread, p) < 0) {
                     ERRORA("Unable to start tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
-                    if (option_debug > 100) {
-                      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-                    }
                     return -1;
                   } else {
                     DEBUGA_SKYPE("started tcp_cli_thread thread.\n", SKYPIAX_P_LOG);
@@ -2230,14 +1883,8 @@
 {
   int sent;
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   sent = write(p->audioskypepipe[1], (short *) f->data, f->datalen);
 
-  if (option_debug > 100) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return 0;
 }
 int skypiax_console_skype(int fd, int argc, char *argv[])
@@ -2254,17 +1901,8 @@
             "No \"current\" console for skypiax_skype, please enter 'help console'\n");
     return RESULT_SUCCESS;
   }
-  if (option_debug > 10) {
-    DEBUGA_PBX("ENTERING FUNC\n", SKYPIAX_P_LOG);
-  }
   if (!p->skype) {
     ast_cli(fd, "The \"current\" console is not connected to a Skype client'\n");
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
-    if (option_debug > 10) {
-      DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-    }
     return RESULT_SUCCESS;
   }
 
@@ -2285,9 +1923,6 @@
       break;
   }
   skypiax_skype_write(p, skype_msg);
-  if (option_debug > 10) {
-    DEBUGA_PBX("EXITING FUNC\n", SKYPIAX_P_LOG);
-  }
   return RESULT_SUCCESS;
 }
 
@@ -2370,7 +2005,6 @@
   } else {
     snprintf(fn, sizeof(fn), "%s/%s", ast_config_AST_CONFIG_DIR, configfile);
   }
-  if (option_debug)
     NOTICA("Opening '%s'\n", SKYPIAX_P_LOG, fn);
   time(&t);
   ast_copy_string(date, ctime(&t), sizeof(date));
@@ -2382,14 +2016,12 @@
 
   if (p->phonebook_writing_fp) {
     if (add_to_skypiax_dir_conf) {
-      if (option_debug)
         NOTICA("Opened '%s' for appending \n", SKYPIAX_P_LOG, fn);
       fprintf(p->phonebook_writing_fp, ";!\n");
       fprintf(p->phonebook_writing_fp, ";! Update Date: %s", date);
       fprintf(p->phonebook_writing_fp, ";! Updated by: %s, %d\n", __FILE__, __LINE__);
       fprintf(p->phonebook_writing_fp, ";!\n");
     } else {
-      if (option_debug)
         NOTICA("Opened '%s' for writing \n", SKYPIAX_P_LOG, fn);
       fprintf(p->phonebook_writing_fp, ";!\n");
       fprintf(p->phonebook_writing_fp, ";! Automatically generated configuration file\n");



More information about the Freeswitch-svn mailing list