Now this keeps one FBO for each SDL_TEXTUREACCESS_TARGET texture, and doesn't
reuse it. We check if the FBO is "complete" once, at creation time, and
setting a render target merely has to bind the right FBO and never look back.
This simplifies the code and removes a guaranteed pipeline stall when setting
a new render target.
(This code merged over from the GLES2 renderer, from changes made in
56e0d052f18938e8d9c6cfe11d87d118afc1990d.)
Fixes#16839.
Now this keeps one FBO for each SDL_TEXTUREACCESS_TARGET texture, and doesn't
reuse it. We check if the FBO is "complete" once, at creation time, and
setting a render target merely has to bind the right FBO and never look back.
This simplifies the code and removes a guaranteed pipeline stall when setting
a new render target.
(This code merged over from the GLES2 renderer, from changes made in
56e0d052f18938e8d9c6cfe11d87d118afc1990d.)
Reference Issue #16839.
This shows some helpful tips about how to submit good bugs and has a checkbox
saying something like "I promise this isn't just a wall of LLM-generated text."
(Strictly speaking, these are Uint64 on most things we care about, but the
goal here is to remove the sign conversion, which can cause problems depending
on your Visual and CPU, not to get into color formats we've never supported
and probably aren't widespread anyhow.)
Fixes#16513.
- They now work when the app specifies a NULL spec (verses a spec with zero'd
fields).
- They now favor the hint, falling back to the device's default settings
(before they would fall back to `DEFAULT_AUDIO_*` defines, but it's better
to default to what the hardware natively offers, and if the device doesn't
specify a default, they'll be set to those defines earlier anyhow). This
uses `device->default_spec` instead of `device->spec` so if something opens
the device at a low-quality, it doesn't force all future default opens to
conform to it.
- Hint docs now explain this.
Fixes#16652.
Runs after a successful OpenDevice call, _without the device lock held_.
The immediate need is that the JACK backend calls jack_activate() during
device open, which blocks until stuff happens on an internal, JACK-controlled
thread. But several things this thread might do will obtain the SDL audio
device lock, which is being held until after jack_activate returns. So now we
do everything _but_ activate during OpenDevice(), and activate starts
everything flowing during PostOpenDevice() now.
Other backends (PipeWire, PulseAudio, etc) might have similar problems with
other workarounds in place, but might benefit from PostOpenDevice in the same
way.
Fixes#16551.
- Now the writer increments a global variable, and readers report on its
current value, which shows not just what order things lock, but also that
serialization is happening appropriately.
- Readers will, once we hit the timeout, sleep and never try to grab the lock,
so even if normal operation results in complete starvation (launch with
`--nbthreads 1000`, etc), the writer will be able to obtain the lock
shortly after the time limit and everything will shut down in orderly
fashion.
- Other minor cleanups and tweaks.
Fixes#15346.
This builds SDL with CMake, like a normal library, and a small app with
"hvigor", which is HarmonyOS's equivalent to Android's gradle, to test the
parts that CMake doesn't touch.
This is added to the non-priority builds.
[sdl-ci-filter *]
We had logic to do this, but due to the nature of iOS, we never actually
called it because the process terminated before we could. This was likely
true on Android, HarmonyOS, and Emscripten, too, so this adds a new interface
that various platforms can use as appropriate when the event fires.
The generic implementation just attempts to set apprc to success, which will
result in normal process termination, including calling SDL_AppQuit(), which
matched current behavior, but to be fair, all the platforms that use the
generic backend shouldn't ever fire this event.
When calling SDL_AppQuit() due to SDL_EVENT_TERMINATING, the other backends
leave the SDL_AppResult as SDL_APP_CONTINUE (assuming SDL_AppEvent() didn't
respond to SDL_EVENT_TERMINATING by returning a terminating result), so that
SDL_AppQuit() has a signal that they have arrived at termination in an unusual
way, instead of the app explicitly requesting it.
Fixes#16457.
It's the only thing you would need to query with an external function, and the
pen ID could be invalid by the time you run the event queue, so it's easier to
just include it with the events.
Fixes#16316.
Nothing in here has public API documentation (intentionally), and since it's
in the same category as SDL_main.h, it would overwrite its function-order list,
causing the "Main" section to be dropped from the Quick Reference pages.
In addition to adding properties to audio devices, the new property,
`SDL_PROP_AUDIO_DEVICE_UNIQUE_ID_STRING`, allows a best-effort option to find
the same specific audio device used on a previous run of a program, even in an
imperfect way. Most backends don't support this, but CoreAudio on macOS and
IMMDevice on Windows can.
coreaudio: Rework device enumeration queries, acquire unique_id.
- No longer keeps multiple AudioObjectPropertyAddress objects, just change the
selector for each query.
- Move string retrieval for AudioObjectProperties off to a separate function.
- Query for unique_id.
- If a device name is blank, don't reject the device, try to come up with a
name of some sort (either the unique_id or "Unnamed audio device").
windows: Add unique audio device identifiers to IMMDevice support.
This uses the new "StableId" property on Windows 11 if available, and the
device id (IMMDevice::GetId()) otherwise.
Microsoft claims that GetId() remains valid between reboots and even
disconnecting and reconnecting the audio device (although I am dubious that is
universally true when plugging into a different USB port, etc), but driver and
OS updates might change the identifier. StableId goes further, promising that
software updates won't change it, either.
This adds support to our WASAPI and DirectSound backends, if you're on at
least Windows Vista. Windows XP will not offer a unique ID for devices.
Fixes#16258.
This is my port of SDL3 to HarmonyOS/OpenHarmony. It has been tested on real
hardware from Huawei, and commercial games are being prepped to ship with it
already.
There is _heavy_ documentation in docs/README-harmonyos.md, including how to
set up a development environment and project, build, and debug, for the
completely uninitiated.
This work was sponsored by Outfit7: https://outfit7.com/Fixes#9837.
This was a pending question from the atomic merge. Not only does this function
need to be called, it needs to be called in the SwapWindow* functions first,
like the legacy (non-atomic) path does.
Reference Issue #16136.
Previously this was only available through the gamepad API, but this state has
always actually lived on the lower-level joystick objects, so there's no sense
in not offering a public API for that level, as well.
Closes#16202.
This lets the OS remove windows that were destroyed in cases where we aren't
terminating the process right after calling SDL_Quit(). Otherwise, they'll
stay on the screen, unresponsive.
Apparently there is some animation state that needs to complete, and that is
handled via the runloop.
Fixes#10081.
It's possible that IOStreams might get created and thrown away a lot, perhaps
at any point in an app's lifetime, so it makes sense to avoid doing the work
of maintaining a properties group for each, if the app hasn't requested it,
since this requires a bunch of allocations and locks.
It's not necessarily worth doing this for other SDL objects, like SDL_Window,
since there are likely to only be a few of them, and likely created at startup
and living for the entire lifespan of the app.
Fixes#14436.
We don't care _what_ the `sizeof` results are, we just want it to vaporize
the condition's code out of the build. So we check it with a `? 1 : 0`, so it
always boils down to a `sizeof (int)`, no matter what data type the condition
actually is.
This works with bitfields, pointers, anything that can be "truthy." If it
isn't truthy, it would fail when assertions are enabled anyhow.
Fixes#15990.
Now it does _not_ call SDL_SetError(), since that would allocate memory with
the system in a weird state, and setting all four functions to NULL will
restore the original memory functions, as a shortcut vs having to query
SDL_GetOriginalMemoryFunctions() first.
Fixes#15914.
If a device has disconnected, and the app has quit the audio subsystem before
the queued main thread function has run, the pointer will be bogus by the time
the run occurs. So now it looks up the object from its device ID, and if the
lookup returns NULL, it returns immediately and everything works out.
Reference Issue #14856.
(which might be fixed by this or not.)