Can't access microphone when starting VoIP call in background via Siri extension

Our app uses CallKit and AVAudioEngine and requests Background Audio and VoIP background modes.


When audio is activated by an incoming VoIP push notification, everything works fine: we can activate AVAudioSessionCategoryPlayAndRecord audio session category with sample rate 44100 and AVAudioEngine.inputNode output format is reported to be <AVAudioFormat 0x1d00931f0: 1 ch, 44100 Hz, Float32>


However when recording is requested via Siri through INStartAudioCallIntent we have problems accessing microphone, namely the audio session sample rate is reported to be 48000 and the AVAudioEngine.inputNode output formtat is <AVAudioFormat 0x1d428b6d0: 2 ch, 0 Hz, Float32, non-inter>

We can also see the following error: [aurioc] 921: failed: -10851 (enable 1, outf< 2 ch, 0 Hz, Float32, non-inter> inf< 2 ch, 0 Hz, Float32, non-inter>)


In both cases the audio session is activated from provider(_ provider: CXProvider, perform action: CXStartCallAction) function of CXProviderDelegate


Thanks in anticipation, any help would be greatly appreciated!

Replies

According to Apple you should not be activating the audio session yourself, and you should wait to use it until the following method has been called:

provider(_ provider: CXProvider, didActivate audioSession: AVAudioSession)


You should still configure the session in

provider(_ provider: CXProvider, perform action: CXStartCallAction)

as well as

provider(_ provider: CXProvider, perform action: CXAnswerCallAction)

but don't activate it until the didActivate call.


Take a look at the Speakerbox sample app as well as https://forums.developer.apple.com/thread/64544