Skip to content

Add iOS support to coreaudio driver#1720

Merged
derselbst merged 3 commits intoFluidSynth:masterfrom
neoharp-dev:coreaudio-ios-support
Dec 19, 2025
Merged

Add iOS support to coreaudio driver#1720
derselbst merged 3 commits intoFluidSynth:masterfrom
neoharp-dev:coreaudio-ios-support

Conversation

@neoharp-dev
Copy link
Contributor

Previously coreaudio driver was working only on MacOSX, and only way to get sound on iOS was with SDL3, which is a heavy dependency

This adds support for iOS in coreaudio driver.

It introduces COREAUDIO_SUPPORT_HAL preprocessor variable that indicated if coreaudio has HAL (that is, this is MacOSX), or not

If presense of HAL is not detected:

there is only one possible audio output, so audio.coreaudio.device is not populated.

componentSubType is set to kAudioUnitSubType_RemoteIO. This name is confusing (like, what is 'remote' about it ?), but apparently this is the way to go on iOS.

Works in test version of our iOS app (app is not yet live on app store)

@neoharp-dev
Copy link
Contributor Author

neoharp-dev commented Dec 10, 2025

Note that the code in fluid_coreaudio.c does not set up AVAudiosession for low-latency.

(edit: now it does)

@neoharp-dev neoharp-dev force-pushed the coreaudio-ios-support branch from af3750b to 72b8276 Compare December 12, 2025 12:50
@neoharp-dev
Copy link
Contributor Author

neoharp-dev commented Dec 12, 2025

Added Objective-C code to setup AVAudioSession, and also now can set "audio.coreaudio.performance-mode" setting to LowLatency to set audio session category 'AVAudioSessionCategoryPlayAndRecord' and reduce ioBufferDuration to the value closest to the duration of one period

@neoharp-dev
Copy link
Contributor Author

neoharp-dev commented Dec 12, 2025

it is unclear if there's a need to expose a setting of ioBufferDuration and if someone might want to set larger values of it than 'closest to one period'. I guess it can be done in a different PR.

@neoharp-dev neoharp-dev force-pushed the coreaudio-ios-support branch from 72b8276 to 9e86d60 Compare December 12, 2025 15:48
Copy link
Member

@derselbst derselbst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks! Two nit-picks below. Also: the iOS CI build succeeds, however, it does not compile with CoreAudio support. I would have expected, that it does compile with CoreAudio, just like MacOS CI does.

@neoharp-dev neoharp-dev force-pushed the coreaudio-ios-support branch 2 times, most recently from d300ca3 to 4338866 Compare December 17, 2025 17:04
@neoharp-dev
Copy link
Contributor Author

neoharp-dev commented Dec 17, 2025

I would have expected, that it does compile with CoreAudio, just like MacOS CI does.

Removed SDL from ios_build.sh and .github/workflows/ios.yml, now ios_build.sh enables coreaudio and not SDL3

if ( NOT COREAUDIO_SUPPORT_HAL )
enable_language( OBJC )
set ( fluid_coreaudio_SOURCES ${fluid_coreaudio_SOURCES} drivers/fluid_coreaudio_avaudiosession.m )
endif ( COREAUDIO_SUPPORT_HAL )
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
endif ( COREAUDIO_SUPPORT_HAL )
endif ( NOT COREAUDIO_SUPPORT_HAL )

Tiny oversight, that should make all CI builds succeed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks, fixed.

@neoharp-dev neoharp-dev force-pushed the coreaudio-ios-support branch from 4338866 to 0f8fa5f Compare December 19, 2025 22:03
Copy link
Member

@derselbst derselbst left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good now, thanks!

@derselbst derselbst merged commit 2761d37 into FluidSynth:master Dec 19, 2025
69 of 78 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants