Commit Graph

14068 Commits (cbf9012c74c2e2babd3c48386dc42e3e4384337d)

Author SHA1 Message Date
Ryan C. Gordon c45b5121ce
audio: Fixed potential race condition.
We need to check if the device is ready to close before releasing the lock,
in case other things are messing with the list of logical devices.
2023-10-26 23:03:27 -04:00
Sam Lantinga 8b6da3c701 Fixed making the EGL context current when resuming on Android
Make sure that we don't have the context cached as current on the current thread.
2023-10-26 17:07:40 -07:00
SDL Wiki Bot 2e9eb1073d Sync SDL3 wiki -> header 2023-10-26 18:23:13 +00:00
Ryan C. Gordon e6116d399a
mutex: Removed SDL_MUTEX_MAXWAIT.
Fixes #8436.
2023-10-26 14:21:53 -04:00
SDL Wiki Bot 82f48be3ef Sync SDL3 wiki -> header 2023-10-26 12:58:14 +00:00
Ryan C. Gordon 899eb0d042 thread: Locking mutexes and rwlocks are now void functions.
Almost nothing checks these return values, and there's no reason a valid
lock should fail to operate. The cases where a lock isn't valid (it's a
bogus pointer, it was previously destroyed, a thread is unlocking a lock it
doesn't own, etc) are undefined behavior and always were, and should be
treated as an application bug.

Reference Issue #8096.
2023-10-26 08:57:34 -04:00
Frank Praznik 082ef41566 alsa: Fix crash from invalid handle pointer
ALSA expects handles to be of type ALSA_Device, and passing the handle for the default device as a plain string causes a crash as it attempts to deference the string contents itself as a pointer to a string.

Create immutable static ALSA_Device structs for the default devices and pass those as the handles. They are not placed in the hotplug list, and the audio layer doesn't attempt to free ALSA handles, so there is no need to worry about them being erroneously freed.
2023-10-25 19:37:43 -04:00
Ozkan Sezer a9aa15c792 CI: change FreeBSD CI runner to cross-platform-actions. 2023-10-26 01:03:40 +03:00
Sam Lantinga 23ceae94c9 Fixed Xbox 360 Controller support using libusb on Linux 2023-10-25 14:50:07 -07:00
Ryan C. Gordon ace0c2c297
mutex: Fixed bug where generic SDL_TryLockMutex would incorrectly block.
Fixes #8433.
2023-10-25 13:03:46 -04:00
Sam Lantinga f52b330ed8 Added support for the HP HyperX Clutch Gladiate controller 2023-10-25 09:00:26 -07:00
Ryan C. Gordon b61706373c
n3ds: Check that audio thread name starts with "SDLAudioP"
The string has a number after it, so a basic SDL_strcmp() will never match.

Reference PR #8346.

(cherry picked from commit cba6090398f581415938aa53c232142c85d23009)
2023-10-24 23:58:30 -04:00
ds-sloth 6827b3331d
n3ds systhread - use 80kb thread stack size as default, remove hard cap
(cherry picked from commit 3823ba1ded857a8af52d765b2d3ae6641b15dfe1)
2023-10-24 23:57:12 -04:00
ds-sloth e4cd1d4059
n3ds systhread - prefer to put audio thread on system core
(cherry picked from commit 301ee21f33c7e2cef4a0c484640fb028378a2fc5)
2023-10-24 23:56:34 -04:00
ds-sloth 1023d8ec84
SDL_n3dsaudio.c - don't risk leaving current_priority uninitialized
(cherry picked from commit 6623c87d0b7f6bae2ac16991aea53551899481b9)
2023-10-24 23:48:53 -04:00
ds-sloth 07171be596
SDL_n3dsaudio.h: use triple buffering
(cherry picked from commit 070f57820f401cb962e743bb3a4d12e346d6ed4b)
2023-10-24 23:48:17 -04:00
ds-sloth 6efe957159
SDL_n3dsaudio.c: separate mixer locks from audio device locks
(cherry picked from commit 62266dbd4fa79090025317a71473eb764b2e1abe)

(SDL3 audio backends don't have the LockDevice interfaces, so this just
ended up being a comment.)
2023-10-24 23:47:13 -04:00
Sam Lantinga 39a961ba41 Added support for "%[]" sscanf syntax
Fixes https://github.com/libsdl-org/SDL/issues/8423
2023-10-24 17:28:15 -07:00
Sam Lantinga 124a0050b6 Fixed warning: no previous prototype for function 'SDL_UpdateAudio' 2023-10-24 14:22:41 -07:00
Ryan C. Gordon b16165a33f
rwlock: SDL_UnlockRWLock was incorrectly tagged with SDL_RELEASE_SHARED.
It needs to be SDL_RELEASE_GENERIC, because it releases both exclusive
(writer) and shared (reader) locks.

Without this fix, clang's `-Wthread-safety` tests generate incorrect warnings.

Reference Issue #8096.
2023-10-24 14:42:02 -04:00
Ryan C. Gordon 865dd04068
pulseaudio: Don't use a hash for device change detection.
Both strings are _right there_ for comparing, so we can just set a flag to
note the device definitely changed.

Also simplified string management further; hotplug thread now makes a copy
of the string before releasing the lock if there was a change event, so when
the lock releases further events don't see a NULL and assume it's a new
device, causing a lot of work to ripple out and decide nothing has changed,
until the system stabilizes again. Now, it just does the right thing once.
2023-10-24 00:36:30 -04:00
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