Skip to content

Commit

Permalink
ao_coreaudio: fix nan in ca_get_device_latency_ns
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 authored and sfan5 committed Sep 28, 2024
1 parent c365e2f commit c3d9243
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion audio/out/ao_coreaudio_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit c3d9243

Please sign in to comment.