summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrcombs <rcombs@rcombs.me>2022-12-09 16:32:22 -0600
committersfan5 <sfan5@live.de>2023-01-24 15:56:56 +0100
commit71346393e2b994fb3cd806453f308017a17fd174 (patch)
treece4775f7e85dcb6a6bd31ba9cef694005b09b9c8
parentae7ee7417fcd09a75f2b1d71a375233bb23e0ea6 (diff)
downloadmpv-71346393e2b994fb3cd806453f308017a17fd174.tar.bz2
mpv-71346393e2b994fb3cd806453f308017a17fd174.tar.xz
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
-rw-r--r--audio/out/ao_coreaudio_utils.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c
index b55bf1c0df..f7869c2453 100644
--- a/audio/out/ao_coreaudio_utils.c
+++ b/audio/out/ao_coreaudio_utils.c
@@ -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(