Commit Graph

13458 Commits (70a1bc69739016884a22abe6bf86f8a5deba29ef)

Author SHA1 Message Date
Sam Lantinga 70a1bc6973 Check for NULL before dereferencing newly allocated memory
Fixes https://github.com/libsdl-org/SDL/issues/8289
2023-09-24 17:17:49 -07:00
Frank Praznik 752f14e5a6 wayland: Convert some memcpy calls to copyp 2023-09-24 11:44:35 -04:00
Frank Praznik 9284a03053 wayland: Remove some unnecessary helper functions 2023-09-24 11:44:35 -04:00
Ryan C. Gordon 399bc709b7
build-scripts.pl: Added add-source-to-projects.pl
This insert files to the Xcode and Visual Studio projects, so you can add
sources to the build without having to find a Mac or Windows machine with
the appropriate tools installed, and manually update four different sets of
projects across them.

This doesn't touch CMake, but you can add files to that with a text editor
(hopefully) without drama.

This, like all Perl code, is fragile. Report bugs and don't push it too hard.
2023-09-22 23:08:46 -04:00
Ryan C. Gordon ac68271871
Visual-WinRT: dos2unix the project files to match other Visual Studio targets. 2023-09-22 23:08:46 -04:00
Sam Lantinga 34719cba96 Fixed crash in hid_init() if the HIDDeviceManager isn't available 2023-09-22 10:14:16 -07:00
Sam Lantinga 2e92e94ebb Make sure we update device->sample_frames in SDL_AudioDeviceFormatChangedAlreadyLocked()
WASAPI_GetDeviceBuf() will fail if we don't request the correct buffer size
2023-09-21 11:32:37 -07:00
Frank Praznik 9964e5c5b0 wayland: Don't retrieve the drag offer strings with every pointer motion event
Querying the drag offer with every pointer movement would require refactoring to work with the portal implementation, however, there is little point, as the event layer just discards the file name. Remove the existing code and note that a new implementation is needed if the name ever starts to be passed though.

In the event that this is reimplemented, it should cache the filenames, as otherwise, this could potentially hammer the DBus interface hundreds or even thousands of times per second.
2023-09-21 14:05:16 -04:00
Sam Lantinga bac7eeaaae Added missing include 2023-09-20 14:13:50 -07:00
Ryan C. Gordon a541e2ac10
audio: Change a few SDL_memcpy calls to SDL_copyp. 2023-09-20 17:02:44 -04:00
Ryan C. Gordon 54125c1408
audio: Only update bound audiostreams' formats when necessary.
Saves locks and copies during audio thread iteration. We've added asserts
that can evaporate out in release mode to make sure everything stays in sync.
2023-09-20 17:02:44 -04:00
Ryan C. Gordon e0b0f9a36e
testaudio: Fix mouseover testing.
Not sure how this line got lost.
2023-09-20 17:02:44 -04:00
Frank Praznik 2f3deec245 wayland: Don't process drag & drop events from surfaces not owned by SDL
Libdecor creates subsurfaces of the primary SDL surface, but events from these surfaces should be ignored, or applications will get drag & drop events when dragged over drop shadows and such.
2023-09-20 15:00:40 -04:00
Frank Praznik 42bdced05d events: Log file drop position events and print the pointer coordinates 2023-09-20 15:00:40 -04:00
Frank Praznik c10d93d3a0 wayland: Replace magic constant with define 2023-09-20 15:00:40 -04:00
Ryan C. Gordon 5008521538
emscripten: Restore compatibility with existing emsdk releases. 2023-09-20 14:32:41 -04:00
Jaswant Panchumarti 953b55dd6d
Use EM_ASM_PTR when the return value is a pointer
- closes https://github.com/libsdl-org/SDL/issues/8241
2023-09-20 14:25:35 -04:00
Ryan C. Gordon a4541a255e
audio: SDL_GetAudioStreamQueued now returns bytes, not frames.
Reference #8266.
2023-09-20 14:15:47 -04:00
Ryan C. Gordon 703aefbce0
Sync SDL3 wiki -> header 2023-09-20 14:08:32 -04:00
Colin Kinloch 99421b64d0 linux: Add portal drag and drop 2023-09-20 11:41:48 -04:00
Michael Bradshaw 952c5059b5 Remove stray Â
Presumably this is an accidental character due to the copyright symbol and conversion to/from different encodings. The *.c file does not have this character.
2023-09-20 08:32:53 -07:00
Simon McVittie eebd5d18a2 linux: Handle upower's UP_DEVICE_STATE_PENDING_CHARGE, PENDING_DISCHARGE
On my laptop, the battery is configured to stop charging at around 80%
most of the time, to increase the overall useful lifetime of the battery.
When in that state, upower reports UP_DEVICE_STATE_PENDING_CHARGE
(numeric value 5), which SDL previously mapped to SDL_POWERSTATE_UNKNOWN.
This made the platform_testGetPowerInfo automated test fail, because
it assumes that SDL_POWERSTATE_UNKNOWN means no battery is connected,
and does not expect to see a percentage.

Map UP_DEVICE_STATE_PENDING_CHARGE (5) to SDL_POWERSTATE_CHARGED, which
seems close enough.

Also map UP_DEVICE_STATE_PENDING_DISCHARGE (6) to
SDL_POWERSTATE_ON_BATTERY, which matches how at least GNOME presents it.

Signed-off-by: Simon McVittie <smcv@collabora.com>
2023-09-20 08:32:03 -07:00
Ryan C. Gordon f8fdb20d8f
audio: Destroy all existing SDL_AudioStreams on shutdown. 2023-09-20 10:47:11 -04:00
Ryan C. Gordon 62d4459972
audio: Removed declarations of functions that don't exist anymore. 2023-09-20 10:21:03 -04:00
Ryan C. Gordon b656720bc6 loopwave: Use SDL_GetAudioStreamQueued() for more accurate results. 2023-09-20 10:15:03 -04:00
Ryan C. Gordon 34b931f7eb audio: Added SDL_GetAudioStreamQueued 2023-09-20 10:15:03 -04:00
Ryan C. Gordon 23206b9e3f audio: Added SDL_EVENT_AUDIO_DEVICE_FORMAT_CHANGED
This fires if an opened device changes formats (which it can on Windows,
if the user changes this in the system control panel, and WASAPI can
report), or if a default device migrates to new hardware and the format
doesn't match.

This will fire for all logical devices on a physical device (and if it's
a format change and not a default device change, it'll fire for the
physical device too, but that's honestly not that useful and might change).

Fixes #8267.
2023-09-20 10:12:10 -04:00
Ryan C. Gordon c7e6d7a1f7
audio: Changed debug logging output.
("preconverted bytes" makes it sounds like we already converted them before
the call instead of "bytes that haven't yet hit the stage where we convert
them. Just dump the wording completely.)
2023-09-20 10:04:23 -04:00
Ryan C. Gordon 87ec6acf2d
audio: Added a FIXME 2023-09-20 10:04:19 -04:00
Ryan C. Gordon ac88ffb7ea
audio: don't allocate buffer in SDL_SetAudioPostmixCallback for NULL callback. 2023-09-20 10:03:02 -04:00
Ryan C. Gordon 2a950f6ae6
audio: Replace some SDL_memcpy calls with SDL_copyp. 2023-09-20 10:01:52 -04:00
Ryan C. Gordon 0dc0434a3e
audio: Fixed race condition in subsystem shutdown.
This makes sure new devices can't be created when we're in the process of
shutting down.
2023-09-20 10:00:44 -04:00
Ryan C. Gordon 23f60203a3
audio: precalculate if we can use simple copies instead of the full mixer.
This just saves a bunch of conditionals (and an atomic get!) per iteration
of the audio thread.
2023-09-20 09:58:27 -04:00
Ryan C. Gordon 36b0f11414
audio: Optimize setting device formats during audio thread iteration.
The API entry point does a ton of unnecessary validation just to eventually
do a memcpy().
2023-09-20 09:09:15 -04:00
Anonymous Maarten 4c3e84897f testspriteminimal: make standalone by embedding icon.bmp 2023-09-19 17:58:25 +02:00
Anonymous Maarten 2a01f9dcb5 tests: plug leaks when running with --trackmem
(using SDL_VIDEO_DRIVER=x11/wayland on Linux)
2023-09-19 17:58:25 +02:00
Anonymous Maarten f42bbeca24 SDL_test: track stack frames of allocations on Windows 2023-09-19 17:58:25 +02:00
Anonymous Maarten 12c0be028e SDL_test: clear text cache on exit event 2023-09-19 17:58:25 +02:00
Anonymous Maarten b4bfb18318 SDL_test: free state before logging allocations 2023-09-19 17:58:25 +02:00
Anonymous Maarten 248b1edd3f SDL_test: destroy windows in SDL_CommonQuit
Not destroying the windows, caused a leak in checkkeys when
exiting by clicking somewhere in the window:
Allocation 0: 8 bytes
	0x7f46f56d2fe8: SDL_realloc_REAL+0x3d
	0x7f46f565deb7: GetMouseInputSource+0x88
	0x7f46f565e07b: SDL_PrivateSendMouseButton+0x56
	0x7f46f565e5aa: SDL_SendMouseButton+0x44
	0x7f46f57fb0a4: pointer_handle_button_common+0x1bb
	0x7f46f57fb0f3: pointer_handle_button+0x41
	0x7f46f5123be6: ffi_prep_go_closure+0x2c6
	0x7f46f51204bf: SDL_InitSubSystem+0x19
	0x7f46f512318e: ffi_call+0x12e
2023-09-19 17:58:25 +02:00
Anonymous Maarten 98da2dd303 SDL_test: don't warn about expected allocations when running with --trackmem
Since 9f4baeea53, the TLS storage is cleaned up when running SDL_Quit().
2023-09-19 17:58:25 +02:00
Sam Lantinga 6a381567b0 Support audio rate conversion up to 384KHz 2023-09-18 22:21:54 -07:00
Sam Lantinga b2b548a1fc Don't hang if IAudioRenderClient_GetBuffer() fails indefinitely 2023-09-18 20:55:28 -07:00
Sam Lantinga a3a5e17282 Fixed build warning '=': conversion from 'Uint32' to 'Uint16', possible loss of data 2023-09-18 13:56:51 -07:00
Sam Lantinga 6d3e21c27c Fixed android build warnings 2023-09-18 13:22:15 -07:00
Sam Lantinga fca2f53189 Fixed warning: this function declaration is not a prototype 2023-09-18 13:09:28 -07:00
Sam Lantinga a72dfa6a5f Fixed sensor timestamp units for third-party PS5 controllers 2023-09-18 12:55:43 -07:00
Sam Lantinga f6756047a4 Fixed error: array subscript 2 is above array bounds of ‘const Uint8[2]’
Smart compilers don't like dereferencing off the end of arrays
2023-09-18 12:19:18 -07:00
Sam Lantinga 7059a55ccc Fixed sensor timestamp calculation for third-party PS5 controllers 2023-09-18 11:50:56 -07:00
Sam Lantinga c0443e5d12 Fixed crash in SDL_IMMDevice_FindByDevID()
Either devid or handle->immdevice_id was NULL, crashing SDL_wcscmp()
2023-09-18 09:47:57 -07:00