From 621effd5f7c5db2a4c92923265d139f49e21366f Mon Sep 17 00:00:00 2001 From: Thomas Guillem Date: Fri, 18 Nov 2022 13:58:01 +0100 Subject: [PATCH] audiounit: refactor, add GetLatency() No functional changes. --- modules/audio_output/audiounit_ios.m | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m index 161de28982a2..c66ff9a6c61b 100644 --- a/modules/audio_output/audiounit_ios.m +++ b/modules/audio_output/audiounit_ios.m @@ -154,6 +154,18 @@ - (NSInteger)removeAoutInstance:(AoutWrapper *)wrapperInstance PORT_TYPE_HEADPHONES }; +static vlc_tick_t +GetLatency(audio_output_t *p_aout) +{ + aout_sys_t *p_sys = p_aout->sys; + + vlc_tick_t latency_us = + vlc_tick_from_sec([p_sys->avInstance outputLatency]); + + msg_Dbg(p_aout, "Current device has a latency of %lld us", latency_us); + return latency_us; +} + #pragma mark - #pragma mark AVAudioSession route and output handling @@ -182,10 +194,8 @@ - (void)audioSessionRouteChange:(NSNotification *)notification aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT); else { - const vlc_tick_t latency_us = - vlc_tick_from_sec([p_sys->avInstance outputLatency]); + const vlc_tick_t latency_us = GetLatency(p_aout); ca_SetDeviceLatency(p_aout, latency_us); - msg_Dbg(p_aout, "Current device has a new latency of %lld us", latency_us); } } @@ -580,10 +590,7 @@ static int role2policy_cmp(const void *key, const void *val) if (err != noErr) ca_LogWarn("failed to set IO mode"); - const vlc_tick_t latency_us = - vlc_tick_from_sec([p_sys->avInstance outputLatency]); - msg_Dbg(p_aout, "Current device has a latency of %lld us", latency_us); - + const vlc_tick_t latency_us = GetLatency(p_aout); ret = au_Initialize(p_aout, p_sys->au_unit, fmt, NULL, latency_us, NULL); if (ret != VLC_SUCCESS) goto error;