1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

iOS Audio: Allow specifying a fixed set of preferred sample rates

By defining JUCE_IOS_AUDIO_EXPLICIT_SAMPLERATES, the iOS audio device
will always use the requested samplerates instead of querying the
current audio device for the samplerates it supports. This is useful
because certain hardware (such as the Focusrite iTrack Dock) takes a
long time to set new samplerates, which can end up freezing the main
thread for significant lengths of time.

This approach is inspired by the AUM app for iOS, which appears to
provide a fixed list of "allowed" samplerates, rather than querying the
device for its allowed samplerates.
This commit is contained in:
reuk 2021-08-05 19:05:25 +01:00
parent 3f5862cf17
commit fd87195941
No known key found for this signature in database
GPG key ID: 9ADCD339CFC98A11

View file

@ -25,7 +25,13 @@ namespace juce
class iOSAudioIODevice;
static const char* const iOSAudioDeviceName = "iOS Audio";
constexpr const char* const iOSAudioDeviceName = "iOS Audio";
#ifndef JUCE_IOS_AUDIO_EXPLICIT_SAMPLERATES
#define JUCE_IOS_AUDIO_EXPLICIT_SAMPLERATES
#endif
constexpr std::initializer_list<double> iOSExplicitSampleRates { JUCE_IOS_AUDIO_EXPLICIT_SAMPLERATES };
//==============================================================================
struct AudioSessionHolder
@ -356,6 +362,12 @@ struct iOSAudioIODevice::Pimpl : public AudioPlayHead,
// depending on whether the headphones are plugged in or not!
void updateAvailableSampleRates()
{
if (iOSExplicitSampleRates.size() != 0)
{
availableSampleRates = Array<double> (iOSExplicitSampleRates);
return;
}
availableSampleRates.clear();
AudioUnitRemovePropertyListenerWithUserData (audioUnit,