[vlc-commits] audiounit_ios: keep the sharedInstance

Thomas Guillem git at videolan.org
Thu Mar 2 18:16:52 CET 2017


vlc | branch: master | Thomas Guillem <thomas at gllm.fr> | Thu Mar  2 09:19:05 2017 +0100| [6d91163d2f80d2f1abedf54d51d5bf2069ee038d] | committer: Thomas Guillem

audiounit_ios: keep the sharedInstance

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=6d91163d2f80d2f1abedf54d51d5bf2069ee038d
---

 modules/audio_output/audiounit_ios.m | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index eeefe21..de56c65 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -68,6 +68,7 @@ struct aout_sys_t
 {
     struct aout_sys_common c;
 
+    AVAudioSession *avInstance;
     AoutWrapper *aoutWrapper;
     /* The AudioUnit we use */
     AudioUnit au_unit;
@@ -114,8 +115,8 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, unsigned channel_count,
                              enum dev_type *pdev_type,
                              AudioChannelLayout **playout)
 {
-    AVAudioSession *instance = [AVAudioSession sharedInstance];
-
+    struct aout_sys_t * p_sys = p_aout->sys;
+    AVAudioSession *instance = p_sys->avInstance;
     AudioChannelLayout *layout = NULL;
     *pdev_type = DEV_TYPE_DEFAULT;
     NSInteger max_channel_count = [instance maximumOutputNumberOfChannels];
@@ -212,8 +213,7 @@ static int
 avas_SetActive(audio_output_t *p_aout, bool active, NSUInteger options)
 {
     struct aout_sys_t * p_sys = p_aout->sys;
-
-    AVAudioSession *instance = [AVAudioSession sharedInstance];
+    AVAudioSession *instance = p_sys->avInstance;
     BOOL ret = false;
     NSError *error = nil;
 
@@ -340,7 +340,6 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
     OSStatus err;
     OSStatus status;
     AudioChannelLayout *layout = NULL;
-    AVAudioSession *instance = [AVAudioSession sharedInstance];
 
     if (aout_FormatNbChannels(fmt) == 0
      || aout_BitsPerSample(fmt->i_format) == 0 /* No Passthrough support */)
@@ -398,7 +397,7 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
         goto error;
     }
 
-    p_sys->c.i_latency_us = [instance outputLatency] * CLOCK_FREQ;
+    p_sys->c.i_latency_us = [p_sys->avInstance outputLatency] * CLOCK_FREQ;
 
     if (p_sys->b_muted)
         Pause(p_aout, true, 0);
@@ -443,6 +442,9 @@ Open(vlc_object_t *obj)
     if (unlikely(sys == NULL))
         return VLC_ENOMEM;
 
+    sys->avInstance = [AVAudioSession sharedInstance];
+    assert(sys->avInstance != NULL);
+
     sys->aoutWrapper = [[AoutWrapper alloc] initWithAout:aout];
     if (sys->aoutWrapper == NULL)
     {



More information about the vlc-commits mailing list