From c3d9243a3eadf3d7eecdb11c8c98e5d88862ab12 Mon Sep 17 00:00:00 2001 From: Misaki Kasumi Date: Fri, 27 Sep 2024 11:01:03 +0800 Subject: [PATCH] ao_coreaudio: fix nan in ca_get_device_latency_ns --- audio/out/ao_coreaudio_utils.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/audio/out/ao_coreaudio_utils.c b/audio/out/ao_coreaudio_utils.c index 78cdcad393..f06d3fae26 100644 --- a/audio/out/ao_coreaudio_utils.c +++ b/audio/out/ao_coreaudio_utils.c @@ -442,12 +442,14 @@ int64_t ca_get_device_latency_ns(struct ao *ao, AudioDeviceID device) } } - double sample_rate = ao->samplerate; + double sample_rate; 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); + } else { + sample_rate = ao->samplerate; } return MP_TIME_S_TO_NS(latency_frames / sample_rate);