Revision
14375
Author
gmaruzz
Date
2009-07-27 10:56:07 -0500 (Mon, 27 Jul 2009)

Log Message

skypiax: indent -gnu -ts4 -br -brs -cdw -lp -ce -nbfda -npcs -nprs -npsl -nbbo -saf -sai -saw -cs -bbo -nhnl -nut -sob -l90

Modified Paths

Diff

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c (14374 => 14375)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2009-07-27 15:51:03 UTC (rev 14374)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/mod_skypiax.c	2009-07-27 15:56:07 UTC (rev 14375)
@@ -40,57 +40,47 @@
 /***************/
 // from http://www.openasthra.com/c-tidbits/gettimeofday-function-for-windows/
 
-#include <time.h>
-     
-#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
-#define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
-#else
-#define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
-#endif
-     
-    struct timezone 
-    {
-      int  tz_minuteswest; /* minutes W of Greenwich */
-      int  tz_dsttime;     /* type of dst correction */
-    };
-     
-    int gettimeofday(struct timeval *tv, struct timezone *tz)
-    {
-      FILETIME ft;
-      unsigned __int64 tmpres = 0;
-      static int tzflag;
-     
-      if (NULL != tv)
-      {
-        GetSystemTimeAsFileTime(&ft);
-     
-        tmpres |= ft.dwHighDateTime;
-        tmpres <<= 32;
-        tmpres |= ft.dwLowDateTime;
-     
-        /*converting file time to unix epoch*/
-        tmpres /= 10;  /*convert into microseconds*/
-        tmpres -= DELTA_EPOCH_IN_MICROSECS; 
-        tv->tv_sec = (long)(tmpres / 1000000UL);
-        tv->tv_usec = (long)(tmpres % 1000000UL);
-      }
-     
-      if (NULL != tz)
-      {
-        if (!tzflag)
-        {
-          _tzset();
-          tzflag++;
-        }
-        tz->tz_minuteswest = _timezone / 60;
-        tz->tz_dsttime = _daylight;
-      }
-     
-      return 0;
-    }
+#include <time.h>
+
+#if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
+#define DELTA_EPOCH_IN_MICROSECS  11644473600000000Ui64
+#else /*  */
+#define DELTA_EPOCH_IN_MICROSECS  11644473600000000ULL
+#endif /*  */
+struct timezone {
+  int tz_minuteswest;           /* minutes W of Greenwich */
+  int tz_dsttime;               /* type of dst correction */
+};
+int gettimeofday(struct timeval *tv, struct timezone *tz)
+{
+  FILETIME ft;
+  unsigned __int64 tmpres = 0;
+  static int tzflag;
+  if (NULL != tv) {
+    GetSystemTimeAsFileTime(&ft);
+    tmpres |= ft.dwHighDateTime;
+    tmpres <<= 32;
+    tmpres |= ft.dwLowDateTime;
+
+    /*converting file time to unix epoch */
+    tmpres /= 10;               /*convert into microseconds */
+    tmpres -= DELTA_EPOCH_IN_MICROSECS;
+    tv->tv_sec = (long) (tmpres / 1000000UL);
+    tv->tv_usec = (long) (tmpres % 1000000UL);
+  }
+  if (NULL != tz) {
+    if (!tzflag) {
+      _tzset();
+      tzflag++;
+    }
+    tz->tz_minuteswest = _timezone / 60;
+    tz->tz_dsttime = _daylight;
+  }
+  return 0;
+}
+
 /***************/
 #endif /* WIN32 */
-
 SWITCH_MODULE_LOAD_FUNCTION(mod_skypiax_load);
 SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_skypiax_shutdown);
 SWITCH_MODULE_DEFINITION(mod_skypiax, mod_skypiax_load, mod_skypiax_shutdown, NULL);
@@ -140,8 +130,8 @@
                                   globals.codec_rates_string);
 
 /* BEGIN: Changes here */
-static switch_status_t interface_exists(char* skype_user);
-static switch_status_t remove_interface(char* skype_user);
+static switch_status_t interface_exists(char *skype_user);
+static switch_status_t remove_interface(char *skype_user);
 /* END: Changes here */
 
 static switch_status_t channel_on_init(switch_core_session_t * session);
@@ -221,93 +211,102 @@
 }
 
 /* BEGIN: Changes here */
-static switch_status_t interface_exists(char* skype_user) {
-	int i;
-	for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
-		if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
-			if(strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, skype_user) == 0) {
-				return SWITCH_STATUS_SUCCESS;
-			}
-		}
-	}
-	return SWITCH_STATUS_FALSE;
+static switch_status_t interface_exists(char *skype_user)
+{
+  int i;
+  for (i = 0; i < SKYPIAX_MAX_INTERFACES; i++) {
+    if (strlen(globals.SKYPIAX_INTERFACES[i].name)) {
+      if (strcmp(globals.SKYPIAX_INTERFACES[i].skype_user, skype_user) == 0) {
+        return SWITCH_STATUS_SUCCESS;
+      }
+    }
+  }
+  return SWITCH_STATUS_FALSE;
 }
 
-static switch_status_t remove_interface(char* skype_user) {
-	int x = 100;
-	unsigned int howmany = 8;
-	int interface_id = -1;
-	private_t *tech_pvt = NULL;
-	switch_status_t status;
+static switch_status_t remove_interface(char *skype_user)
+{
+  int x = 100;
+  unsigned int howmany = 8;
+  int interface_id = -1;
+  private_t *tech_pvt = NULL;
+  switch_status_t status;
 
-	running = 0;
+  running = 0;
 
-	for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
-		if(strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user) == 0) {
-			tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
-			break;
-		}
-	}
+  for (interface_id = 0; interface_id < SKYPIAX_MAX_INTERFACES; interface_id++) {
+    if (strcmp(globals.SKYPIAX_INTERFACES[interface_id].skype_user, skype_user) == 0) {
+      tech_pvt = &globals.SKYPIAX_INTERFACES[interface_id];
+      break;
+    }
+  }
 
-	if(!tech_pvt) {
-		DEBUGA_SKYPE("interface for skype user '%s' does not exist\n", SKYPIAX_P_LOG, skype_user);
-		goto end;
-	}
+  if (!tech_pvt) {
+    DEBUGA_SKYPE("interface for skype user '%s' does not exist\n", SKYPIAX_P_LOG,
+                 skype_user);
+    goto end;
+  }
 
-	if (strlen(globals.SKYPIAX_INTERFACES[interface_id].session_uuid_str)) {
-		DEBUGA_SKYPE("interface for skype user '%s' is busy\n", SKYPIAX_P_LOG, skype_user);
-		goto end;
-	}
+  if (strlen(globals.SKYPIAX_INTERFACES[interface_id].session_uuid_str)) {
+    DEBUGA_SKYPE("interface for skype user '%s' is busy\n", SKYPIAX_P_LOG, skype_user);
+    goto end;
+  }
 
-	if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
+  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
 #ifdef WIN32
-		switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", &howmany);   // let's the controldev_thread die
+    switch_file_write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", &howmany); // let's the controldev_thread die
 #else /* WIN32 */
-		howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", howmany);
+    howmany = write(tech_pvt->SkypiaxHandles.fdesc[1], "sciutati", howmany);
 #endif /* WIN32 */
-	}
+  }
 
-	if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
+  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
 #ifdef WIN32
-		if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {  // let's the skypiax_api_thread_func die
-			DEBUGA_SKYPE("got FALSE here, thread probably was already dead. GetLastError returned: %d\n",
-					SKYPIAX_P_LOG, GetLastError());
-			globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
-		}
+    if (SendMessage(tech_pvt->SkypiaxHandles.win32_hInit_MainWindowHandle, WM_DESTROY, 0, 0) == FALSE) {    // let's the skypiax_api_thread_func die
+      DEBUGA_SKYPE
+        ("got FALSE here, thread probably was already dead. GetLastError returned: %d\n",
+         SKYPIAX_P_LOG, GetLastError());
+      globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread = NULL;
+    }
 #else
-		XEvent e;
-		Atom atom1 = XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
-		memset(&e, 0, sizeof(e));
-		e.xclient.type = ClientMessage;
-		e.xclient.message_type = atom1;   /*  leading message */
-		e.xclient.display = tech_pvt->SkypiaxHandles.disp;
-		e.xclient.window = tech_pvt->SkypiaxHandles.skype_win;
-		e.xclient.format = 8;
+    XEvent e;
+    Atom atom1 =
+      XInternAtom(tech_pvt->SkypiaxHandles.disp, "SKYPECONTROLAPI_MESSAGE_BEGIN", False);
+    memset(&e, 0, sizeof(e));
+    e.xclient.type = ClientMessage;
+    e.xclient.message_type = atom1; /*  leading message */
+    e.xclient.display = tech_pvt->SkypiaxHandles.disp;
+    e.xclient.window = tech_pvt->SkypiaxHandles.skype_win;
+    e.xclient.format = 8;
 
-		XSendEvent(tech_pvt->SkypiaxHandles.disp, tech_pvt->SkypiaxHandles.win, False, 0, &e);
-		XSync(tech_pvt->SkypiaxHandles.disp, False);
+    XSendEvent(tech_pvt->SkypiaxHandles.disp, tech_pvt->SkypiaxHandles.win, False, 0, &e);
+    XSync(tech_pvt->SkypiaxHandles.disp, False);
 #endif
-	}
+  }
 
-	while (x) {                 //FIXME 2 seconds?
-		x--;
-		switch_yield(20000);
-	}
+  while (x) {                   //FIXME 2 seconds?
+    x--;
+    switch_yield(20000);
+  }
 
-	if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
-		switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
-	}
+  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread) {
+    switch_thread_join(&status,
+                       globals.SKYPIAX_INTERFACES[interface_id].skypiax_signaling_thread);
+  }
 
-	if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
-		switch_thread_join(&status, globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
-	}
+  if (globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread) {
+    switch_thread_join(&status,
+                       globals.SKYPIAX_INTERFACES[interface_id].skypiax_api_thread);
+  }
 
-	memset(&globals.SKYPIAX_INTERFACES[interface_id], '\0',sizeof(private_t));
-	DEBUGA_SKYPE("interface for skype user '%s' deleted successfully\n", SKYPIAX_P_LOG, skype_user);
+  memset(&globals.SKYPIAX_INTERFACES[interface_id], '\0', sizeof(private_t));
+  DEBUGA_SKYPE("interface for skype user '%s' deleted successfully\n", SKYPIAX_P_LOG,
+               skype_user);
 end:
-	running = 1;
-	return SWITCH_STATUS_SUCCESS;
+  running = 1;
+  return SWITCH_STATUS_SUCCESS;
 }
+
 /* END: Changes here */
 
 /* 
@@ -983,10 +982,10 @@
       }
 
       /* BEGIN: Changes here */
-      if(reload_type == SOFT_RELOAD) {
-        if(interface_exists(skype_user) == SWITCH_STATUS_SUCCESS) {
-	  continue;
-	}
+      if (reload_type == SOFT_RELOAD) {
+        if (interface_exists(skype_user) == SWITCH_STATUS_SUCCESS) {
+          continue;
+        }
       }
       /* END: Changes here */
 
@@ -1622,19 +1621,19 @@
 
 /* BEGIN: Changes heres */
   } else if (!strcasecmp(argv[0], "reload")) {
-    if(load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
+    if (load_config(SOFT_RELOAD) != SWITCH_STATUS_SUCCESS) {
       stream->write_function(stream, "sk reload failed\n");
     } else {
       stream->write_function(stream, "sk reload success\n");
     }
   } else if (!strcasecmp(argv[0], "remove")) {
-    if(argc == 2) {
-      if(remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
-	if(interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
+    if (argc == 2) {
+      if (remove_interface(argv[1]) == SWITCH_STATUS_SUCCESS) {
+        if (interface_exists(argv[1]) == SWITCH_STATUS_SUCCESS) {
           stream->write_function(stream, "sk remove '%s' failed\n", argv[1]);
-	} else {
-          stream->write_function(stream, "sk remove '%s' success\n",argv[1]);
-	}
+        } else {
+          stream->write_function(stream, "sk remove '%s' success\n", argv[1]);
+        }
       }
     } else {
       stream->write_function(stream, "-ERR Usage: sk remove interface_name\n");

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h (14374 => 14375)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	2009-07-27 15:51:03 UTC (rev 14374)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax.h	2009-07-27 15:56:07 UTC (rev 14375)
@@ -37,7 +37,6 @@
 #include <switch.h>
 #include <switch_version.h>
 
-
 #ifndef WIN32
 #include <sys/time.h>
 #include <X11/Xlib.h>

Modified: freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c (14374 => 14375)


--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	2009-07-27 15:51:03 UTC (rev 14374)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/skypiax_protocol.c	2009-07-27 15:56:07 UTC (rev 14375)
@@ -181,7 +181,7 @@
               /* this is the call in which we are calling out */
               DEBUGA_SKYPE("Call %s NOTHING\n", SKYPIAX_P_LOG, id);
             } else {
-              skypiax_sleep(400000);   //0.4 seconds
+              skypiax_sleep(400000);    //0.4 seconds
               DEBUGA_SKYPE("Call %s TRY TRANSFER\n", SKYPIAX_P_LOG, id);
               skypiax_transfer(tech_pvt, id, value);
             }
@@ -252,8 +252,8 @@
             char msg_to_skype[1024];
             tech_pvt->skype_callflow = CALLFLOW_STATUS_EARLYMEDIA;
             tech_pvt->interface_state = SKYPIAX_STATE_DIALING;
-            DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n", SKYPIAX_P_LOG,
-                   id);
+            DEBUGA_SKYPE("Our remote party in skype_call %s is EARLYMEDIA\n",
+                         SKYPIAX_P_LOG, id);
             start_audio_threads(tech_pvt);
             skypiax_sleep(1000);
             sprintf(msg_to_skype, "ALTER CALL %s SET_INPUT PORT=\"%d\"", id,
@@ -391,7 +391,7 @@
                             sizeof(tech_pvt->skype_call_id) - 1);
             tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
             tech_pvt->skype_call_id[0] = '\0';
-			skypiax_sleep(1000);
+            skypiax_sleep(1000);
             return CALLFLOW_INCOMING_HANGUP;
           } else if (!strcasecmp(value, "WAITING_REDIAL_COMMAND")) {
             tech_pvt->skype_callflow = CALLFLOW_STATUS_FAILED;
@@ -402,7 +402,7 @@
                             sizeof(tech_pvt->skype_call_id) - 1);
             tech_pvt->interface_state = SKYPIAX_STATE_DOWN;
             tech_pvt->skype_call_id[0] = '\0';
-			skypiax_sleep(1000);
+            skypiax_sleep(1000);
             return CALLFLOW_INCOMING_HANGUP;
           } else {
             WARNINGA("skype_call: %s, STATUS: %s is not recognized\n", SKYPIAX_P_LOG, id,
@@ -695,7 +695,7 @@
         DEBUGA_SKYPE("ACCEPTED here you send me %d\n", SKYPIAX_P_LOG,
                      tech_pvt->tcp_cli_port);
 #ifndef WIN32
-		fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
+        fcntl(tech_pvt->audioskypepipe[0], F_SETFL, O_NONBLOCK);
 #endif //WIN32
 
         if (!running)
@@ -713,7 +713,7 @@
           if (!running)
             break;
           FD_ZERO(&fs);
-          to.tv_usec = 120000;   //120msec
+          to.tv_usec = 120000;  //120msec
           to.tv_sec = 0;
 #if defined(WIN32) && !defined(__CYGWIN__)
 /* on win32 we cannot select from the apr "pipe", so we select on socket writability */
@@ -730,63 +730,63 @@
 #endif
 
           if (rt > 0) {
-			  int counter;
+            int counter;
 
-			  /* until we drained the pipe to empty */
-			for(counter = 0; counter < 10; counter++){
-            /* read from the pipe the audio frame we are supposed to send out */
-            got =
-              skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
-                                SAMPLES_PER_FRAME * sizeof(short));
-			if(got == -1)
-				break;
+            /* until we drained the pipe to empty */
+            for (counter = 0; counter < 10; counter++) {
+              /* read from the pipe the audio frame we are supposed to send out */
+              got =
+                skypiax_pipe_read(tech_pvt->audioskypepipe[0], cli_in,
+                                  SAMPLES_PER_FRAME * sizeof(short));
+              if (got == -1)
+                break;
 
-            if (got != SAMPLES_PER_FRAME * sizeof(short)) {
-              WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
-                       (int) (SAMPLES_PER_FRAME * sizeof(short)));
-            }
+              if (got != SAMPLES_PER_FRAME * sizeof(short)) {
+                WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+                         (int) (SAMPLES_PER_FRAME * sizeof(short)));
+              }
 
-            if (got == SAMPLES_PER_FRAME * sizeof(short)) {
-              if (samplerate_skypiax == 8000) {
+              if (got == SAMPLES_PER_FRAME * sizeof(short)) {
+                if (samplerate_skypiax == 8000) {
 
-                /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
-                a = 0;
-                for (i = 0; i < got / sizeof(short); i++) {
-                  cli_out[a] = cli_in[i];
-                  a++;
-                  cli_out[a] = cli_in[i];
-                  a++;
+                  /* we're upsampling from 8khz to 16khz, cli_out will contain two times each sample from cli_in */
+                  a = 0;
+                  for (i = 0; i < got / sizeof(short); i++) {
+                    cli_out[a] = cli_in[i];
+                    a++;
+                    cli_out[a] = cli_in[i];
+                    a++;
+                  }
+                  got = got * 2;
+                } else if (samplerate_skypiax == 16000) {
+                  /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
+                  for (i = 0; i < got / sizeof(short); i++) {
+                    cli_out[i] = cli_in[i];
+                  }
+                } else {
+                  ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
                 }
-                got = got * 2;
-              } else if (samplerate_skypiax == 16000) {
-                /* we're NOT upsampling, cli_out will contain just ALL samples from cli_in */
-                for (i = 0; i < got / sizeof(short); i++) {
-                  cli_out[i] = cli_in[i];
-                }
-              } else {
-                ERRORA("SAMPLERATE_SKYPIAX can only be 8000 or 16000\n", SKYPIAX_P_LOG);
-              }
 
-              /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
-              if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
-                len = send(fd, (char *) cli_out, got, 0);
-                skypiax_sleep(5000);    //5 msec
+                /* send the 16khz frame to the Skype client waiting for incoming audio to be sent to the remote party */
+                if (tech_pvt->skype_callflow != CALLFLOW_STATUS_REMOTEHOLD) {
+                  len = send(fd, (char *) cli_out, got, 0);
+                  skypiax_sleep(5000);  //5 msec
 
-                if (len == -1) {
-                  break;
-                } else if (len != got) {
-                  ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
-                  skypiax_sleep(1000);
-                  break;
+                  if (len == -1) {
+                    break;
+                  } else if (len != got) {
+                    ERRORA("len=%d\n", SKYPIAX_P_LOG, len);
+                    skypiax_sleep(1000);
+                    break;
+                  }
                 }
-              }
 
-            } else {
+              } else {
 
-              WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
-                       (int) (SAMPLES_PER_FRAME * sizeof(short)));
+                WARNINGA("got is %d, but was expected to be %d\n", SKYPIAX_P_LOG, got,
+                         (int) (SAMPLES_PER_FRAME * sizeof(short)));
+              }
             }
-			}
           } else {
             if (rt)
               ERRORA("CLI rt=%d\n", SKYPIAX_P_LOG, rt);