iOS doesn't initialize the sample rate correctly


#1

I justed updated to the latest juce, from a version a few months old. In the simiulator my audio devices are opening at 8000hz instead of 44100hz.

Looking into the code, 

currentSetup.sampleRate = chooseBestSampleRate (newSetup.sampleRate);

is called before 

updateSampleRates();

In chooseBestSampleRate, since rates is empty, when rates[0] is returned it returns garbage data. I'm assuming by some coincendece due to memory layout it used to return 44100, now it returns 8000.

double AudioDeviceManager::chooseBestSampleRate (double rate) const
{
    jassert (currentAudioDevice != nullptr);

    const Array<double> rates (currentAudioDevice->getAvailableSampleRates());

    if (rate > 0 && rates.contains (rate))
        return rate;

    double lowestAbove44 = 0.0;

    for (int i = rates.size(); --i >= 0;)
    {
        const double sr = rates[i];
        if (sr >= 44100.0 && (lowestAbove44 < 1.0 || sr < lowestAbove44))
            lowestAbove44 = sr;
    }

    if (lowestAbove44 > 0.0)
        return lowestAbove44;

    return rates[0];
}

#2

Ok, thanks, I'll take a look at that.


#3

I wanted to confirm that I was having this problem, but latest Juce seems to have indeed fixed it.