Skip to content

Commit

Permalink
audiounit: refactor, add GetLatency()
Browse files Browse the repository at this point in the history
No functional changes.
  • Loading branch information
tguillem authored and jbkempf committed Dec 2, 2022
1 parent 9020106 commit 621effd
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions modules/audio_output/audiounit_ios.m
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 621effd

Please sign in to comment.