Android: decouple video/audio subsystems from JNI initialization#15199
Open
HTRamsey wants to merge 1 commit intolibsdl-org:mainfrom
Open
Android: decouple video/audio subsystems from JNI initialization#15199HTRamsey wants to merge 1 commit intolibsdl-org:mainfrom
HTRamsey wants to merge 1 commit intolibsdl-org:mainfrom
Conversation
Collaborator
|
I'm marking this draft until CI passes and the test plan is complete. |
4053b0e to
7a16beb
Compare
Allow Android embedders to use SDL without the full video/audio Java layer by gating subsystem-specific code behind SDL_VIDEO_DISABLED and SDL_AUDIO_DISABLED preprocessor flags. This enables applications that only need joystick/gamepad support (e.g. Qt-based apps like QGroundControl) to build SDL without shipping stub Java classes for unused subsystems. Changes: - Split SDLActivity JNI method table into core (lifecycle, hints, permissions) and video (surface, input, clipboard, orientation) - Gate SDLAudioManager and SDLInputConnection JNI registration - Make checkJNIReady() subsystem-aware: no longer requires mAudioManagerClass when SDL_AUDIO_DISABLED - Group method ID resolution by subsystem in nativeSetupJNI() - Guard all video/audio function implementations and declarations - Keep display orientation accessors always available (needed by camera) - Add subsystem-selective SDL.setupJNI(int)/initialize(int) to SDL.java with backwards-compatible zero-arg overloads - Guard SDL_VIDEO_DRIVER_ANDROID and related defines in SDL_build_config_android.h
7a16beb to
7e6af41
Compare
Contributor
|
There are going lots of merge conflicts with #14962 |
Author
|
Not really. Also most of the changes in this are trivial so rebase conflicts would be very easy to fix |
Contributor
|
it's a lot of idef indeed, but not so easy to test for someone who's not running SDL without video/audio |
Contributor
|
I'm very interested in this and can test with audio disabled. Would proguard see the final ints and strip out unused code from SDLAudioManager.java? Or can more compile conditions be put in? |
|
I'm also interested in this because I use OpenAl-Soft directly and don't seem to be using SDL_VIDEO anywhere. |
19 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Allows Android embedders to use SDL without the full video/audio Java layer by gating subsystem-specific code behind
SDL_VIDEO_DISABLEDandSDL_AUDIO_DISABLEDpreprocessor flags.This enables applications that only need joystick/gamepad support (e.g. Qt-based apps like QGroundControl) to build SDL without shipping stub Java classes for unused subsystems. Currently, QGC maintains a full set of stubbed-out
SDLActivity.java,SDLAudioManager.java, andSDLInputConnection.javafiles just to satisfy SDL's JNI requirements, even though it only uses the controller/HID subsystem.Changes
C layer (
SDL_android.c,SDL_android.h)SDLActivity_tabJNI method table into core (20 entries: lifecycle, hints, permissions, file dialog) and video (24 entries: surface, input, clipboard, orientation)JNI_OnLoad: conditionally registerSDLActivity_video_tab,SDLInputConnection, andSDLAudioManagerclassescheckJNIReady(): no longer requiresmAudioManagerClasswhenSDL_AUDIO_DISABLEDis definednativeSetupJNI(): method ID resolution split into core (always) vs video (guarded)#ifndef SDL_AUDIO_DISABLED#ifndef SDL_VIDEO_DISABLEDGetDisplayNaturalOrientation,GetDisplayCurrentOrientation) remain outside video guard, needed by camera subsystemSDL_SendAndroidBackButton()compiles as no-op when video disabled (public API, must always link)SDL_androidkeyboard.h, etc.) guardedJava layer (
SDL.java)SDL_INIT_*flag constants matchinginclude/SDL3/SDL_init.hvaluessetupJNI(int subsystems)andinitialize(int subsystems)methods for selective initializationBuild config (
SDL_build_config_android.h)SDL_VIDEO_DRIVER_ANDROID, OpenGL ES, Vulkan, and GPU defines in#ifndef SDL_VIDEO_DISABLED, matching the existing pattern used for audio/joystick/haptic/sensor/cameraUsage
Embedders can now build SDL with
-DSDL_VIDEO_DISABLED=1 -DSDL_AUDIO_DISABLED=1and initialize from Java:No
SDLAudioManager.java,SDLInputConnection.java,SDLDummyEdit.java, orSDLSurface.javarequired.SDLActivity.javaonly needs core methods (getContext,isAndroidTV,isChromebook,isDeXMode,isTablet,sendMessage, etc.).Test plan
-DSDL_VIDEO_DISABLED=1: video Java classes not required, joystick/gamepad still works-DSDL_AUDIO_DISABLED=1: audio Java class not requiredSDL.setupJNI()zero-arg call still works identically to before