summaryrefslogtreecommitdiffstats
path: root/audio/out/ao_coreaudio_exclusive.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2015-07-06 17:49:28 +0200
committerwm4 <wm4@nowhere>2015-07-06 17:49:28 +0200
commit7c032bde3e6473902bbda2aea65be4bfb9d68802 (patch)
treeddfe8e980dae575321de8f34ea8d2b332652315b /audio/out/ao_coreaudio_exclusive.c
parenta56a7f3e8c7dbed38546f3ddedb0e26353f92e25 (diff)
downloadmpv-7c032bde3e6473902bbda2aea65be4bfb9d68802.tar.bz2
mpv-7c032bde3e6473902bbda2aea65be4bfb9d68802.tar.xz
ao_coreaudio: fix device latency, share the code
ao_coreaudio (using AudioUnit) accounted only for part of the latency - move the code in ao_coreaudio_exclusive to utils, and use that for the AudioUnit code. (There's still the question why CoreAudio and AudioUnit require you to jump through hoops this much, but apparently that's how it is.)
Diffstat (limited to 'audio/out/ao_coreaudio_exclusive.c')
-rw-r--r--audio/out/ao_coreaudio_exclusive.c19
1 files changed, 1 insertions, 18 deletions
diff --git a/audio/out/ao_coreaudio_exclusive.c b/audio/out/ao_coreaudio_exclusive.c
index 031bc67b9e..f8aba87188 100644
--- a/audio/out/ao_coreaudio_exclusive.c
+++ b/audio/out/ao_coreaudio_exclusive.c
@@ -320,24 +320,7 @@ static int init(struct ao *ao)
goto coreaudio_error;
}
- uint32_t latency_frames = 0;
- uint32_t latency_properties[] = {
- kAudioDevicePropertyLatency,
- kAudioDevicePropertyBufferFrameSize,
- kAudioDevicePropertySafetyOffset,
- };
- for (int n = 0; n < MP_ARRAY_SIZE(latency_properties); n++) {
- uint32_t temp;
- err = CA_GET_O(p->device, latency_properties[n], &temp);
- CHECK_CA_WARN("cannot get device latency");
- if (err == noErr) {
- latency_frames += temp;
- MP_VERBOSE(ao, "Latency property %s: %d frames\n",
- fourcc_repr(latency_properties[n]), (int)temp);
- }
- }
-
- p->hw_latency_us = ca_frames_to_us(ao, latency_frames);
+ p->hw_latency_us = ca_get_device_latency_us(ao, p->device);
MP_VERBOSE(ao, "base latency: %d microseconds\n", (int)p->hw_latency_us);
err = enable_property_listener(ao, true);