0

We write app that records audio in background. We use AVAudioSession with AVAudioSessionCategoryPlayAndRecord category and AVAudioSessionCategoryOptionAllowBluetooth option:

AVAudioSession *session = [AVAudioSession sharedInstance];
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions: AVAudioSessionCategoryOptionMixWithOthers | AVAudioSessionCategoryOptionDefaultToSpeaker | AVAudioSessionCategoryOptionAllowBluetooth  error:&error];

We noticed the strange issue - when iPhone connected to Multimedia Car Bluetooth system and our app runs, there are shown phone call from device to itself (the call continues during all device connection to bluetooth system). When we close app - the call is ended, when we open app again - call begins and etc. This issue reproduces on all Multimedia Bluetooth systems. How can we fix it? Thanks

tatiana_c
  • 948
  • 7
  • 16
  • 31
  • I think the Multimedia Car Bluetooth system take the audio as calling but you really did not call; you can sniffer the air trace to see what happen; or observer the iOS log to see whether it sending some audio starts indication or other kind of thinks confused the carkit. – Guo Xingmin Sep 13 '16 at 09:01
  • @ Guo Xingmin thanks for answer, how can I sniff the air trace? – tatiana_c Sep 13 '16 at 13:14
  • If you are a Bluetooth developer you would have the sniffer, it is a debug tools for you to look up the air log. However if you do not have such tools, you may need find out the "Multimedia Bluetooth systems". – Guo Xingmin Sep 14 '16 at 02:07
  • @ Guo Xingmin thanks! – tatiana_c Sep 14 '16 at 08:48

1 Answers1

0

Think you need to add AVAudioSessionCategoryOptionAllowBluetoothA2DP instead of the old HFP profile. The call is used to make older bluetooth devices to work.

With iOS 10, Apple added the option AVAudioSessionCategoryOptionAllowBluetoothA2DP. They also changed the meaning of AudioSessionCategoryOptionAllowBluetooth to only allow output using the HFP Bluetooth profile, which is where you get the low quality audio output.

If you use this new option in place of the AudioSessionCategoryOptionAllowBluetooth option in your code snippet, it will allow high quality output but disallow low quality audio output.

Here's the online documentation for the options, but unfortunately there's no description for the new iOS 10 options online. You can see more detail in the in-code documentation in AVAudioSession.h https://developer.apple.com/reference/avfoundation/avaudiosessioncategoryoptions?language=objc

Info from: Keep bluetooth sound when initializing AVAudioSession

Community
  • 1
  • 1
Sjoerd Perfors
  • 2,317
  • 22
  • 37