6

I am doing some precise measurement of audio signals on iOS using the earphones.

The audio signals vary quite significantly depending on whether the earphones are plugged into the device's 3.5mm headphone-jack or the lightning connector (the lightning includes its own ADC/DAC unit I believe).

I am therefore looking for a way to determine which port the headphones are plugged in to – lightning or headphone-jack.

When inspecting the types of the current route's output port for both connections, they both return AVAudioSessionPortHeadphones, which doesn't quite give me the granularity I need.

for (AVAudioSessionPortDescription *outputPort in [currentRoute outputs])
{
    if ([[outputPort portType] isEqualToString:AVAudioSessionPortHeadphones])
    {
        ...
    }
}

Does anyone know of a way to determine which port the AVAudioSessionPortHeadphones are connected to?

Thanks, Andy.

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Andy Barnard
  • 696
  • 1
  • 5
  • 15
  • check this URL : https://stackoverflow.com/questions/3575463/detecting-if-headphones-are-plugged-into-iphone . if it helps in any scenario. – Amit May 15 '18 at 09:48
  • Amit, the link is of no use and doesn't answer the question. I'm also trying to distinguish between headphones through headphone jack and lightning adapter with audio jack input. Have you ever found an answer to this question Andy Barnard? – Michael Nov 30 '19 at 01:17
  • Can you check [`EAAccessoryManager.connectedAccessories`](https://developer.apple.com/documentation/externalaccessory/eaaccessorymanager/1613821-connectedaccessories)? – nneonneo Nov 30 '19 at 01:33
  • 1
    It's very likely they're indistinguishable from within the code. The Lightning connector may just have an ADC sitting on the analog out is not a discrete source selected via a mux. – jpsalm Dec 06 '19 at 23:02
  • @nneonneo Checked it out but it's no use. With the headset in the audio jack and with the headset in the lightning-to-mini-jack converter there is no accessories returned when calling [EAAccessoryManager sharedAccessoryManager]connectedAccessories]; – Michael Dec 07 '19 at 19:09
  • @jpsalm it's starting to look like it. I've been digging in Apple's framework for a while now but can't find a way to distinguish between the 2 inputs. It sucks because I'm recording and playing sounds from a headset/microphone-like hardware and because of the difference between the ADC of both inputs I need different settings for the acceptance criteria. I guess it's going to be a plain old User Setting (UISwitch). – Michael Dec 07 '19 at 19:11

0 Answers0