ao_coreaudio: use device's nominal sample rate for latency properties

Fixes sync issues when using high-latency devices at non-native sample rates

Closes #10984
This commit is contained in:
rcombs 2022-12-09 16:32:22 -06:00 committed by sfan5
parent ae7ee7417f
commit 71346393e2
1 changed files with 9 additions and 1 deletions

View File

@ -456,7 +456,15 @@ int64_t ca_get_device_latency_us(struct ao *ao, AudioDeviceID device)
}
}
return ca_frames_to_us(ao, latency_frames);
double sample_rate = ao->samplerate;
OSStatus err = CA_GET_O(device, kAudioDevicePropertyNominalSampleRate,
&sample_rate);
CHECK_CA_WARN("cannot get device sample rate, falling back to AO sample rate!");
if (err == noErr) {
MP_VERBOSE(ao, "Device sample rate: %f\n", sample_rate);
}
return latency_frames / sample_rate * 1e6;
}
static OSStatus ca_change_format_listener(