Commit Graph
100 Commits
Author SHA1 Message Date
Ryan C. Gordon 125e7420ec cocoa: Warp mouse to center of window before enabling relative mouse.
This prevents the case where the mouse might be at the edge of the
window when enabling relative mode, which confuses macOS, at it
might believe the user is attempting to resize the window.

Fixes #6994.

(cherry picked from commit 2afb49ba9a)
2023-06-11 12:54:51 -04:00
Ryan C. Gordon 49b5cfa6c5 x11: check if window size/position has changed during SDL_ShowWindow.
Fixes #4216.
2023-06-07 15:42:22 -04:00
Ryan C. Gordon 19c10b41fd x11: Attempt to wait for SDL_MaximizeWindow to complete before returning.
Fixes #7070.

(cherry picked from commit 379a6f4dab)
2023-05-30 17:10:04 -04:00
Ryan C. Gordon ecccf6f9ca windows: Don't allow non-resizable windows to be maximized.
Fixes #6346.

(cherry picked from commit d275851dfb)
2023-05-29 14:49:57 -04:00
Ryan C. Gordon 95f244598b power: On Linux, compare status strings as case-insensitive.
In case something reports "Device" when we expected "device", etc.

Reference Issue #6835.

(cherry picked from commit df9d0fb332)
2023-05-28 21:36:56 -04:00
Ryan C. Gordon c6cecb0fb0 wasapi: Deal with HDMI or DisplayPort-based audio devices.
They can vanish for UP TO EIGHT SECONDS...!

This is for devices that connect to HDMI/DisplayPort/etc, where it
presumably has to wait for a display to get up and running before it
can play audio through it, so one can see the audio device fail when
changing display modes, or the system returning from sleep. Since this
can be triggered by a game changing video resolutions at startup (either
before or after opening the audio device!), it's important to deal with.

In normal conditions, it shouldn't take this long to open or recover an
audio device, but this is better than unexpectedly losing the device
in this situation.

Fixes #7044.
Fixes #5571.

(cherry picked from commit 48e71ae87b)
2023-05-26 19:15:56 -04:00
Ryan C. Gordon 35292d7dba pulseaudio: Redesigned to use pa_threaded_mainloop.
We weren't meant to have multiple contexts and mainloops, but we had one
for each opened device and the hotplug detection thread. Instead, use
pa_threaded_mainloop, which can be shared between threads and objects, and
a single context (which, according to the PulseAudio documentation, is
usually meant to be a singleton that represents a global server connection,
possibly with multiple streams hung on it).

Now instead of polling in a loop, threads will block until the
threaded_mainloop runs a callback, and the callback will fire a signal to
unblock the thread.

Prior to this, the code upset ThreadSanitizer, as Pulse has some unprotected
global resource that each mainloop/context would touch.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon 81fe505c31 audio: remove is_in_audio_device_thread()
SDL mutexes are always recursive in modern times, so no need to check this,
plus the test triggers a false-positive on ThreadSanitizer.

Reference Issue #7427.
2023-05-26 09:07:33 -04:00
Ryan C. Gordon d4bc393efe video: Only specify some GL context attributes if not the explicit default.
Just in case it upsets some OpenGL drivers unnecessarily.

Fixes #7730.
2023-05-25 10:04:44 -04:00
Ryan C. Gordon 2e646c7141 audio: Load .WAV files with format->blockalign==0.
In theory this is illegal, but legit wavefiles in the field do it, and
it's easy to bump it to 1 for general purposes.

Formats with more specific alignment requirements already check for them
separately.

Fixes #7714.
2023-05-17 20:06:58 -04:00
Ryan C. Gordon d05639a626 dynapi: Accept a comma-separated list of libraries to attempt to load.
First one to load and have the necessary symbol is the one we accept,
if any. Once we accept one, we won't try loading others.

Fixes #7613.

(cherry picked from commit 32999798e0)
2023-05-17 20:03:36 -04:00
Ryan C. Gordon b5cd0749b2 blit: Add a case for 8-bit blits that sdl12-compat exposed.
sdl12-compat can get into a state where a color-keyed surface is
marked for blending, but wants to blend with full alpha (which
is the same as _not_ blending), so rather than fail to find a
blitter in that case, it just selects the colorkey blitter.

Reference https://github.com/libsdl-org/sdl12-compat/issues/233

(cherry picked from commit 0eea92c8fc)
2023-05-16 14:42:16 -04:00
Ryan C. Gordon 9facc86b6a audio: more AudioStream allocation work.
This was only including the resampling buffer needs if it was larger
the other allocation needs, but it needs to be included unconditionally.

For safety's sake, we also make sure the pre-resample buffer doesn't risk
overflow, too, but this might not be necessary in practice.
2023-05-12 21:35:23 -04:00
Ryan C. Gordon 80a8691098 audio: Fixed buffer overflow in SDL_AudioStream resampling. 2023-05-11 16:25:20 -04:00
Ryan C. Gordon 9bf0934877 audio: SDL_memcpy() params were backwards. :O 2023-05-11 15:13:11 -04:00
Ryan C. Gordon 2b6cb7bfb2 include: SDL_ConvertAudioSamples docs now warn about converting in chunks.
Fixes #7154.
2023-05-09 14:24:22 -04:00
Ryan C. Gordon 7b6dabd81f audio: AudioStreams shouldn't overflow output buffers.
Before, as ConvertAudio might have expanded data in-place temporarily during
its work, this could blow up. Now if there's a chance of that, it'll
work out of an internal buffer and copy the final results to the output
buffer.

If the output format can handle the temporary expansion, we write directly
to the output buffer without the extra copy.

Fixes #7668.
2023-05-09 14:19:16 -04:00
Ryan C. Gordon 0e1669e296 audio: Fixed audiostreams converting incorrect channel counts. 2023-05-09 10:58:32 -04:00
Ryan C. Gordon 7f219aa369 audio: Make sure AudioStream's internal buffers are large enough.
It needs to deal with ConvertAudio growing buffers in-place, as it might
convert smaller types to float as an intermediate step.
2023-05-09 10:57:23 -04:00
Ryan C. Gordon c7629704b4 audio: SDL_ConvertAudioSamples shouldn't calculate its output buffer size.
Just use what the AudioStream calculates instead.
2023-05-09 10:56:34 -04:00
Ryan C. Gordon a88aeb2a8a coreaudio: Flush/stop the AudioQueue before disposing of it.
Otherwise, a CoreAudio thread lingers forever, and coreaudiod eats CPU
until the SDL process terminates.

Fixes #7689.

(cherry picked from commit 86786ed544)
2023-05-08 14:26:34 -04:00
Ryan C. Gordon e191bc8491 audio: Simplified GetFirstAudioFormat/GetNextAudioFormat.
Now it just returns an iterable array and needs no global state.
2023-05-03 22:37:23 -04:00
Ryan C. Gordon e474047ff8 rwlock: Added SDL_rwlock API for shared locks. 2023-04-27 21:54:02 -04:00
Ryan C. Gordon 776820526b windows: Use InitializeSRWLock explicitly.
The docs say you should, if not statically initializing an SRWLOCK--which
we aren't--but in practice this is probably just being pedantic.

Still, better (thread) safe than sorry!
2023-04-27 21:54:02 -04:00
Ryan C. Gordon 70a501d8ec winrt: Don't reference generic Condition Variables at all.
It always has the SRWLOCK implementation available to it, so let the
linker throw away the generic version if possible.
2023-04-27 21:54:02 -04:00
Ryan C. Gordon 736f9fb9b9 mutex: Fixed typos in documentation 2023-04-27 21:54:02 -04:00
Ryan C. Gordon e5a6c24c82 audio: Redesigned audio conversion code for SDL3.
- SDL_AudioCVT is gone, even internally.
- libsamplerate is gone (I suspect our resampler is finally Good Enough).
- Cleanups and improvements to audio conversion interfaces.
- SDL_AudioStream can change its input/output format/rate/channels on the fly!
2023-04-27 18:35:15 -04:00
Ryan C. Gordon 586004e52a wikiheaders.pl: Manpages shouldn't use .BI sections, it looks bad.
Reference Issue #7514.
2023-03-21 22:23:06 -07:00
Ryan C. Gordon 1b81ececd3 wikiheaders.pl: Fixed uninitialized value warning when run without arguments. 2023-03-21 21:57:12 -07:00
Ryan C. Gordon d898dbfe50 render: Make sure logical_target is bound when presenting.
Fixes black screen on macOS.

Fixes #7320.
2023-03-08 22:57:29 -05:00
Ryan C. Gordon 8b9a938413 dataqueue: Make thread safe.
Each data queue gets its own mutex and each function obtains it.

Fixes #7390.
2023-03-02 16:35:16 -05:00
Ryan C. Gordon f833e005e1 dataqueue: Removed non-public SDL_ReserveSpaceInDataQueue function
This wasn't used, and it was just asking for trouble.
2023-03-02 16:09:23 -05:00
Ryan C. Gordon f48d0cc164 audio: Remove AUDIO_U16* support.
It wasn't heavily used, and you can't use memset to silence a U16 buffer.

Fixes #7380.
2023-03-01 10:26:01 -05:00
Ryan C. Gordon 5d3234d8ae docs: Removed bogus file from wiki bridge.
That was fixed to not do that again by https://github.com/libsdl-org/ghwikipp/commit/7e429a13d385e448dd2efaf014e5aaddb6eff66b
2023-02-28 13:39:43 -05:00
Ryan C. Gordon 5585a4ac72 Renamed CONTRIBUTING.md to README-contributing.md
This lets the wiki bridge pick it up.
2023-02-28 12:38:31 -05:00
Ryan C. Gordon 7b9b20e684 docs: Deleting a bogus file to see if wiki bridge rebuilds it. 2023-02-28 12:31:11 -05:00
Ryan C. Gordon 99c38268cd wikiheaders: Sort pages before listing them in README/FrontPage.md. 2023-02-28 12:28:10 -05:00
Ryan C. Gordon 7745c9b3ae wikiheaders: Use Windows endlines in the source, Unix in the wiki. 2023-02-28 12:28:10 -05:00
Ryan C. Gordon 6d1e14b792 wikiheaders: ignore wiki's README/FrontPage.md 2023-02-28 11:55:19 -05:00
Ryan C. Gordon 2506676f34 wikiheaders: Bridge README files in the docs directory to wiki.
Fixes #6026.
2023-02-28 11:45:47 -05:00
Ryan C. Gordon a479633455 wikiheaders: fixed wikilinks in Markdown code sections. 2023-02-27 23:08:19 -05:00
Ryan C. Gordon 9f8425a7a9 include: Fixed wiki formatting that got mangled into the headers. 2023-02-26 21:47:17 -05:00
Ryan C. Gordon 5b0351a672 wikiheaders: Fix wikilinks inside code sections a little. Not perfect yet. 2023-02-24 14:29:36 -05:00
Ryan C. Gordon 0598ecc150 Sync wiki -> headers. 2023-02-24 11:49:41 -05:00
Ryan C. Gordon d748a454a8 wikiheaders: fixed see-also conversion 2023-02-24 11:45:43 -05:00
Ryan C. Gordon 5ff49955ab wikibridge: Fixes for manpage generation from Markdown format. 2023-02-24 10:21:54 -05:00
Ryan C. Gordon 936a51d5cc wikiheaders: Work to make the wiki exist primarily in Markdown format.
This adds a means to mass-convert the whole wiki to Markdown as a one-time
operation, and then some fixes to make --copy-to-headers correctly deal with
Markdown-formatted wiki pages.
2023-02-24 09:07:09 -05:00
Ryan C. Gordon 1e5e8e2fda resampler: Work at double precision on x86-64 machines.
We get audio artifacts if we don't work at the higher precision, but
this is painful on CPUs that have to use a software fallback for this,
so for now (that is, until we have a better solution), get better output
on amd64 chips, where the cost is less painful.
2023-02-21 13:00:20 -05:00
Ryan C. Gordon 357bc8ca5c resampler: correctly save off left padding.
I don't know if we ever actually hit this in practice, but if this isn't
replacing the whole buffer, it needs to slide the end of the existing padding
over to the start before adding in the new data.
2023-02-21 13:00:19 -05:00
Ryan C. Gordon 077725d0e3 wikiheaders: Fixed SDL2 wiki link. 2023-01-26 14:50:52 -05:00
Ryan C. Gordon 5f8b53820a wikiheaders: Link to the SDL2 wiki in the preamble.
Fixes #6568.
2023-01-26 14:45:58 -05:00
Ryan C. Gordon 726d6f9422 wikiheaders: Allow markdown in the wikipreamble string.
Reference Issue #6568.
2023-01-26 14:45:57 -05:00
Ryan C. Gordon 79cca812cb include: make SDL_RenderPresent thread safety notes less verbose.
Reference Issue #7140.
2023-01-25 13:15:34 -05:00
Ryan C. Gordon 197340ea1c Sync wiki -> headers. 2023-01-25 13:01:40 -05:00
Ryan C. Gordon 01cba48d18 wikiheaders: Add a \threadsafety tag to document threading details.
Reference Issue #7140.
2023-01-25 12:59:25 -05:00
Ryan C. Gordon e3bada6fbd wikiheaders: We never updated the config when we moved to include/SDL3. :O 2023-01-24 19:42:36 -05:00
Ryan C. Gordon 87c8e2b942 README-migration: Added backticks to avoid markdown highlighting. 2022-12-31 01:12:10 -05:00
Ryan C. Gordon 138f632b59 include: Add a comment about reserving a bit for sdl2-compat. 2022-12-29 13:34:53 -05:00
Ryan C. Gordon 1cf2b566af cpu: Removed 3DNow! support and SDL_Has3DNow().
Reference Issue #6636.
2022-12-23 09:30:56 -08:00
Ryan C. Gordon 7a5a1b16ce events: Make sure new display events don't overlap with sdl2-compat.
Reference PR #6867.
2022-12-22 11:47:54 -05:00
Ryan C. Gordon 3197632347 include: Renamed begin_code.h and close_code.h to have SDL_ prefixes.
Fixes #6864.
2022-12-22 11:39:26 -05:00
Ryan C. Gordon c9887c5c72 include: Split out functions in SDL.h to SDL_init.h.
SDL.h now exists solely as a header that includes everything else, instead
of one that forces you to include everything else when you just want the
declaration for SDL_Init().

Fixes #6840.
2022-12-22 01:05:10 -05:00
Ryan C. Gordon 182806e39f docs: Updated migration notes for SDL_RWops. 2022-12-22 00:55:54 -05:00
Ryan C. Gordon 78725dc0cd include: Fixed a C++-style single line comment.
Reference Issue #6838.
2022-12-17 23:52:33 -05:00
Ryan C. Gordon d927befcd7 docs: Just adjusting some link text. 2022-12-17 13:06:44 -05:00
Ryan C. Gordon 7b25f04476 README-migration.md: Point to the SDL_gesture repository. 2022-12-17 13:05:00 -05:00
Ryan C. Gordon 3b5780ba0a README-migration.md: Updated stdio RWops example code for new API. 2022-12-17 13:05:00 -05:00
Ryan C. Gordon c637031294 rwops: Fixed another Windows build failure. 2022-12-15 00:16:02 -05:00
Ryan C. Gordon 4075748e41 rwops: Removed unused variable in Windows-specific code. 2022-12-15 00:09:32 -05:00
Ryan C. Gordon 83559503c4 test: patched to compile. 2022-12-14 23:25:09 -05:00
Ryan C. Gordon 72c1f73bc5 rwops: Make read and write work like POSIX, not stdio.
This simplifies some things, clarifies some things, and also allows
for the possibility of RWops that offer non-blocking i/o (although
none of the current built-in ones do, intentionally, we could add this
later if we choose, or people could provide things like network socket
RWops implementations now, etc.

Fixes #6729.
2022-12-14 15:47:13 -05:00
Ryan C. Gordon 5a2d0b69c8 render: Remove SDL_GetRenderDriverInfo and change SDL_CreateRenderer.
Fixes #6625.
2022-12-13 23:27:35 -05:00
Ryan C. Gordon a76053352c gesture: Removed the gesture API from SDL3.
Fixes #6758.
2022-12-13 14:54:37 -05:00
Ryan C. Gordon 12486e144b wasapi: Fixed incorrect assertions.
Fixes #6795.
2022-12-12 16:07:48 -05:00
Ryan C. Gordon 16f8dfcef9 docs: Note that you don't need to free SDL_GetDefaultCursor's results.
Reference Issue #6777.
2022-12-09 22:08:40 -05:00
Ryan C. Gordon 7ca0d15d64 events: Changed SDL_GetEventState from a macro to a function.
Fixes #6773.
2022-12-08 00:08:51 -05:00
Ryan C. Gordon a3225ae6de dynapi: Abstract out the environment variable name. 2022-11-29 14:13:07 -05:00
Ryan C. Gordon fa5adcafd5 cocoa: Patched to compile on macOS SDK < 10.10.
Fixes #6586.
2022-11-26 13:57:45 -05:00
Ryan C. Gordon 80c1ddbe97 dynapi: Bumped dynapi version to 2, so SDL2 libs don't conflict. 2022-11-26 09:49:18 -05:00
Ryan C. Gordon 712457ec28 Merge pull request #6321 from Daft-Freak/no-ie
Delete emscripten CanvasPixelArray (IE10/11) support
2022-11-23 14:03:35 -05:00
Ryan C. Gordon 040a17a50f Merge pull request #6317 from tycho/wip/angle-egl
EGL: fixes for better ANGLE support
2022-11-23 14:02:15 -05:00
Ryan C. Gordon dcd9e21966 Merge branch 'main' into wip/angle-egl 2022-11-23 14:01:17 -05:00
Ryan C. Gordon 3983c98ece Merge branch 'main' into no-ie 2022-11-23 13:46:27 -05:00
Ryan C. Gordon a5e9d9bd7e Merge pull request #6142 from Daft-Freak/em-webgl-selector-hint
emscripten: use webgl APIs directly and add canvas selector hint
2022-11-23 13:23:15 -05:00
Ryan C. Gordon c2f26087c8 Merge branch 'main' into em-webgl-selector-hint 2022-11-23 13:22:23 -05:00
Ryan C. Gordon 4c39dd5c72 Testing the wiki, disregard this commit. 2022-11-22 18:12:08 -05:00
Ryan C. Gordon 8b18b09027 fnsince.pl: Make this work with SDL3. 2022-11-22 17:39:56 -05:00
Ryan C. Gordon b33000448e .wikiheaders-options: Add a warning that SDL3 is WIP. 2022-11-22 13:49:03 -05:00
Ryan C. Gordon 94f19d974d .wikiheader-options: Whoops, this isn't SDL_mixer. :) 2022-11-22 12:48:33 -05:00
Ryan C. Gordon a1702d463c ibus: Try to use org.freedesktop.portal.IBus first if available.
This should fix apps that want ibus support inside sandboxed environments
like FlatPak or Snaps.

Fixes #4706.
2022-11-16 23:39:41 -05:00
Ryan C. Gordon bb0b8adacc mac: Fix handling of deprecated symbol.
This needs to check what our deployment target is, not what SDK
is available, since this is a linker symbol and not an enum
value or whatever.

Also removed a copy/paste error that mentioned CoreAudio in
the haptic subsystem.

Fixes #6534.
2022-11-16 22:04:04 -05:00
Ryan C. Gordon 389ffab733 Code style fixes, etc.
Reference PR #6345.
2022-11-16 12:53:48 -05:00
Ryan C. Gordon 7ebdae5dc9 cocoa: Fix OpenGL deprecation warning. 2022-11-16 11:45:41 -05:00
Ryan C. Gordon 7c760f7f79 cocoa: Update CVDisplayLink timing when screen changes.
This handles both the window moving to a new display and
changing the current display's refresh rate in System
Preferences

Reference Issue #4918.
2022-11-16 11:35:27 -05:00
Ryan C. Gordon 1fd66cc890 Revert "cocoa: Backed out CVDisplayLink code for macOS vsync."
This reverts commit 04b50f6c6b.

It turns out OpenGL vsync has broken again in macOS 12, so
we're reintroducing our CVDisplayLink code to deal with it,
again.

Reference Issue #4918.
2022-11-16 11:34:25 -05:00
Ryan C. Gordon 9d67686a5b haptic: Deal with deprecated macOS symbol. 2022-11-16 10:08:40 -05:00
Ryan C. Gordon 6801d676c0 Revert "pulseaudio: Only use PA_STREAM_ADJUST_LATENCY if buffer isn't super small."
This reverts commit d8b1ef42ae.

This turned out to be unnecessary (it was a problem on the user's system,
not an SDL bug).

Reference Issue #6121.
2022-11-16 09:53:37 -05:00
Ryan C. Gordon d8b1ef42ae pulseaudio: Only use PA_STREAM_ADJUST_LATENCY if buffer isn't super small.
Fixes #6121.
2022-11-15 22:44:31 -05:00
Ryan C. Gordon 44d7b8b91d egl: Check for a NULL pointer in SDL_EGL_GetProcAddress.
This happens on kmsdrm if you try to GetProcAddress before creating
a window.

Fixes #5399.
2022-11-15 13:59:24 -05:00
Ryan C. Gordon 85aa9b8b6f wasapi: Favor the system resampler again, for now.
Reference Issue #5538.
2022-11-11 13:48:11 -05:00