[vlc-commits] audiounit: update device latency when the route changes
Thomas Guillem
git at videolan.org
Wed Jul 17 16:55:51 CEST 2019
vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Jul 17 15:56:03 2019 +0200| [b46f49a81ce75d026b9fac1d00f5568c4a5ce6d3] | committer: Thomas Guillem
audiounit: update device latency when the route changes
This commit fixes airplay delay that may not be updated.
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=b46f49a81ce75d026b9fac1d00f5568c4a5ce6d3
---
modules/audio_output/audiounit_ios.m | 8 ++++++++
modules/audio_output/coreaudio_common.c | 9 +++++++++
modules/audio_output/coreaudio_common.h | 2 ++
3 files changed, 19 insertions(+)
diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index 13cb6b2000..812195dac7 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -154,6 +154,7 @@ enum port_type
- (void)audioSessionRouteChange:(NSNotification *)notification
{
audio_output_t *p_aout = [self aout];
+ struct aout_sys_t *p_sys = p_aout->sys;
NSDictionary *userInfo = notification.userInfo;
NSInteger routeChangeReason =
[[userInfo valueForKey:AVAudioSessionRouteChangeReasonKey] integerValue];
@@ -163,6 +164,13 @@ enum port_type
if (routeChangeReason == AVAudioSessionRouteChangeReasonNewDeviceAvailable
|| routeChangeReason == AVAudioSessionRouteChangeReasonOldDeviceUnavailable)
aout_RestartRequest(p_aout, AOUT_RESTART_OUTPUT);
+ else
+ {
+ const vlc_tick_t latency_us =
+ vlc_tick_from_sec([p_sys->avInstance outputLatency]);
+ ca_SetDeviceLatency(p_aout, latency_us);
+ msg_Dbg(p_aout, "Current device has a new latency of %lld us", latency_us);
+ }
}
- (void)handleInterruption:(NSNotification *)notification
diff --git a/modules/audio_output/coreaudio_common.c b/modules/audio_output/coreaudio_common.c
index 0814f2a17c..3a9ec69113 100644
--- a/modules/audio_output/coreaudio_common.c
+++ b/modules/audio_output/coreaudio_common.c
@@ -411,6 +411,15 @@ ca_SetAliveState(audio_output_t *p_aout, bool alive)
vlc_sem_post(&p_sys->flush_sem);
}
+void ca_SetDeviceLatency(audio_output_t *p_aout, vlc_tick_t i_dev_latency_us)
+{
+ struct aout_sys_common *p_sys = (struct aout_sys_common *) p_aout->sys;
+
+ lock_lock(p_sys);
+ p_sys->i_dev_latency_us = i_dev_latency_us;
+ lock_unlock(p_sys);
+}
+
AudioUnit
au_NewOutputInstance(audio_output_t *p_aout, OSType comp_sub_type)
{
diff --git a/modules/audio_output/coreaudio_common.h b/modules/audio_output/coreaudio_common.h
index 1630c7f0c6..11c73b31e4 100644
--- a/modules/audio_output/coreaudio_common.h
+++ b/modules/audio_output/coreaudio_common.h
@@ -103,6 +103,8 @@ void ca_Uninitialize(audio_output_t *p_aout);
void ca_SetAliveState(audio_output_t *p_aout, bool alive);
+void ca_SetDeviceLatency(audio_output_t *p_aout, vlc_tick_t i_dev_latency_us);
+
AudioUnit au_NewOutputInstance(audio_output_t *p_aout, OSType comp_sub_type);
int au_Initialize(audio_output_t *p_aout, AudioUnit au,
More information about the vlc-commits
mailing list