From: gineera Date: Sat, 8 Jun 2013 19:30:41 +0000 (+0000) Subject: OSS: revise default latency reporting: previous fixed values could not actually be... X-Git-Tag: pa_stable_v19_20140130_r1919~16 X-Git-Url: https://andrewgundersen.net/repos?a=commitdiff_plain;h=80c77d9ae468a194e281042bd529269d81d7dd6e;p=portaudio 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. --- 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 {