PA/CoreAudio may use non-optimal host buffer sizes in some corner cases
CalculateOptimalBufferSize() in pa_mac_core.c computes the host buffer size based on the suggestedLatency parameter. r1762 adds a fix to try to ensure that the host buffer size is a multiple of the user buffer size. However, this isn't the case if the buffer size is then clamped to the minimum and maximum device buffer size.
I think the correct fix should be:
When requestedFramesPerBuffer is less than or equal to the maximum allowed device buffer size CalculateOptimalBufferSize() should return a multiple of requestedFramesPerBuffer based on suggestedLatency. The multiple should be chosen such that the total latency is greater than or equal to suggestedLatency, subject to constraints imposed by max allowable device buffer size.
When requestedFramesPerBuffer exceeds the maximum allowed device buffer size other heuristics may be appropriate (to be discussed).
I think the correct fix should be:
When requestedFramesPerBuffer is less than or equal to the maximum allowed device buffer size CalculateOptimalBufferSize() should return a multiple of requestedFramesPerBuffer based on suggestedLatency. The multiple should be chosen such that the total latency is greater than or equal to suggestedLatency, subject to constraints imposed by max allowable device buffer size.
When requestedFramesPerBuffer exceeds the maximum allowed device buffer size other heuristics may be appropriate (to be discussed).
Leave a comment