| @@ -76,8 +76,7 @@ public: | |||||
| String open (const BigInteger& inputChannels, | String open (const BigInteger& inputChannels, | ||||
| const BigInteger& outputChannels, | const BigInteger& outputChannels, | ||||
| double sampleRate, | |||||
| int bufferSize) | |||||
| double sampleRate, int bufferSize) | |||||
| { | { | ||||
| close(); | close(); | ||||
| @@ -98,17 +97,14 @@ public: | |||||
| AudioSessionSetActive (true); | AudioSessionSetActive (true); | ||||
| UInt32 audioCategory = (numInputChannels > 0 && audioInputIsAvailable) ? kAudioSessionCategory_PlayAndRecord | |||||
| : kAudioSessionCategory_MediaPlayback; | |||||
| AudioSessionSetProperty (kAudioSessionProperty_AudioCategory, sizeof (audioCategory), &audioCategory); | |||||
| if (audioCategory == kAudioSessionCategory_PlayAndRecord) | |||||
| if (numInputChannels > 0 && audioInputIsAvailable) | |||||
| { | |||||
| setSessionUInt32Property (kAudioSessionProperty_AudioCategory, kAudioSessionCategory_PlayAndRecord); | |||||
| setSessionUInt32Property (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, 1); | |||||
| } | |||||
| else | |||||
| { | { | ||||
| // (note: mustn't set this until after the audio category property has been set) | |||||
| UInt32 allowBluetoothInput = 1; | |||||
| AudioSessionSetProperty (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, | |||||
| sizeof (allowBluetoothInput), &allowBluetoothInput); | |||||
| setSessionUInt32Property (kAudioSessionProperty_AudioCategory, kAudioSessionCategory_MediaPlayback); | |||||
| } | } | ||||
| AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this); | AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this); | ||||
| @@ -134,6 +130,9 @@ public: | |||||
| if (isRunning) | if (isRunning) | ||||
| { | { | ||||
| isRunning = false; | isRunning = false; | ||||
| setSessionUInt32Property (kAudioSessionProperty_AudioCategory, kAudioSessionCategory_MediaPlayback); | |||||
| AudioSessionRemovePropertyListenerWithUserData (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this); | AudioSessionRemovePropertyListenerWithUserData (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this); | ||||
| AudioSessionSetActive (false); | AudioSessionSetActive (false); | ||||
| @@ -494,15 +493,17 @@ private: | |||||
| //DBG ("audio route: " + nsStringToJuce (route)); | //DBG ("audio route: " + nsStringToJuce (route)); | ||||
| if ([route hasPrefix: @"Receiver"]) | if ([route hasPrefix: @"Receiver"]) | ||||
| { | |||||
| UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker; | |||||
| AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride); | |||||
| } | |||||
| setSessionUInt32Property (kAudioSessionProperty_OverrideAudioRoute, kAudioSessionOverrideAudioRoute_Speaker); | |||||
| CFRelease (audioRoute); | CFRelease (audioRoute); | ||||
| } | } | ||||
| } | } | ||||
| static void setSessionUInt32Property (AudioSessionPropertyID propID, UInt32 value) | |||||
| { | |||||
| AudioSessionSetProperty (propID, sizeof (value), &value); | |||||
| } | |||||
| JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice) | JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice) | ||||
| }; | }; | ||||