PA/CoreAudio recommended deviceInfo->default*Latency is 0
The PA/CoreAudio implementation reports 0 recommended latency for all devices.
META TICKET: #97 [META] Some PA recommended deviceInfo->default*Latency values are bad or unimplemented
See also:
#182 PA/CoreAudio ignores Pa_OpenStream() suggestedLatency param
META TICKET: #97 [META] Some PA recommended deviceInfo->default*Latency values are bad or unimplemented
See also:
#182 PA/CoreAudio ignores Pa_OpenStream() suggestedLatency param
Leave a comment
I cannot reproduce the error. When I run pa_devs.c I get non-zero values for latency. From pa_mac_core.c, these default values are set:
deviceInfo->defaultLowInputLatency = .01;
deviceInfo->defaultHighInputLatency = .10;
deviceInfo->defaultLowOutputLatency = .01;
deviceInfo->defaultHighOutputLatency = .10;
then the latency in frames is queried:
AudioDeviceGetProperty( ..., kAudioDevicePropertyLatency, ... )
that is converted to seconds:
double secondLatency = frameLatency / deviceInfo->defaultSampleRate;
then the default latencies are updated based on that:
deviceInfo->defaultLowOutputLatency = 3 * secondLatency;
deviceInfo->defaultHighOutputLatency = 3 * 10 * secondLatency;
This seems fairly reasonable. I cannot explain why a latency of zero would be returned unless frameLatency was zero. So I added a trap for frameLatency==0 and use the original defaults in that case.
deviceInfo->defaultLowInputLatency = .01;
deviceInfo->defaultHighInputLatency = .10;
deviceInfo->defaultLowOutputLatency = .01;
deviceInfo->defaultHighOutputLatency = .10;
then the latency in frames is queried:
AudioDeviceGetProperty( ..., kAudioDevicePropertyLatency, ... )
that is converted to seconds:
double secondLatency = frameLatency / deviceInfo->defaultSampleRate;
then the default latencies are updated based on that:
deviceInfo->defaultLowOutputLatency = 3 * secondLatency;
deviceInfo->defaultHighOutputLatency = 3 * 10 * secondLatency;
This seems fairly reasonable. I cannot explain why a latency of zero would be returned unless frameLatency was zero. So I added a trap for frameLatency==0 and use the original defaults in that case.
Some useful info from Jeff Moore on latency at:
http://osdir.com/ml/coreaudio-api/2010-01/msg00046.html
http://osdir.com/ml/coreaudio-api/2009-07/msg00140.html
I added some calls to query the properties that Jeff mentions. On my MacBook:
kAudioDevicePropertyLatency had values of 0,10,15. o was for aggregate device.
kAudioStreamPropertyLatency had values of 0,10,15,48. 48 was for a USB headset.
kAudioDevicePropertyBufferFrameSize was always 512.
kAudioDevicePropertySafetyOffset was 32,50,65,134.
http://osdir.com/ml/coreaudio-api/2010-01/msg00046.html
http://osdir.com/ml/coreaudio-api/2009-07/msg00140.html
I added some calls to query the properties that Jeff mentions. On my MacBook:
kAudioDevicePropertyLatency had values of 0,10,15. o was for aggregate device.
kAudioStreamPropertyLatency had values of 0,10,15,48. 48 was for a USB headset.
kAudioDevicePropertyBufferFrameSize was always 512.
kAudioDevicePropertySafetyOffset was 32,50,65,134.
Another useful link from Jeff Moore:
>In software play through, the latency (in sample frames) is determined by the following formula (presuming the play through is happening on the same device in the same IO proc):
>
>Input Latency + Input Safety Offset + (2* IO buffer Size) + Output Safety Offset + Output Latency
http://lists.apple.com/archives/coreaudio-api/2004/Jan/msg00445.html
>In software play through, the latency (in sample frames) is determined by the following formula (presuming the play through is happening on the same device in the same IO proc):
>
>Input Latency + Input Safety Offset + (2* IO buffer Size) + Output Safety Offset + Output Latency
http://lists.apple.com/archives/coreaudio-api/2004/Jan/msg00445.html