Commit Graph

13797 Commits (4e8d1ec98373444e872d47668cdbfa072a5fe501)

Author SHA1 Message Date
Sam Lantinga b8cc51875a Fixed build 2023-10-23 19:36:14 -07:00
Sam Lantinga 0413e21e54 Fixed audio device removed events for ALSA
We don't match dev->name by string, since we might use the same string for both capture and output devices. Instead use the device pointer itself as the handle.

@icculus, are we guaranteed the device pointer is valid in ALSA_OpenDevice()?
2023-10-23 19:05:27 -07:00
Sam Lantinga 5ba03d377a Revert "Fixed audio device removed events for ALSA"
This reverts commit e57fef8f0b.

We actually need to match on a unique handle
2023-10-23 19:05:27 -07:00
Ryan C. Gordon a774694be0
pulseaudio: Simplified default device change detection code.
This reduces allocations, simplifies some code, and makes it quick to decide
from the hotplug thread if there was _actually_ a device change.
2023-10-23 22:02:27 -04:00
Sam Lantinga e57fef8f0b Fixed audio device removed events for ALSA 2023-10-23 18:42:48 -07:00
Sam Lantinga 4280d4b359 Fixed warning C4210: nonstandard extension used: function given file scope
Resurrected SDL_audio_c.h, we knew it would be back...
2023-10-23 17:04:14 -07:00
Ryan C. Gordon 182cfc3265
pulseaudio: Rework how we manage default devices and hotplug.
This fixes problems where Pulse callbacks don't fire in the order we expect,
or fail to fire at all, and avoids extra round trips to the Pulse server to
lookup information we could have trivially obtained already.

The end result is we would occasionally miss default device changes, etc, and
this resolves that better.
2023-10-23 19:17:50 -04:00
Ryan C. Gordon b2ae1e835f
pulseaudio: Change debug printf calls to use SDL_Log instead. 2023-10-23 19:17:49 -04:00
Sam Lantinga 38afd48daf Added a single source of SDL object IDs
This ensures that we don't accidentally interpret an ID from one system as an ID in another system.
Audio device IDs are not covered here, since they have a unique numbering system.
2023-10-23 10:49:37 -07:00
Sam Lantinga e07f6c0a17 SDL_IsJoystickProductWheel() returns SDL_TRUE for Asetek wheelbases (thanks @IOBYTE!) 2023-10-23 10:42:36 -07:00
Sam Lantinga c98a14fdeb Renamed display added/removed events for consistency with the rest of the API
Fixes https://github.com/libsdl-org/SDL/issues/8425
2023-10-23 09:14:54 -07:00
Sam Lantinga c2a3112b6f Added "--substring" to the help for rename_symbols.py 2023-10-23 09:14:54 -07:00
Sam Lantinga a844d90942 Add missing error reporting in Android_JNI_FileOpen()
Fixes https://github.com/libsdl-org/SDL/issues/8427
2023-10-23 08:27:57 -07:00
Ryan C. Gordon 4ac38d13dd
alsa: Don't touch free'd memory in hotplug thread. 2023-10-23 00:59:40 -04:00
Ryan C. Gordon 43d41c9dcb
audio: Another attempt to make device add/remove work vs event watchers.
This patch reverts the previous reversion, and then adds code to queue up
events to be sent the next time SDL pumps the event queue. This guarantees
that the event watcher/filter _never_ runs from an SDL audio device thread
or some other backend-specific internal thread.
2023-10-23 00:38:41 -04:00
Ryan C. Gordon 9abc692156
audio: Another attempt to deal with device destruction from device thread.
This only happens when closing a device from an event watcher, when the
device reports failure from its own thread.
2023-10-22 17:01:49 -04:00
Ryan C. Gordon 33c9eeec7c
Revert "audio: Device threads don't increment physical device refcounts."
This reverts commit 76f81797b7.

This worked in the normal cases, but:

A device thread that calls SDL_DisconnectAudioDevice due to failure will fire
the disconnect event from the device thread...and if there's an event watcher
that uses that moment to close the device, we still end up in the same
situation, where the device thread tries to join on itself.

Better solutions are still pending.
2023-10-22 16:15:27 -04:00
Sam Lantinga e5a15f94e2 Revert "Check to make sure the Windows joystick device has buttons and axes"
This reverts commit 642504bc59.

We have SDL_HINT_JOYSTICK_ROG_CHAKRAM to ignore or allow the ROG Chakram X mouse to be used as a joystick.

Fixes https://github.com/libsdl-org/SDL/issues/8227
2023-10-22 09:21:07 -07:00
Sam Lantinga 70fd8e2ba2 Lock joysticks when adding gamepad mappings
Fixes https://github.com/libsdl-org/SDL/issues/8412
2023-10-19 22:36:44 -07:00
Ryan C. Gordon 76f81797b7
audio: Device threads don't increment physical device refcounts.
Otherwise, they risk the device thread joining on itself.

Now we make sure the reference is held at the logical device level until
the physical device is closed, so it can't destroy the device in normal
usage until the thread is joined, etc.
2023-10-19 15:47:29 -04:00
SDL Wiki Bot 594fda4120 Sync SDL3 wiki -> header 2023-10-19 17:13:15 +00:00
Sam Lantinga 0d7c5a2c56 Updated Android API documentation 2023-10-19 10:12:34 -07:00
Sam Lantinga 0df888c584 Moved Android low latency audio behind a hint "SDL_ANDROID_LOW_LATENCY_AUDIO" 2023-10-19 08:54:11 -07:00
SDL Wiki Bot 142366c837 Sync SDL3 wiki -> header 2023-10-19 14:03:06 +00:00
Sam Lantinga 3a4c9d6990 Fixed build error when API logging is enabled 2023-10-18 22:30:16 -07:00
Sam Lantinga 1f8f82b379 Removed redundant thread-safety information 2023-10-18 22:19:50 -07:00
SDL Wiki Bot a6edc75fe7 Sync SDL3 wiki -> header 2023-10-19 05:18:12 +00:00
Sam Lantinga 3c8edeb79b Clarified SDL property thread-safety information 2023-10-18 22:17:02 -07:00
SDL Wiki Bot 4fa821cb3e Sync SDL3 wiki -> header 2023-10-19 05:14:13 +00:00
Sam Lantinga 1c70760c0b Added thread-safety information for the new SDL properties API 2023-10-18 22:13:33 -07:00
Sam Lantinga 15533dce05 Cleaned up warnings from check_stdlib_usage.py 2023-10-18 21:38:14 -07:00
Ryan C. Gordon bf269571fc
jack: Removed FIXME comment that has since been fixed. 2023-10-18 15:47:01 -04:00
Ryan C. Gordon 797b70877d
audio: Remove stub header SDL_audio_c.h.
It was a leftover, that just included SDL_sysaudio.h, in modern times.
2023-10-18 15:46:07 -04:00
Ryan C. Gordon 9d7c57234a
audio: Cleaned out most remaining `/* */` comments for `//` style.
Fully committing to it...!

This left SDL_wave.* alone for now, since there's a ton of comments in there
and this code hasn't changed much from SDL2 so far. But as SDL2 ages out a
little more, I'll likely switch this over, too.
2023-10-18 15:39:01 -04:00
Ryan C. Gordon 0ff67dc21b
video: Fix compiler warning about SDL_ReadSurfacePixel not being declared.
(this was legal before, but the Android NDK wants to make sure we didn't mean
for this function to be marked `static` since it didn't have a formal
declaration before its definition and might only be used in the one source
file.)
2023-10-18 15:02:01 -04:00
Ryan C. Gordon 81c77396af
opensles: Patched to compile. 2023-10-18 14:56:32 -04:00
Ryan C. Gordon 442e84916a
opensles: Fixed capitalization to match other SDL backends. 2023-10-18 13:57:32 -04:00
Ryan C. Gordon 34914bfb49
alsa: Clean up device handles, now that hotplug thread cleanup is in place. 2023-10-18 13:53:42 -04:00
Sam Lantinga 48d80efb51 Fixed warning C4701: potentially uninitialized local variable 'props' used 2023-10-18 09:04:05 -07:00
Ozkan Sezer f7dc63bcc3 audio: another windows wasapi build fix. 2023-10-18 18:32:00 +03:00
Ozkan Sezer dd98330076 audio: fix windows wasapi build. 2023-10-18 18:20:00 +03:00
Ryan C. Gordon 7a52f7b3fd
audio: Split Deinitialize into two stages.
First stage happens before we destroy objects, and is generally used to
shut down hotplug. The second stage is the usual deinit, which cleans up
the lowlevel API, unloads shared libraries, etc.
2023-10-18 10:43:45 -04:00
Ryan C. Gordon e55e556f32
alsa: Fixed minor memory leak.
The default device handles aren't free'd anywhere, so don't strdup them;
everything else is managed by the hotplug thread, which does its own freeing.
2023-10-17 23:28:50 -04:00
Sam Lantinga b45a0d9016 Updated the documentation for SDL_LoadWAV_RW() 2023-10-17 20:27:49 -07:00
Cameron Gutman 435e7ce663 Check for device disconnection in HIDAPI_JoystickOpen()
HIDAPI joystick drivers may call HIDAPI_JoystickDisconnected() in their
UpdateDevice() function during HIDAPI_JoystickOpen(). If they do this
today, the opened joystick will end up partially initialized (no name,
path, mapping GUID, etc.) because HIDAPI_GetDeviceByIndex() will no
longer be able to find the SDL_HIDAPI_Device for the removed joystick.

Worse still, joystick->hwdata->device becomes a dangling freed pointer
the next time HIDAPI_UpdateDeviceList() is called. This leads to a UAF
when the application or SDL calls SDL_JoystickClose() on this joystick.

Fix all this by checking if the device no longer has any associated
joysticks after calling UpdateDevice() and failing the open call if so.
2023-10-17 21:54:09 -05:00
Ryan C. Gordon b733adb503
audio: Fix device refcounting vs ProvidesOwnCallbackThread backends. 2023-10-16 20:17:04 -04:00
Ryan C. Gordon c6f08c2553
testaudio: Removed debugging code. 2023-10-16 15:25:34 -04:00
Ryan C. Gordon d5dac0ad27
testaudio: Deal with a texture being unexpectedly NULL when scaling.
This happens to work because our current textures are all 128x128, but in
theory one shouldn't hit this case anyhow...right?!

Reference Issue #8344.
2023-10-16 14:03:58 -04:00
Ryan C. Gordon b19e68c8ec
testaudio: Properly display playback progress, regardless of data source. 2023-10-16 13:56:43 -04:00
Ryan C. Gordon 8c39269279
audio: Fix audio stream format when binding to a capture device.
Fixes #8402.
2023-10-16 13:34:40 -04:00