mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
CoreAudio: Include buffer size and stream latency when calculating CoreAudio device's total latency
This commit is contained in:
parent
9a62775809
commit
a8a0342745
1 changed files with 20 additions and 7 deletions
|
|
@ -915,7 +915,7 @@ public:
|
|||
{
|
||||
const auto scope = getScope (isInput);
|
||||
|
||||
const auto latency = audioObjectGetProperty<UInt32> (parent.deviceID, { kAudioDevicePropertyLatency,
|
||||
const auto deviceLatency = audioObjectGetProperty<UInt32> (parent.deviceID, { kAudioDevicePropertyLatency,
|
||||
scope,
|
||||
juceAudioObjectPropertyElementMain }).value_or (0);
|
||||
|
||||
|
|
@ -923,7 +923,20 @@ public:
|
|||
scope,
|
||||
juceAudioObjectPropertyElementMain }).value_or (0);
|
||||
|
||||
return static_cast<int> (latency + safetyOffset);
|
||||
const auto framesInBuffer = audioObjectGetProperty<UInt32> (parent.deviceID, { kAudioDevicePropertyBufferFrameSize,
|
||||
kAudioObjectPropertyScopeWildcard,
|
||||
juceAudioObjectPropertyElementMain }).value_or (0);
|
||||
|
||||
UInt32 streamLatency = 0;
|
||||
|
||||
if (auto streams = audioObjectGetProperties<AudioStreamID> (parent.deviceID, { kAudioDevicePropertyStreams,
|
||||
scope,
|
||||
juceAudioObjectPropertyElementMain }); ! streams.empty())
|
||||
streamLatency = audioObjectGetProperty<UInt32> (streams.front(), { kAudioStreamPropertyLatency,
|
||||
scope,
|
||||
juceAudioObjectPropertyElementMain }).value_or (0);
|
||||
|
||||
return static_cast<int> (deviceLatency + safetyOffset + framesInBuffer + streamLatency);
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue