- Code: Select all
UInt32 audioCategory = audioInputIsAvailable ? kAudioSessionCategory_PlayAndRecord
AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (audioCategory), &audioCategory);
UInt32 allowBluetoothInput = 1;
AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, sizeof(allowBluetoothInput), &allowBluetoothInput);
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this);
kAudioSessionProperty_OverrideCategoryEnableBluetoothInput is available in in iOS 3.1 and later. While the name seems to imply that it only applies to audio input it affects audio output as well. This behavior is documented in the Audio Session Services Reference (http://developer.apple.com/library/ios/#documentation/AudioToolbox/Reference/AudioSessionServicesReference/Reference/reference.html):
"This property affects the kAudioSessionCategory_PlayAndRecord category as follows: If the audio input to the device is coming from a Bluetooth headset, setting this property to TRUE results in audio output also going to the Bluetooth headset."
I can't test right now, my already ordered bluetooth headset is still on its way from Amazon. If someone could verify if this fixes bluetooth audio that would be great.