Commit Graph

14438 Commits (7561116873d99e6a566c6cdabd343090f7553c9d)

Author SHA1 Message Date
Ryan C. Gordon 759cdf6159
audio: Fixed GetFirstAudioDeviceAdded().
It forgot to check for the type of device needed.
2023-11-01 00:39:51 -04:00
Ryan C. Gordon 0e614d9179
audio: Massive reworking on thread locking.
This cleans up a ton of race conditions, and starts moving towards something
we can use with Clang's -Wthread-safety (but that has a ways to go still).
2023-11-01 00:10:25 -04:00
Ryan C. Gordon 40fb76196c
audio: Don't let simplified audio streams bind to new devices.
This can happen if you close the stream's underlying device directly, which
removes the binding but doesn't destroy the object.

In this case, the stream remains valid until destroyed, but still should not
be able to be bound to a new device.
2023-10-31 10:52:50 -04:00
Ryan C. Gordon 24e3328cca
audio: Don't reset device ID counter on subsystem init/quit.
Otherwise you risk a buggy app holding an obsolete device ID that now refers
to a different device after reinit.
2023-10-31 10:50:37 -04:00
Anonymous Maarten 5d95cbde37 cmake: reset check state before testing -fobjc-arc 2023-10-30 21:14:39 +01:00
Anonymous Maarten f18120c83c cmake: check -fobjc-arc compiler flag on Apple platforms 2023-10-30 19:59:28 +01:00
Anonymous Maarten 4aacc4b92e cmake: file(RELATIVE_PATH) needs 2 absolute paths 2023-10-30 19:50:35 +01:00
Ryan C. Gordon dcc8805c21
testaudio: Fixed compiler warning on Visual Studio. 2023-10-30 13:09:56 -04:00
Ryan C. Gordon 9cb259e865
audio: Never SDL_PushEvent from anywhere but SDL_UpdateAudio().
Fixes some corner-case deadlocks.
2023-10-30 13:08:10 -04:00
Frank Praznik 875e45e70b wayland: Sanity check pointers and protocols before confining 2023-10-29 14:24:47 -04:00
Frank Praznik 0e87b71d08 wayland: Check the relative pointer handle before destroying
If the relative protocol is unsupported, this will always be null and the destroy function won't be called.
2023-10-29 14:15:23 -04:00
Anonymous Maarten 6127ac0871 Use SDL_DISABLE_ALLOCA instead of HAVE_ALLOCA in SDL_stdinc.h 2023-10-28 18:54:12 +02:00
Sam Lantinga 552bee47cb Clear any previous errors if we successfully show a message box 2023-10-27 10:11:23 -07:00
Sam Lantinga 343da852a6 Don't try to use the Wayland messagebox if we're not in Wayland
Also cleaned up some potential file handle leaks when querying the zenity version
2023-10-27 10:11:23 -07:00
Ryan C. Gordon f63e9a8a3f
wasapi: Handle disconnected devices that get reconnected.
The device ID strings don't change between connects, so we need to move the
old device object out of the way if it still exists as a zombie, and let
the reconnected device get itself a fresh object.
2023-10-27 01:30:27 -04:00
Ryan C. Gordon 5fa7b291d4
wasapi: Fixed memory leak if new audio devices fail to add. 2023-10-27 01:30:13 -04:00
Ryan C. Gordon 468c386686
wasapi: Handle disconnect notifications from the management thread, too.
These are also pretty heavyweight, don't do them from the notification
thread, which can deadlock everything.
2023-10-27 01:28:51 -04:00
Ryan C. Gordon ce3be02b48
wasapi: If device is marked as a zombie, don't try to resuscitate it. 2023-10-27 01:27:22 -04:00
Ryan C. Gordon 85923049a6
wasapi: Patched to compile. 2023-10-26 23:09:11 -04:00
Ryan C. Gordon 9bec57309c
wasapi: Proxy default device change handling to management thread.
This does a ton of work that can deadlock, because several crucial WASAPI
things that we want to do in response to this will block until the
notification callback has returned, so we can't call them from the handler
directly, or we'll be waiting until the thing that called us returns.
2023-10-26 23:03:27 -04:00
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