Commit Graph

11075 Commits

Author SHA1 Message Date
Sam Lantinga
5318e30ee5 Pause and resume Android audio without taking device locks
The AAudio driver implemented pause/resume by dangerously locking the audio devices. If there was an audio hotplug event or a background thread tried to interact with the audio system, this could cause deadlocks.
2024-07-29 08:41:40 -07:00
Sam Lantinga
9d35f178a6 Follow up to removing the ancient Android audio driver 2024-07-29 08:06:43 -07:00
Sam Lantinga
691cf15e75 Removed the ancient Android audio driver
OpenSLES is well supported on Android 4.0 and later.
2024-07-29 08:05:36 -07:00
Sam Lantinga
61a88077a7 Re-added SDL_HINT_APP_ID and SDL_HINT_APP_NAME 2024-07-29 07:26:03 -04:00
Ozkan Sezer
94827e0acd SDL_mslibc.c: revert PR/10303 changes 2024-07-28 22:48:05 +03:00
Sam Lantinga
45ecea1346 Fixed crash when switching a window from using OpenGL to Metal 2024-07-28 11:43:11 -07:00
Sam Lantinga
e35a559442 Revert "Add two more mapping for Nvidia controller (2019)"
This reverts commit 5d6333d6ea, which was accidentally committed during testing.
2024-07-28 11:07:59 -07:00
Arias800
5d6333d6ea Add two more mapping for Nvidia controller (2019)
0500b30c550900001472000001000000 is the ID when the controller is connected via Bluetooth and 0300b30c550900001472000011010000 is for USB mode.

Tested by setting "SDL_GAMECONTROLLERCONFIG" in some games.
2024-07-28 08:06:01 -07:00
Sam Lantinga
b5ad74998b Removed SDL_DECLSPEC_FREE 2024-07-28 07:24:21 -07:00
Sam Lantinga
a36fe632fd Added SDL_SetAppMetadata() (#10404)
Removed duplicate hints SDL_HINT_APP_NAME, SDL_HINT_APP_ID, and
SDL_HINT_AUDIO_DEVICE_APP_NAME.

Wired up a few things to use the metadata; more to come!

Fixes https://github.com/libsdl-org/SDL/issues/4703
2024-07-28 07:22:46 -07:00
hwsmm
35e42d0a25 Remove SDL_DECLSPEC_FREE before SDL_DECLSPEC in gendynapi 2024-07-27 22:31:49 -07:00
Frank Praznik
5617ce277d wayland: Don't fail to retrieve a system cursor if no window is focused
Doing this can leave the cursor data in a weird, corrupt state.
2024-07-27 20:24:24 -04:00
Sam Lantinga
f080336fa6 Fixed memory leak if logging is done after SDL_Quit()
If someone calls SDL_Quit(), then runs an SDL function that implicitly initializes TLS or logging, and then calls SDL_Quit() again, we want to make sure we run through the quit process again. Each of the Init/Quit calls are protected against being called multiple times.
2024-07-27 16:46:09 -07:00
Sam Lantinga
82c89c0125 Removed redundant subystem quit calls
SDL_Quit() quits everything
2024-07-27 16:46:09 -07:00
Sam Lantinga
95dd8781ce Do a full cleanup if renderer creation fails during autodetection 2024-07-27 16:46:09 -07:00
Sam Lantinga
ebd059e6eb Don't send keys consumed by the IME on macOS
This makes the macOS behavior match other platforms where the IME eats keys that are used for composing text.
2024-07-27 16:37:05 -07:00
Sam Lantinga
91d2dbdc9d Fixed memory leak if joysticks were initialized but gamepads were not
If a joystick is connected, SDL_IsGamepad() will be called on it, which adds it to the cache, which then needs to be cleaned up when joysticks quit.
2024-07-27 13:44:45 -07:00
Sam Lantinga
7eb2605630 Fixed memory leak when a renderer fails to be created
The supported texture formats were leaking. In order to catch future issues, we'll just do a full teardown of the renderer in the failure case, and make sure it's safe to do so with a partially initialized renderer.
2024-07-27 13:36:12 -07:00
Sam Lantinga
da035142b2 Use SDL_InitFlags for the SDL_Init* function implementations 2024-07-27 10:32:11 -07:00
Sam Lantinga
9da58e9fb7 Fixed storing a key in the persistent string hashtable that's about to be freed 2024-07-27 09:35:22 -07:00
Sam Lantinga
473feab2a4 Added SDL_unsetenv() 2024-07-27 09:10:08 -07:00
Sam Lantinga
b854e1fe0b Fixed some issues found with static analysis 2024-07-27 09:07:42 -07:00
Sam Lantinga
218e45247f Fixed memory leak when SDL_Init() was called multiple times 2024-07-27 09:06:52 -07:00
Sam Lantinga
625bc2d250 Fixed getting the initial window safe area
Fixes testsprite and testwm on desktop platforms
2024-07-27 08:40:31 -07:00
Anonymous Maarten
76f60c4b66 riscos: fix -Wunused-variable 2024-07-27 15:19:20 +00:00
Sam Lantinga
538adc52d2 Removed the temporary memory symbols from the public API 2024-07-26 21:10:47 -07:00
Sam Lantinga
4f55271571 Removed temporary memory from the API
It was intended to make the API easier to use, but various automatic garbage collection all had flaws, and making the application periodically clean up temporary memory added cognitive load to using the API, and in many cases was it was difficult to restructure threaded code to handle this.

So, we're largely going back to the original system, where the API returns allocated results and you free them.

In addition, to solve the problems we originally wanted temporary memory for:
* Short strings with a finite count, like device names, get stored in a per-thread string pool.
* Events continue to use temporary memory internally, which is cleaned up on the next event processing cycle.
2024-07-26 20:59:14 -07:00
Sam Lantinga
21411c6418 Don't apply creation window flags to external windows.
Whoever provided the window has already set it up the way they want it.

Fixes SDL removing iconified or maximized state when creating a window from an existing OS window.
2024-07-26 10:39:05 -07:00
Sam Lantinga
5e513ecc7f Don't automatically free temporary memory, let the application call SDL_FreeTemporaryMemory() when it's ready.
Also mark up all functions that return temporary memory with SDL_DECLSPEC_TEMP, to help people implementing language bindings.

Fixes https://github.com/libsdl-org/SDL/issues/10378
2024-07-26 10:05:03 -07:00
Frank Praznik
66eb2ea443 mouse: Make pointer warp emulation via relative mode available to all platforms
Move the Wayland pointer warp emulation code up to the SDL mouse layer, and activate it when a client attempts to warp a hidden mouse cursor when the hint is set.

testrelative adds the ability to test the warp emulation activation/deactivation with the --warp parameter and 'c' key for toggling cursor visibility.
2024-07-25 19:57:39 -04:00
Sam Lantinga
42650d79c1 Moved Android event initialization to SDL_InitEvents() 2024-07-25 09:25:00 -07:00
hwsmm
8fa550e003 Check window fullscreen flag in SDL_GetWindowSizeInPixels 2024-07-25 08:49:50 -07:00
Sam Lantinga
e9a7014e56 Fixed hanging after onDestroy() on Android 2024-07-25 07:34:25 -07:00
Sam Lantinga
e387314a67 Fixed building on older macOS SDK 2024-07-25 05:44:54 -07:00
Daniel Ludwig
76c4c16ca9 Fix DXGI cleanup code 2024-07-25 11:35:10 +03:00
Daniel Ludwig
ff66ec5fb5 GDK build: fix Xbox targets 2024-07-25 11:35:10 +03:00
Daniel Ludwig
7e48d4522b GDK build: move suspend/constrain setup back to previous compilation unit 2024-07-25 11:35:10 +03:00
Daniel Ludwig
0a678a654e GDK build: fix project settings and API changes 2024-07-25 11:35:10 +03:00
Sam Lantinga
cf8b158ccb Added SDL_GetRenderSafeArea() 2024-07-24 17:40:41 -07:00
Sam Lantinga
eb09264076 Added the safe area to the debug window information 2024-07-24 17:40:41 -07:00
Sam Lantinga
9e6d5babce Fixed display detection after the monitor resolution changed on X11 2024-07-24 17:46:25 -07:00
Sam Lantinga
b98e1e9ef0 Fixed the render viewport not updating when the metal view resizes
When the phone is in portrait mode and the window is in landscape mode, the view changes orientation after layoutSubviews runs. In this case we need some way of notifying the application that the Metal view has changed.
2024-07-24 16:12:29 -07:00
Sam Lantinga
e7771fb4f6 Fixed memory corruption in SDL_GetPreferredLocales()
Fixes https://github.com/libsdl-org/SDL/issues/10362
2024-07-24 13:37:40 -07:00
Sam Lantinga
c601120883 Handle all Android lifecycle events on the main thread
This restructuring also allows us to wait efficiently in SDL_WaitEvent() on Android
2024-07-24 13:37:40 -07:00
Sam Lantinga
a7c0192017 Renamed SDL_PostSemaphore() to SDL_SignalSemphore() 2024-07-24 13:37:40 -07:00
Sam Lantinga
83c7ce2681 Android life cycle behavior more closely matches iOS
On iOS, the application gets one last change to process messages before going into the background. We do the same on Android, which more closely matches the previous behavior.
2024-07-24 06:18:18 -07:00
Sam Lantinga
ca4bd4b63c Android life cycle behavior more closely matches iOS
This change also decouples the pause/resume handling from the video subsystem on Android, so applications that don't use SDL for video can get application life cycle events.

The semantics for the life cycle events are that they need to be handled in an event watch callback, and once they've been delivered, the application will block until it's been resumed. SDL_HINT_ANDROID_BLOCK_ON_PAUSE can be used to control that behavior, and if that's set to "0", then the application will continue to run in the background at low CPU usage until being resumed or stopped.

SDL_HINT_ANDROID_BLOCK_ON_PAUSE_PAUSEAUDIO has been removed, and the audio will be paused when the application is paused.

Fixes https://github.com/libsdl-org/SDL/issues/3193
2024-07-24 05:11:13 -07:00
Sam Lantinga
fff783de6c Fixed life cycle events on iOS when using main callbacks 2024-07-24 05:11:13 -07:00
Sam Lantinga
45fc548562 Don't queue application events that need to be handled immediately
This makes it more clear that these events can't be handled in the normal event loop. It also makes pause and resume transparent to applications that don't handle them, which is a nice side effect.
2024-07-24 05:11:13 -07:00
Sam Lantinga
fa0918a686 Renamed SDL life cycle functions
This maps better to how SDL delivers the events, and the iOS delegate methods are in the documentation for reference.
2024-07-24 05:11:13 -07:00