Slow initialisation of AudioDeviceManager on iOS


I’m developing an iOS app. I create a deviceManager with this code :

AudioDeviceManager::AudioDeviceSetup deviceSetup;
deviceSetup.bufferSize = 0; // use default value
deviceSetup.inputChannels = 2;
deviceSetup.outputChannels = 2;
deviceSetup.sampleRate = 44100;
String config = _deviceManager.initialise(2, 2, nullptr, false, "", &deviceSetup);

The last call (AudioDeviceManager::initialise) takes ages to complete. The manager is stuck in the AvailableSampleRates method sometimes for 10 sec. Is there a solution to avoid that ?

Testing device : iphone6 , iOS 11.1
Juce 5.2.0

Thanks !

Could you try with the latest version from the develop branch? We’ve made a lot of changes to the iOSAudioDevice class.

If things are still slow, then try setting JUCE_IOS_AUDIO_LOGGING=1 in the Extra Preprocessor Definitions of the iOS exporter tab in the Projucer, re-saving and re-building. This might give us some useful info.

I get

Updating hardware info
Lowest supported sample rate: 8000
Highest supported sample rate: 48000
Trying a sample rate of 9000, got 11025
Trying a sample rate of 12025, got 16000
Trying a sample rate of 17000, got 22050
Trying a sample rate of 23050, got 24000
Trying a sample rate of 25000, got 32000
Trying a sample rate of 33000, got 44100
Trying a sample rate of 45100, got 48000
Available sample rates: 8000 11025 16000 22050 24000 32000 44100 48000
Sample rate after detecting available sample rates: 44100

in well under a second from a rather old iPad.

I tested the last develop version (737c82f). It gives me the same result : worst case is 19 sec on my iphone 6 with headphones connected.

The problem does not occur on iPad Pro 10.5 inch though.

update : During my last test I messed up with Juce versions, the problem is solved with the last develop version. Thanks!

Problem solved thanks!

1 Like