mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-18 01:28:42 +00:00
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()
|
* PaUtil_WriteMemoryBarrier()
|
||||||
*
|
*
|
||||||
****************/
|
****************/
|
||||||
|
#define __VIA_HACK__
|
||||||
#if defined(__VIA_HACK__)
|
#if defined(__VIA_HACK__)
|
||||||
#define NO_BARRIER
|
#define NO_BARRIER
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,36 +145,35 @@ long ReadAudioStream(PABLIO_Stream * aStream, void *data, long numFrames, switch
|
|||||||
{
|
{
|
||||||
long bytesRead = 0;
|
long bytesRead = 0;
|
||||||
char *p = (char *) data;
|
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);
|
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);
|
PaUtil_FlushRingBuffer(&aStream->inFIFO);
|
||||||
avail = 0;
|
avail = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (avail >= numBytes * 2) {
|
bytesRead = 0;
|
||||||
bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, numBytes);
|
|
||||||
numBytes -= bytesRead;
|
if (totalBytes < neededBytes && avail >= neededBytes) {
|
||||||
readBytes += bytesRead;
|
bytesRead = PaUtil_ReadRingBuffer(&aStream->inFIFO, p, neededBytes);
|
||||||
|
totalBytes += bytesRead;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (numBytes > 0) {
|
if (bytesRead) {
|
||||||
if (switch_core_timer_check(timer, SWITCH_TRUE) == SWITCH_STATUS_SUCCESS) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
switch_yield(1000);
|
|
||||||
p += bytesRead;
|
p += bytesRead;
|
||||||
|
} else {
|
||||||
|
switch_yield(1000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (readBytes) {
|
return totalBytes / aStream->bytesPerFrame;
|
||||||
switch_core_timer_sync(timer);
|
|
||||||
}
|
|
||||||
|
|
||||||
return readBytes / aStream->bytesPerFrame;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/************************************************************
|
/************************************************************
|
||||||
|
Loading…
x
Reference in New Issue
Block a user