[Freeswitch-svn] [commit] r8294 - freeswitch/trunk/src/mod/endpoints/mod_portaudio

Freeswitch SVN anthm at freeswitch.org
Wed May 7 12:32:05 EDT 2008


Author: anthm
Date: Wed May  7 12:32:04 2008
New Revision: 8294

Modified:
   freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
   freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c

Log:
testing beware

Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/mod_portaudio.c	Wed May  7 12:32:04 2008
@@ -552,7 +552,7 @@
 		globals.read_frame.datalen = samples * 2;
 		globals.read_frame.samples = samples;
 
-		switch_core_timer_check(&globals.timer, SWITCH_TRUE);
+		//switch_core_timer_check(&globals.timer, SWITCH_TRUE);
 		*frame = &globals.read_frame;
 
 		if (!switch_test_flag((&globals), GFLAG_MOUTH)) {

Modified: freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c
==============================================================================
--- freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c	(original)
+++ freeswitch/trunk/src/mod/endpoints/mod_portaudio/pablio.c	Wed May  7 12:32:04 2008
@@ -145,20 +145,36 @@
 {
 	long bytesRead;
 	char *p = (char *) data;
-	long numBytes = aStream->bytesPerFrame * numFrames;
+	long avail, readBytes = 0, numBytes = aStream->bytesPerFrame * numFrames;
 	
 	while (numBytes > 0) {
-		bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
-		numBytes -= bytesRead;
+		avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
+
+		if (avail >= numBytes * 10) {
+			PaUtil_FlushRingBuffer(&aStream->inFIFO);
+			avail = 0;
+		}
+
+		if (avail >= numBytes) {
+			bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
+			numBytes -= bytesRead;
+			readBytes += bytesRead;
+		}
+		
 		if (numBytes > 0) {
 			if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
-				PaUtil_FlushRingBuffer(&aStream->inFIFO);
-				return 0;
+				break;
 			}
 			switch_yield(1000);
+			p += bytesRead;
 		}
 	}
-	return numFrames;
+
+	if (readBytes) {
+		switch_core_timer_sync(timer);
+	}
+
+	return readBytes / aStream->bytesPerFrame;
 }
 
 /************************************************************



More information about the Freeswitch-svn mailing list