]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
ok this has to fix the issue with crappy sound cards 100% soft timer
authorAnthony Minessale <anthony.minessale@gmail.com>
Thu, 8 May 2008 16:20:15 +0000 (16:20 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Thu, 8 May 2008 16:20:15 +0000 (16:20 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8305 d0543943-73ff-0310-b7d9-9358b9ac24b2

src/mod/endpoints/mod_portaudio/pa_ringbuffer.c
src/mod/endpoints/mod_portaudio/pablio.c

index 41342f2e2dff01183754a91973886181a1eb1ea7..b632c0608482a93db3c18079ab52c94cad208e2c 100644 (file)
@@ -70,7 +70,7 @@
  * PaUtil_WriteMemoryBarrier()
  *
  ****************/
-
+#define __VIA_HACK__
 #if defined(__VIA_HACK__)
 #define NO_BARRIER
 #endif
index c4be4bc77ffd7d7dfdb09c2f17b45e895399f263..a38ca925ba961484d859d19004d982e9ebf6757f 100644 (file)
@@ -145,36 +145,35 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
 {
        long bytesRead = 0;
        char *p = (char *) data;
-       long avail, readBytes = 0, numBytes = aStream->bytesPerFrame * numFrames;
+       long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames;
        
-       while (numBytes > 0) {
+       for(;;) {
                avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
-
-               if (avail >= numBytes * 10) {
+               
+               if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
+                       break;
+               }
+               
+               if (avail >= neededBytes * 6) { 
                        PaUtil_FlushRingBuffer(&aStream->inFIFO);
                        avail = 0;
                }
                
-               if (avail >= numBytes * 2) {
-                       bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
-                       numBytes -= bytesRead;
-                       readBytes += bytesRead;
+               bytesRead = 0;
+
+               if (totalBytes < neededBytes && avail >= neededBytes) {
+                       bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
+                       totalBytes += bytesRead;
                }
                
-               if (numBytes > 0) {
-                       if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
-                               break;
-                       }
-                       switch_yield(1000);
+               if (bytesRead) {
                        p += bytesRead;
+               } else {
+                       switch_yield(1000);
                }
        }
 
-       if (readBytes) {
-               switch_core_timer_sync(timer);
-       }
-
-       return readBytes / aStream->bytesPerFrame;
+       return totalBytes / aStream->bytesPerFrame;
 }
 
 /************************************************************