ok this has to fix the issue with crappy sound cards 100% soft timer
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8305 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
414bad7785
commit
f2c5f7bebd
|
@ -70,7 +70,7 @@
|
|||
* PaUtil_WriteMemoryBarrier()
|
||||
*
|
||||
****************/
|
||||
|
||||
#define __VIA_HACK__
|
||||
#if defined(__VIA_HACK__)
|
||||
#define NO_BARRIER
|
||||
#endif
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
/************************************************************
|
||||
|
|
Loading…
Reference in New Issue