git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12668 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Anthony Minessale 2009-03-19 16:20:43 +00:00
parent 01540fb2da
commit c42e24e631

View File

@ -195,60 +195,60 @@ Index: src/mod/endpoints/mod_portaudio/pablio.c
+ bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes); + bytesWritten = PaUtil_WriteRingBuffer(&aStream->outFIFO, p, numBytes);
+ numBytes -= bytesWritten; + numBytes -= bytesWritten;
+ p += bytesWritten; + p += bytesWritten;
+ +
+ if (numBytes > 0) { + if (numBytes > 0) {
+ PaUtil_FlushRingBuffer(&aStream->outFIFO); + PaUtil_FlushRingBuffer(&aStream->outFIFO);
+ return 0; + return 0;
} }
return numFrames; return numFrames;
} }
@@ -171,32 +169,28 @@ @@ -170,31 +168,32 @@
long bytesRead = 0;
char *p = (char *) data; char *p = (char *) data;
long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames; long avail, totalBytes = 0, neededBytes = aStream->bytesPerFrame * numFrames;
+ int max = 5000;
- for (;;) { - for (;;) {
- avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO); - avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
+ switch_core_timer_next(timer); -
+
+ avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
- if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) { - if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
- break; - break;
- } - }
+ if (avail >= neededBytes * 6) { + switch_core_timer_next(timer);
+ PaUtil_FlushRingBuffer(&aStream->inFIFO);
+ avail = 0;
+ }
- if (avail >= neededBytes * 6) { + while(totalBytes < neededBytes && --max > 0) {
- PaUtil_FlushRingBuffer(&aStream->inFIFO); +
- avail = 0; + avail = PaUtil_GetRingBufferReadAvailable(&aStream->inFIFO);
+ //printf("AVAILABLE BYTES %ld pass %d\n", avail, 5000 - max);
if (avail >= neededBytes * 6) {
PaUtil_FlushRingBuffer(&aStream->inFIFO);
avail = 0;
- } - }
+ bytesRead = 0; + } else {
- bytesRead = 0; - bytesRead = 0;
- + bytesRead = 0;
+
+ if (totalBytes < neededBytes && avail >= neededBytes) {
+ bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
+ totalBytes += bytesRead;
+ }
- if (totalBytes < neededBytes && avail >= neededBytes) { - if (totalBytes < neededBytes && avail >= neededBytes) {
- bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes); - bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
- totalBytes += bytesRead; - totalBytes += bytesRead;
- } + if (bytesRead) {
+ p += bytesRead;
+ } else {
+ switch_cond_next();
+ }
}
- -
- if (bytesRead) { - if (bytesRead) {
- p += bytesRead; - p += bytesRead;
- } else { - } else {
- switch_cond_next(); - switch_cond_next();
- } - }
+ if (totalBytes < neededBytes && avail >= neededBytes) {
+ bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
+ totalBytes += bytesRead;
} }
+ if (bytesRead) {
+ p += bytesRead;
+ } else {
+ switch_cond_next();
+ }
+
return totalBytes / aStream->bytesPerFrame; return totalBytes / aStream->bytesPerFrame;
}