1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

iOS Audio: Ensure current sampleRate and bufferSize are always updated after querying sample rates

The code added in 6f20de5434 was only
executed when no explicit sample rates were set.

Now, the sample rate is always updated after querying available sample
rates and before querying available buffer sizes, so that the buffer
size check is guaranteed to use an up-to-date samplerate value.
This commit is contained in:
reuk 2024-11-18 21:54:08 +00:00
parent 9de56d0aab
commit 55fb6dbe62
No known key found for this signature in database
GPG key ID: FCB43929F012EE5C

View file

@ -518,10 +518,6 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
availableSampleRates.addIfNotAlreadyThere (highestRate);
// Reset sample rate back to the original, so that we don't end up stuck on the highest rate
sampleRate = trySampleRate (sampleRate);
bufferSize = getBufferSize (sampleRate);
AudioUnitAddPropertyListener (audioUnit,
kAudioUnitProperty_StreamFormat,
dispatchAudioUnitPropertyChange,
@ -553,6 +549,13 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
JUCE_IOS_AUDIO_LOG ("Updating hardware info");
updateAvailableSampleRates();
// The sample rate and buffer size may have been affected by
// updateAvailableSampleRates(), so try restoring the last good
// sample rate
sampleRate = trySampleRate (sampleRate);
bufferSize = getBufferSize (sampleRate);
updateAvailableBufferSizes();
if (deviceType != nullptr)