-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for iOS #881
base: master
Are you sure you want to change the base?
Add support for iOS #881
Conversation
Signed-off-by: Hans Petter Selasky <[email protected]>
Did my best to try fixing all of the formatting issues (manually, the patch contained a strange mix of 3-space, 4-space and tab indentation and the VSCode formatter would have preferred a different style to what the rest of the project uses). The |
In fact, the audio session is a singleton, so it's not really a question of whether to set one up, but whether we're happy with the defaults. The docs say "Although the default audio session provides useful behavior, it generally doesn’t provide the audio behavior a media app needs. To change the default behavior, you configure your app’s audio session category." [1] I notice that you mention the playback category, but if full-duplex is required that will not work.[2] Let's stew on this. I'd like to get some other people to confirm this PR works for them before merging. [1] https://developer.apple.com/documentation/avfaudio/avaudiosession |
Yeah, I might have phrased it badly, I meant setting up the singleton (as in the code snippet). The playback category is just an example there. The defaults behaving weirdly, in the sense that speaker output wouldn't work, was something that I didn't (and still don't) really understand. So I would appreciate if someone could comment on that. Another, more minor, issue I see with configuring the audio session from PortAudio is that it will introduce a new dependency on a much higher-level framework (
No, the first commit is 1-to-1 the HPS patch. |
The docs say that the default won't output audio if the phone is in silent mode, could that be the issue? |
Ah, looks like I missed that part, that would definitely explain it :D But yeah, I guess that just underlines that it's rarely the right behavior for media apps. |
Could you revise and simplify the PR description to reflect the updated state of your understanding please? |
Hm, the CI error is strange, I can't reproduce it locally, neither with Makefiles, nor with Ninja, nor with vcpkg:
I found this upstream issue, however: https://gitlab.kitware.com/cmake/cmake/-/issues/18993 |
*hostApi = &auhalHostApi->inheritedHostApiRep; | ||
|
||
(*hostApi)->info.structVersion = 1; | ||
(*hostApi)->info.type = paCoreAudio; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should iOS be using paInDevelopment
and later get its own type id or is it okay to use the same ID as the macOS Core Audio implementation, given that the two should never be available at the same time?
Failing iOS clang CI. Please you could you rebase and check. Possibly could be fixed with the fix we did on master: 7de41c1 |
Hello, I used your solution for .NET 8 iOS (with dllimport). But I think you should add this "set(CMAKE_OSX_DEPLOYMENT_TARGET "14.5")" in CMakeLists.txt. Because without this we need the latest version of iOS. And I have an issue for build that with my iOS application: 1>Xamarin.Shared.Sdk.targets(1560,3): Error : clang++ exited with code 1: I think that pa_pthread_util is not built. EDIT: I found the solution. I added to add_library(... : And it works fine. ;) |
any update ? |
There is a problem with this. The script to use the native csproj library for iOS is not correct. |
Fixes #156, fixes #749
This is a rebased version of Hans Petter Selasky's patch (originally taken from here), adding support for Core Audio on iOS. I have had success using this in an experimental iOS port of the DJ app Mixxx (see here).
Building for iOS
Building for iOS is as simple as setting the
CMAKE_SYSTEM_NAME
(on a Mac):Notes on Usage
As suggested by Alexander Carôt, setting up the shared
AVAudioSession
is generally recommended for every iOS project using this, for example like this (error handling omitted for brevity):iOS does set up a default audio session, the defaults are, however, rarely the desired configuration for a media app. For example, sound by default only plays when the phone is not on silence. Setting up the
AVAudioSession
as described above solved that.While it would probably be possible to include it in PortAudio's initialization procedure, this is (IMO) better handled by the library consumer, since it involves making decisions about whether e.g. the app should mute others etc., something different apps will likely want to handle differently.
Thoughts welcome.