Hello!
I am making a VoIP app, and using AudioQueue for both record and playback.
AVAudioSession was set by following code:
[session setCategory:AVAudioSessionCategoryPlayAndRecord withOptions:
AVAudioSessionCategoryOptionMixWithOthers | //AVAudioSessionCategoryOptionDuckOthers | //
AVAudioSessionCategoryOptionAllowBluetooth error:nil]
Everything works fine using built-in speaker/microphone, as well as a wired headset.
But once I connected my bluetooth HFP device (eg. Airpods)
[session setPreferredInput:hfpdevice error:nil];
The usage of microphone is re-routed to my airpods correctly, but my airpods do not make any sound from the AudioQueue.
AudioStreamBasicDescription audioFormat;
bzero(&audioFormat, sizeof(AudioStreamBasicDescription));
audioFormat.mSampleRate = 44100;
audioFormat.mFormatID = kAudioFormatLinearPCM;
audioFormat.mFormatFlags = kAudioFormatFlagIsSignedInteger |
kAudioFormatFlagsNativeEndian |
kAudioFormatFlagIsPacked;
audioFormat.mFramesPerPacket = 1;
audioFormat.mChannelsPerFrame = 1;
audioFormat.mBitsPerChannel = 16;
audioFormat.mBytesPerPacket = audioFormat.mBytesPerFrame = (audioFormat.mBitsPerChannel / 8) * audioFormat.mChannelsPerFrame;