diff --git a/src/hostapi/oss/pa_unix_oss.c b/src/hostapi/oss/pa_unix_oss.c index a9244b4..51e9630 100644 --- a/src/hostapi/oss/pa_unix_oss.c +++ b/src/hostapi/oss/pa_unix_oss.c @@ -318,6 +318,13 @@ error: return result; } +static int CalcHigherLogTwo( int n ) +{ + int log2 = 0; + while( (1<> 16) - 1) * fragFrames / *defaultSampleRate; + + /* Cannot now try setting a high latency (device would need closing and opening again). Make + * high-latency 4 times the low unless the fragFrames are significantly more than requested 128 */ + temp = (fragFrames < 256) ? 4 : (fragFrames < 512) ? 2 : 1; + *defaultHighLatency = temp * *defaultLowLatency; error: if( devHandle >= 0 ) @@ -962,13 +983,6 @@ static unsigned long PaOssStreamComponent_BufferSize( PaOssStreamComponent *comp return PaOssStreamComponent_FrameSize( component ) * component->hostFrames * component->numBufs; } -static int CalcHigherLogTwo( int n ) -{ - int log2 = 0; - while( (1<latency * sampleRate); - fragSz = bufSz / 4; + /* Aim for 4 fragments in the complete buffer; the latency comes from 3 of these */ + fragSz = (unsigned long)(component->latency * sampleRate / 3); + bufSz = fragSz * 4; } else {