1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-02-09 04:30:09 +00:00

Fix for iOS audio device closing.

This commit is contained in:
jules 2013-09-27 20:00:39 +01:00
parent 354b5d38ae
commit 672283a1e4

View file

@ -76,8 +76,7 @@ public:
String open (const BigInteger& inputChannels,
const BigInteger& outputChannels,
double sampleRate,
int bufferSize)
double sampleRate, int bufferSize)
{
close();
@ -98,17 +97,14 @@ public:
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)
{
// (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_PlayAndRecord);
setSessionUInt32Property (kAudioSessionProperty_OverrideCategoryEnableBluetoothInput, 1);
}
else
{
setSessionUInt32Property (kAudioSessionProperty_AudioCategory, kAudioSessionCategory_MediaPlayback);
}
AudioSessionAddPropertyListener (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this);
@ -134,6 +130,9 @@ public:
if (isRunning)
{
isRunning = false;
setSessionUInt32Property (kAudioSessionProperty_AudioCategory, kAudioSessionCategory_MediaPlayback);
AudioSessionRemovePropertyListenerWithUserData (kAudioSessionProperty_AudioRouteChange, routingChangedStatic, this);
AudioSessionSetActive (false);
@ -494,15 +493,17 @@ private:
//DBG ("audio route: " + nsStringToJuce (route));
if ([route hasPrefix: @"Receiver"])
{
UInt32 audioRouteOverride = kAudioSessionOverrideAudioRoute_Speaker;
AudioSessionSetProperty (kAudioSessionProperty_OverrideAudioRoute, sizeof (audioRouteOverride), &audioRouteOverride);
}
setSessionUInt32Property (kAudioSessionProperty_OverrideAudioRoute, kAudioSessionOverrideAudioRoute_Speaker);
CFRelease (audioRoute);
}
}
static void setSessionUInt32Property (AudioSessionPropertyID propID, UInt32 value)
{
AudioSessionSetProperty (propID, sizeof (value), &value);
}
JUCE_DECLARE_NON_COPYABLE (iOSAudioIODevice)
};