mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
iOS Audio: Request exactly the desired buffersize, to avoid an issue where iOS 18 fails to apply non-power-of-2 sizes
This commit is contained in:
parent
171edbec7f
commit
d3e254e24f
1 changed files with 12 additions and 1 deletions
|
|
@ -320,7 +320,18 @@ struct iOSAudioIODevice::Pimpl final : public AsyncUpdater
|
|||
|
||||
int tryBufferSize (const double currentSampleRate, const int newBufferSize)
|
||||
{
|
||||
NSTimeInterval bufferDuration = currentSampleRate > 0 ? (NSTimeInterval) ((newBufferSize + 1) / currentSampleRate) : 0.0;
|
||||
const auto extraOffset = std::invoke ([&]
|
||||
{
|
||||
// Older iOS versions (iOS 12) seem to require that the requested buffer size is a bit
|
||||
// larger than the desired buffer size.
|
||||
// This breaks on iOS 18, which needs the buffer duration to be as precise as possible.
|
||||
if (@available (ios 18, *))
|
||||
return 0;
|
||||
|
||||
return 1;
|
||||
});
|
||||
|
||||
NSTimeInterval bufferDuration = currentSampleRate > 0 ? (NSTimeInterval) (newBufferSize + extraOffset) / currentSampleRate : 0.0;
|
||||
|
||||
auto session = [AVAudioSession sharedInstance];
|
||||
JUCE_NSERROR_CHECK ([session setPreferredIOBufferDuration: bufferDuration
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue