[vlc-commits] AudioUnit iOS: add headphone detection

Felix Paul Kühne git at videolan.org
Sun Jul 23 17:39:32 CEST 2017


vlc | branch: master | Felix Paul Kühne <fkuehne at videolan.org> | Sun Jul 23 16:58:19 2017 +0200| [0d5f8eb81960cf33d2fcb3898f7345a75ca646cf] | committer: Felix Paul Kühne

AudioUnit iOS: add headphone detection

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

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

diff --git a/modules/audio_output/audiounit_ios.m b/modules/audio_output/audiounit_ios.m
index b189264ff2..9ef7e2a281 100644
--- a/modules/audio_output/audiounit_ios.m
+++ b/modules/audio_output/audiounit_ios.m
@@ -95,7 +95,8 @@ enum port_type
 {
     PORT_TYPE_DEFAULT,
     PORT_TYPE_USB,
-    PORT_TYPE_HDMI
+    PORT_TYPE_HDMI,
+    PORT_TYPE_HEADPHONES
 };
 
 #pragma mark -
@@ -189,6 +190,8 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, enum port_type *pport_type,
             port_type = PORT_TYPE_USB;
         else if ([out.portType isEqualToString: AVAudioSessionPortHDMI])
             port_type = PORT_TYPE_HDMI;
+        else if ([out.portType isEqualToString: AVAudioSessionPortHeadphones])
+            port_type = PORT_TYPE_HEADPHONES;
         else
             port_type = PORT_TYPE_DEFAULT;
 
@@ -245,7 +248,8 @@ avas_GetOptimalChannelLayout(audio_output_t *p_aout, enum port_type *pport_type,
 
     msg_Dbg(p_aout, "Output on %s, channel count: %u",
             *pport_type == PORT_TYPE_HDMI ? "HDMI" :
-            *pport_type == PORT_TYPE_USB ? "USB" : "Default",
+            *pport_type == PORT_TYPE_USB ? "USB" :
+            *pport_type == PORT_TYPE_HEADPHONES ? "Headphones" : "Default",
             layout ? (unsigned) layout->mNumberChannelDescriptions : 2);
 
     *playout = layout;
@@ -404,6 +408,8 @@ Start(audio_output_t *p_aout, audio_sample_format_t *restrict fmt)
             goto error;
     }
 
+    p_aout->current_sink_info.headphones = port_type == PORT_TYPE_HEADPHONES;
+
     p_sys->au_unit = au_NewOutputInstance(p_aout, kAudioUnitSubType_RemoteIO);
     if (p_sys->au_unit == NULL)
         goto error;



More information about the vlc-commits mailing list