Revision
14666
Author
gmaruzz
Date
2009-08-28 15:04:05 -0500 (Fri, 28 Aug 2009)

Log Message

celliax: audio i/o is ok both for echo(), IVR and moh :-)

Modified Paths

Diff

Modified: freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c (14665 => 14666)


--- freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c	2009-08-28 16:18:51 UTC (rev 14665)
+++ freeswitch/branches/gmaruzz/mod_celliax/celliax_protocol.c	2009-08-28 20:04:05 UTC (rev 14666)
@@ -4799,7 +4799,8 @@
   short *buf;
   short *buf2;
   static int readpos = 0;
-  static int left = SKYPIAX_FRAME_SIZE;
+  //static int left = SKYPIAX_FRAME_SIZE;
+  static int left;
   snd_pcm_state_t state;
   int r = 0;
   int off = 0;
@@ -4822,6 +4823,64 @@
   f.delivery.tv_usec = 0;
 #endif// NOTDEF
 
+
+
+
+left = datalen;
+
+  struct timeval to;
+  fd_set rfds;
+int result;
+
+
+    FD_ZERO(&rfds);
+    FD_SET(tech_pvt->celliax_sound_capt_fd, &rfds);
+
+    /* Wait for something to happen */
+    to.tv_sec = 0;
+    to.tv_usec = 500000;        /* we select with this timeout because under cygwin we avoid the signal usage, so there is no way to end the thread if it is stuck waiting for select */
+    result = select(tech_pvt->celliax_sound_capt_fd + 1, &rfds, NULL, NULL, &to);
+
+
+
+    /* If there are errors...  */
+    if (result < 0) {
+      if (errno == EINTR) {     /* EINTR is just the select
+                                   being interrupted by a SIGURG, or so */
+        ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
+        usleep(1000);
+        //continue;
+      } else {
+        ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
+//FIXME what to do here? is the interface that failed signaled? which interface we have to disable?
+        //return NULL;
+      }
+    }
+    /* If there are no file descriptors changed, just continue  */
+
+    if (result == 0) {
+      usleep(10000);              //let's breath
+        ERRORA("select returned %d: %s\n", SKYPIAX_P_LOG, result, strerror(errno));
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
   state = snd_pcm_state(tech_pvt->alsac);
   if (state != SND_PCM_STATE_RUNNING) {
     DEBUGA_SKYPE("ALSA read state is not SND_PCM_STATE_RUNNING\n", SKYPIAX_P_LOG);
@@ -4848,7 +4907,7 @@
   buf2 = __buf2 + ((AST_FRIENDLY_OFFSET / 2) * 2);
 
   if (tech_pvt->alsa_capture_is_mono) {
-    //DEBUGA_SKYPE("buf=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, datalen, left);
+    //DEBUGA_SKYPE("buf=%p, buf+readpos=%p, datalen=%d, left=%d\n", SKYPIAX_P_LOG, (void *)buf, (void *)(buf + readpos), datalen, left);
     r = snd_pcm_readi(tech_pvt->alsac, buf + readpos, left);
   } else {
     r = snd_pcm_readi(tech_pvt->alsac, buf2 + (readpos * 2), left);

Modified: freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c (14665 => 14666)


--- freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c	2009-08-28 16:18:51 UTC (rev 14665)
+++ freeswitch/branches/gmaruzz/mod_celliax/mod_celliax.c	2009-08-28 20:04:05 UTC (rev 14666)
@@ -652,7 +652,7 @@
 int samples;
 
 		//if ((samples = snd_pcm_readi(tech_pvt->alsac, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet)) > 0) 
-		if ((samples = alsa_read(tech_pvt, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet * 2)) > 0) 
+		if ((samples = alsa_read(tech_pvt, tech_pvt->read_frame.data, tech_pvt->read_codec.implementation->samples_per_packet )) > 0) 
 
 
 {
@@ -669,7 +669,7 @@
 
 
 //usleep(17000);
-usleep(17000);
+//usleep(17000);