]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
testing beware
authorAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 May 2008 16:32:04 +0000 (16:32 +0000)
committerAnthony Minessale <anthony.minessale@gmail.com>
Wed, 7 May 2008 16:32:04 +0000 (16:32 +0000)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8294 d0543943-73ff-0310-b7d9-9358b9ac24b2

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

index 8f7aa424df9e077c8f3126adbc73c498e1d27870..52f77bb28a26ce5e3aafce40e1b2c55c73eec052 100644 (file)
@@ -552,7 +552,7 @@ static switch_status_t channel_read_frame(switch_core_session_t *session, switch
                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)) {
index b88b7eed4ebbb23ad4cac70e8965b3f98dab5223..ab1d907e02716df4b9e889f97127168c8e4139ac 100644 (file)
@@ -145,20 +145,36 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
 {
        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;
 }
 
 /************************************************************