mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
iOS Audio: Always deactivate device before setting new preferred samplerate
This fixes a bug on iOS 17 running on a 9th gen iPad. - Set JUCE_IOS_AUDIO_EXPLICIT_SAMPLERATES=44100,48000,88200,96000 - Start the DemoRunner. - Add a breakpoint in AudioDeviceManager::audioDeviceAboutToStartInt(). - In the DemoRunner, change the sample rate to 96000. - The breakpoint will fire. Observe the value of getCurrentBufferSizeSamples(). - Move the breakpoint to audioDeviceIOCallbackInt and continue execution. - The breakpoint will fire. Observe the value of the numSamples parameter. numSamples should always be no larger than the sample count reported in audioDeviceAboutToStartInt(). Before this change, it was possible for getCurrentBufferSizeSamples() to return a value smaller than the buffer size of subsequent process callbacks. Removing the availability checks and unconditionally deactivating/reactivating the device seems to fix this issue, and the correct buffer size is returned immediately when the device is (re)started.
This commit is contained in:
parent
1189687611
commit
3506d66fae
1 changed files with 2 additions and 4 deletions
|
|
@ -426,13 +426,11 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
|
|||
// a call to setActive, so we also need to wait for the first audio callback.
|
||||
// This will be slow!
|
||||
// https://developer.apple.com/library/archive/qa/qa1631/_index.html
|
||||
if (@available (ios 18, *))
|
||||
setAudioSessionActive (false);
|
||||
setAudioSessionActive (false);
|
||||
|
||||
JUCE_NSERROR_CHECK ([session setPreferredIOBufferDuration: bufferDuration error: &error]);
|
||||
|
||||
if (@available (ios 18, *))
|
||||
setAudioSessionActive (true);
|
||||
setAudioSessionActive (true);
|
||||
|
||||
return getBufferSize (currentSampleRate);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue