Skip to content

Commit

Permalink
auhal: rework GetLatency
Browse files Browse the repository at this point in the history
Add logs in case of failure, prepare for the next commit.
  • Loading branch information
tguillem authored and jbkempf committed Dec 2, 2022
1 parent 3e39b3a commit 1bb8234
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions modules/audio_output/auhal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1481,16 +1481,21 @@ GetLatency(audio_output_t *p_aout, const audio_sample_format_t *fmt)
{
aout_sys_t *p_sys = p_aout->sys;

/* get device latency */
UInt32 i_latency_samples;
vlc_tick_t i_latency_us = 0;
vlc_tick_t i_latency_us, i_device_latency_us = 0;
/* Get device latency */
int ret = AO_GET1PROP(p_sys->i_selected_dev, UInt32, &i_latency_samples,
kAudioDevicePropertyLatency,
kAudioObjectPropertyScopeOutput);
if (ret == VLC_SUCCESS)
i_latency_us += vlc_tick_from_samples(i_latency_samples, fmt->i_rate);
i_device_latency_us = vlc_tick_from_samples(i_latency_samples, fmt->i_rate);
else
msg_Warn(p_aout, "failed to get kAudioDevicePropertyLatency");

i_latency_us = i_device_latency_us;

msg_Dbg(p_aout, "Current device has a latency of %lld us", i_latency_us);
msg_Dbg(p_aout, "Current device has a latency of " PRId64 " us",
i_latency_us);

return i_latency_us;
}
Expand Down

0 comments on commit 1bb8234

Please sign in to comment.