From 14a4ae521acb784705e637854c368cceac80039a Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 02:46:55 -0400 Subject: [PATCH 1/9] pulseaudio: Request more recording data per-fragment. This seems to help some devices that can't keep up with smaller fragment sizes for whatever reason. Fixes #13110. --- src/audio/pulseaudio/SDL_pulseaudio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/audio/pulseaudio/SDL_pulseaudio.c b/src/audio/pulseaudio/SDL_pulseaudio.c index 69e8c1a84c..4d618a6e2b 100644 --- a/src/audio/pulseaudio/SDL_pulseaudio.c +++ b/src/audio/pulseaudio/SDL_pulseaudio.c @@ -672,7 +672,8 @@ static bool PULSEAUDIO_OpenDevice(SDL_AudioDevice *device) paspec.rate = device->spec.freq; // Reduced prebuffering compared to the defaults. - paattr.fragsize = device->buffer_size; // despite the name, this is only used for recording devices, according to PulseAudio docs! + + paattr.fragsize = device->buffer_size * 2; // despite the name, this is only used for recording devices, according to PulseAudio docs! (times 2 because we want _more_ than our buffer size sent from the server at a time, which helps some drivers). paattr.tlength = device->buffer_size; paattr.prebuf = -1; paattr.maxlength = -1; From 83cc3bc234db05d52d934cada7006246a9c42525 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 02:56:59 -0400 Subject: [PATCH 2/9] audio: Opened device spec must be >= simple minimums, not device's defaults. Fixes #13159. --- src/audio/SDL_audio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index f10598c32a..24562c8f60 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1771,9 +1771,14 @@ static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec something low quality, like an old game using S8/8000Hz audio, from ruining a music thing playing at CD quality that tries to open later. (or some VoIP library that opens for mono output ruining your surround-sound game because it got there first). These are just requests! The backend may change any of these values during OpenDevice method! */ - device->spec.format = (SDL_AUDIO_BITSIZE(device->default_spec.format) >= SDL_AUDIO_BITSIZE(spec.format)) ? device->default_spec.format : spec.format; - device->spec.freq = SDL_max(device->default_spec.freq, spec.freq); - device->spec.channels = SDL_max(device->default_spec.channels, spec.channels); + + const SDL_AudioFormat minimum_format = device->recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT; + const int minimum_channels = device->recording ? DEFAULT_AUDIO_RECORDING_CHANNELS : DEFAULT_AUDIO_PLAYBACK_CHANNELS; + const int minimum_freq = device->recording ? DEFAULT_AUDIO_RECORDING_FREQUENCY : DEFAULT_AUDIO_PLAYBACK_FREQUENCY; + + device->spec.format = (SDL_AUDIO_BITSIZE(minimum_format) >= SDL_AUDIO_BITSIZE(spec.format)) ? minimum_format : spec.format; + device->spec.channels = SDL_max(minimum_channels, spec.channels); + device->spec.freq = SDL_max(minimum_freq, spec.freq); device->sample_frames = SDL_GetDefaultSampleFramesFromFreq(device->spec.freq); SDL_UpdatedAudioDeviceFormat(device); // start this off sane. From ac3ab026fe9b5d2ff87ff61527bea79ddf4c2e41 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 03:01:37 -0400 Subject: [PATCH 3/9] audio: corrected comment about device format minimums. --- src/audio/SDL_audio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/audio/SDL_audio.c b/src/audio/SDL_audio.c index 24562c8f60..b86fc6bb35 100644 --- a/src/audio/SDL_audio.c +++ b/src/audio/SDL_audio.c @@ -1767,9 +1767,9 @@ static bool OpenPhysicalAudioDevice(SDL_AudioDevice *device, const SDL_AudioSpec SDL_copyp(&spec, inspec ? inspec : &device->default_spec); PrepareAudioFormat(device->recording, &spec); - /* We allow the device format to change if it's better than the current settings (by various definitions of "better"). This prevents - something low quality, like an old game using S8/8000Hz audio, from ruining a music thing playing at CD quality that tries to open later. - (or some VoIP library that opens for mono output ruining your surround-sound game because it got there first). + /* We impose a simple minimum on device formats. This prevents something low quality, like an old game using S8/8000Hz audio, + from ruining a music thing playing at CD quality that tries to open later, or some VoIP library that opens for mono output + ruining your surround-sound game because it got there first. These are just requests! The backend may change any of these values during OpenDevice method! */ const SDL_AudioFormat minimum_format = device->recording ? DEFAULT_AUDIO_RECORDING_FORMAT : DEFAULT_AUDIO_PLAYBACK_FORMAT; From 57b6e6c7f9cc13dcd6fd2b3756037c88dc840f6f Mon Sep 17 00:00:00 2001 From: Mason Remaley Date: Thu, 29 May 2025 14:23:44 -0700 Subject: [PATCH 4/9] Checks if xinput is loaded before trying to call xinput functions --- src/video/x11/SDL_x11pen.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c index f16da51c5a..95629da553 100644 --- a/src/video/x11/SDL_x11pen.c +++ b/src/video/x11/SDL_x11pen.c @@ -283,6 +283,7 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid) { + if (!X11_Xinput2IsInitialized()) return NULL; SDL_VideoData *data = _this->internal; int num_device_info = 0; XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info); @@ -297,6 +298,7 @@ X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid) void X11_RemovePenByDeviceID(int deviceid) { + if (!X11_Xinput2IsInitialized()) return; X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid); if (handle) { SDL_RemovePenDevice(0, handle->pen); @@ -306,6 +308,7 @@ void X11_RemovePenByDeviceID(int deviceid) void X11_InitPen(SDL_VideoDevice *_this) { + if (!X11_Xinput2IsInitialized()) return; SDL_VideoData *data = _this->internal; #define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False) @@ -335,6 +338,7 @@ static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdat void X11_QuitPen(SDL_VideoDevice *_this) { + if (!X11_Xinput2IsInitialized()) return; SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL); } From 9e0d9f30a7a2702d5b1eb5f9405967622601a34d Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 10:14:01 -0400 Subject: [PATCH 5/9] x11: Be a little less aggressive with Xinput2IsInitialized checks. Just in case this ever get deinitialized sooner, we'd still like to SDL_free() things on shutdown, etc. Reference PR #13148. --- src/video/x11/SDL_x11pen.c | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/src/video/x11/SDL_x11pen.c b/src/video/x11/SDL_x11pen.c index 95629da553..c29c629c4a 100644 --- a/src/video/x11/SDL_x11pen.c +++ b/src/video/x11/SDL_x11pen.c @@ -283,22 +283,22 @@ static X11_PenHandle *X11_MaybeAddPen(SDL_VideoDevice *_this, const XIDeviceInfo X11_PenHandle *X11_MaybeAddPenByDeviceID(SDL_VideoDevice *_this, int deviceid) { - if (!X11_Xinput2IsInitialized()) return NULL; - SDL_VideoData *data = _this->internal; - int num_device_info = 0; - XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info); - if (device_info) { - SDL_assert(num_device_info == 1); - X11_PenHandle *handle = X11_MaybeAddPen(_this, device_info); - X11_XIFreeDeviceInfo(device_info); - return handle; + if (X11_Xinput2IsInitialized()) { + SDL_VideoData *data = _this->internal; + int num_device_info = 0; + XIDeviceInfo *device_info = X11_XIQueryDevice(data->display, deviceid, &num_device_info); + if (device_info) { + SDL_assert(num_device_info == 1); + X11_PenHandle *handle = X11_MaybeAddPen(_this, device_info); + X11_XIFreeDeviceInfo(device_info); + return handle; + } } return NULL; } void X11_RemovePenByDeviceID(int deviceid) { - if (!X11_Xinput2IsInitialized()) return; X11_PenHandle *handle = X11_FindPenByDeviceID(deviceid); if (handle) { SDL_RemovePenDevice(0, handle->pen); @@ -308,7 +308,10 @@ void X11_RemovePenByDeviceID(int deviceid) void X11_InitPen(SDL_VideoDevice *_this) { - if (!X11_Xinput2IsInitialized()) return; + if (!X11_Xinput2IsInitialized()) { + return; // we need XIQueryDevice() for this. + } + SDL_VideoData *data = _this->internal; #define LOOKUP_PEN_ATOM(X) X11_XInternAtom(data->display, X, False) @@ -338,7 +341,6 @@ static void X11_FreePenHandle(SDL_PenID instance_id, void *handle, void *userdat void X11_QuitPen(SDL_VideoDevice *_this) { - if (!X11_Xinput2IsInitialized()) return; SDL_RemoveAllPenDevices(X11_FreePenHandle, NULL); } From b8187e2abd4b7c34e23e7ad313e494cc3b134681 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 10:43:08 -0400 Subject: [PATCH 6/9] wikiheaders: Trim whitespace from end of lines in section headers. --- build-scripts/wikiheaders.pl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/build-scripts/wikiheaders.pl b/build-scripts/wikiheaders.pl index 294666ffb5..220f13679b 100755 --- a/build-scripts/wikiheaders.pl +++ b/build-scripts/wikiheaders.pl @@ -825,21 +825,23 @@ sub print_big_ascii_string { die("Don't have a big ascii entry for '$ch'!\n") if not defined $rowsref; my $row = @$rowsref[$rownum]; + my $outstr = ''; if ($lowascii) { my @x = split //, $row; foreach (@x) { - my $v = ($_ eq "\x{2588}") ? 'X' : ' '; - print $fh $v; + $outstr .= ($_ eq "\x{2588}") ? 'X' : ' '; } } else { - print $fh $row; + $outstr = $row; } $charidx++; - - if ($charidx < $charcount) { - print $fh " "; + if ($charidx == $charcount) { + $outstr =~ s/\s*\Z//; # dump extra spaces at the end of the line. + } else { + $outstr .= ' '; # space between glyphs. } + print $fh $outstr; } print $fh "\n"; } From 8510331f6670b3266995bd1c62e7e3088fc2411c Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sun, 1 Jun 2025 10:48:32 -0400 Subject: [PATCH 7/9] .wikiheaders-options: Add Tray to quickreference categories. --- .wikiheaders-options | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.wikiheaders-options b/.wikiheaders-options index 9c2b5bb9be..88d48cfbe0 100644 --- a/.wikiheaders-options +++ b/.wikiheaders-options @@ -25,7 +25,7 @@ manpagesymbolfilterregex = \A[US]int\d+\Z headercategoryeval = s/\ASDL_test_?.*?\.h\Z//; s/\ASDL_?(.*?)\.h\Z/$1/; ucfirst(); quickrefenabled = 1 -quickrefcategoryorder = Init,Hints,Error,Version,Properties,Log,Video,Events,Keyboard,Mouse,Touch,Gamepad,Joystick,Haptic,Audio,Time,Timer,Render,SharedObject,Thread,Mutex,Atomic,Filesystem,IOStream,AsyncIO,Storage,Pixels,Surface,Blendmode,Rect,Camera,Clipboard,Dialog,GPU,Messagebox,Vulkan,Metal,Platform,Power,Sensor,Process,Bits,Endian,Assert,CPUInfo,Intrinsics,Locale,System,Misc,GUID,Main,Stdinc +quickrefcategoryorder = Init,Hints,Error,Version,Properties,Log,Video,Events,Keyboard,Mouse,Touch,Gamepad,Joystick,Haptic,Audio,Time,Timer,Render,SharedObject,Thread,Mutex,Atomic,Filesystem,IOStream,AsyncIO,Storage,Pixels,Surface,Blendmode,Rect,Camera,Clipboard,Dialog,Tray,Messagebox,GPU,Vulkan,Metal,Platform,Power,Sensor,Process,Bits,Endian,Assert,CPUInfo,Intrinsics,Locale,System,Misc,GUID,Main,Stdinc quickreftitle = SDL3 API Quick Reference quickrefurl = https://libsdl.org/ quickrefdesc = The latest version of this document can be found at https://wiki.libsdl.org/SDL3/QuickReference From d283f4651c94dcf15c159963bfeacba45cf994bb Mon Sep 17 00:00:00 2001 From: SDL Wiki Bot Date: Sun, 1 Jun 2025 21:52:34 +0000 Subject: [PATCH 8/9] Sync SDL3 wiki -> header [ci skip] --- include/SDL3/SDL_surface.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/SDL3/SDL_surface.h b/include/SDL3/SDL_surface.h index c4f49fb53d..69f4d69ca9 100644 --- a/include/SDL3/SDL_surface.h +++ b/include/SDL3/SDL_surface.h @@ -32,7 +32,8 @@ * There is also a simple .bmp loader, SDL_LoadBMP(). SDL itself does not * provide loaders for various other file formats, but there are several * excellent external libraries that do, including its own satellite library, - * SDL_image: + * [SDL_image](https://wiki.libsdl.org/SDL3_image) + * : * * https://github.com/libsdl-org/SDL_image */ From a314a58e7e0f5a8f2e06b84f4c2715907f57d34b Mon Sep 17 00:00:00 2001 From: SDL Wiki Bot Date: Sun, 1 Jun 2025 22:00:52 +0000 Subject: [PATCH 9/9] Sync SDL3 wiki -> header [ci skip] --- include/SDL3/SDL_log.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/SDL3/SDL_log.h b/include/SDL3/SDL_log.h index 3fd7ec2ede..2019c3b462 100644 --- a/include/SDL3/SDL_log.h +++ b/include/SDL3/SDL_log.h @@ -206,6 +206,9 @@ extern SDL_DECLSPEC void SDLCALL SDL_ResetLogPriorities(void); * SDL_LOG_PRIORITY_WARN and higher have a prefix showing their priority, e.g. * "WARNING: ". * + * This function makes a copy of its string argument, **prefix**, so it is not + * necessary to keep the value of **prefix** alive after the call returns. + * * \param priority the SDL_LogPriority to modify. * \param prefix the prefix to use for that log priority, or NULL to use no * prefix.