From 80c77d9ae468a194e281042bd529269d81d7dd6e Mon Sep 17 00:00:00 2001 From: gineera Date: Sat, 8 Jun 2013 19:30:41 +0000 Subject: [PATCH] OSS: revise default latency reporting: previous fixed values could not actually be achieved with OSS power-of-2 sizes. Instead try a configuration and correctly report the default latency based on one less than the number of fragments; also fix the stream component 'bufSz' calculation. --- src/hostapi/oss/pa_unix_oss.c | 45 +++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 15 deletions(-) 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 { -- 2.43.0