Skip to content

Commit 21903a2

Browse files
committed
Merge upstream SDL 3.2.20
2 parents 5c55c89 + 96292a5 commit 21903a2

32 files changed

+188
-104
lines changed

include/SDL3/SDL.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
*/
2121

2222
/**
23-
* Main include header for the SDL library, version 3.2.18
23+
* Main include header for the SDL library, version 3.2.20
2424
*
2525
* It is almost always best to include just this one header instead of
2626
* picking out individual headers included here. There are exceptions to

include/SDL3/SDL_assert.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ extern SDL_DECLSPEC SDL_AssertState SDLCALL SDL_ReportAssertion(SDL_AssertData *
362362
#define SDL_enabled_assert(condition) \
363363
do { \
364364
while ( !(condition) ) { \
365-
static struct SDL_AssertData sdl_assert_data = { 0, 0, #condition, 0, 0, 0, 0 }; \
365+
static struct SDL_AssertData sdl_assert_data = { false, 0, #condition, NULL, 0, NULL, NULL }; \
366366
const SDL_AssertState sdl_assert_state = SDL_ReportAssertion(&sdl_assert_data, SDL_FUNCTION, SDL_FILE, SDL_LINE); \
367367
if (sdl_assert_state == SDL_ASSERTION_RETRY) { \
368368
continue; /* go again. */ \

include/SDL3/SDL_audio.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,10 @@ extern SDL_DECLSPEC void SDLCALL SDL_CloseAudioDevice(SDL_AudioDeviceID devid);
942942
* Binding a stream to a device will set its output format for playback
943943
* devices, and its input format for recording devices, so they match the
944944
* device's settings. The caller is welcome to change the other end of the
945-
* stream's format at any time with SDL_SetAudioStreamFormat().
945+
* stream's format at any time with SDL_SetAudioStreamFormat(). If the other
946+
* end of the stream's format has never been set (the audio stream was created
947+
* with a NULL audio spec), this function will set it to match the device
948+
* end's format.
946949
*
947950
* \param devid an audio device to bind a stream to.
948951
* \param streams an array of audio streams to bind.

include/SDL3/SDL_clipboard.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardText(const char *text);
106106
/**
107107
* Get UTF-8 text from the clipboard.
108108
*
109-
* This functions returns an empty string if there was not enough memory left
109+
* This function returns an empty string if there is not enough memory left
110110
* for a copy of the clipboard's content.
111111
*
112112
* \returns the clipboard text on success or an empty string on failure; call
@@ -155,7 +155,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetPrimarySelectionText(const char *text);
155155
/**
156156
* Get UTF-8 text from the primary selection.
157157
*
158-
* This functions returns an empty string if there was not enough memory left
158+
* This function returns an empty string if there is not enough memory left
159159
* for a copy of the primary selection's content.
160160
*
161161
* \returns the primary selection text on success or an empty string on
@@ -194,15 +194,15 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
194194
* clipboard is cleared or new data is set. The clipboard is automatically
195195
* cleared in SDL_Quit().
196196
*
197-
* \param userdata a pointer to provided user data.
197+
* \param userdata a pointer to the provided user data.
198198
* \param mime_type the requested mime-type.
199199
* \param size a pointer filled in with the length of the returned data.
200200
* \returns a pointer to the data for the provided mime-type. Returning NULL
201-
* or setting length to 0 will cause no data to be sent to the
201+
* or setting the length to 0 will cause no data to be sent to the
202202
* "receiver". It is up to the receiver to handle this. Essentially
203203
* returning no data is more or less undefined behavior and may cause
204204
* breakage in receiving applications. The returned data will not be
205-
* freed so it needs to be retained and dealt with internally.
205+
* freed, so it needs to be retained and dealt with internally.
206206
*
207207
* \since This function is available since SDL 3.2.0.
208208
*
@@ -211,10 +211,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasPrimarySelectionText(void);
211211
typedef const void *(SDLCALL *SDL_ClipboardDataCallback)(void *userdata, const char *mime_type, size_t *size);
212212

213213
/**
214-
* Callback function that will be called when the clipboard is cleared, or new
214+
* Callback function that will be called when the clipboard is cleared, or when new
215215
* data is set.
216216
*
217-
* \param userdata a pointer to provided user data.
217+
* \param userdata a pointer to the provided user data.
218218
*
219219
* \since This function is available since SDL 3.2.0.
220220
*
@@ -231,15 +231,15 @@ typedef void (SDLCALL *SDL_ClipboardCleanupCallback)(void *userdata);
231231
* respond with the data for the requested mime-type.
232232
*
233233
* The size of text data does not include any terminator, and the text does
234-
* not need to be null terminated (e.g. you can directly copy a portion of a
234+
* not need to be null-terminated (e.g., you can directly copy a portion of a
235235
* document).
236236
*
237237
* \param callback a function pointer to the function that provides the
238238
* clipboard data.
239239
* \param cleanup a function pointer to the function that cleans up the
240240
* clipboard data.
241241
* \param userdata an opaque pointer that will be forwarded to the callbacks.
242-
* \param mime_types a list of mime-types that are being offered.
242+
* \param mime_types a list of mime-types that are being offered. SDL copies the given list.
243243
* \param num_mime_types the number of mime-types in the mime_types list.
244244
* \returns true on success or false on failure; call SDL_GetError() for more
245245
* information.
@@ -269,10 +269,10 @@ extern SDL_DECLSPEC bool SDLCALL SDL_SetClipboardData(SDL_ClipboardDataCallback
269269
extern SDL_DECLSPEC bool SDLCALL SDL_ClearClipboardData(void);
270270

271271
/**
272-
* Get the data from clipboard for a given mime type.
272+
* Get the data from the clipboard for a given mime type.
273273
*
274274
* The size of text data does not include the terminator, but the text is
275-
* guaranteed to be null terminated.
275+
* guaranteed to be null-terminated.
276276
*
277277
* \param mime_type the mime type to read from the clipboard.
278278
* \param size a pointer filled in with the length of the returned data.
@@ -292,8 +292,8 @@ extern SDL_DECLSPEC void * SDLCALL SDL_GetClipboardData(const char *mime_type, s
292292
/**
293293
* Query whether there is data in the clipboard for the provided mime type.
294294
*
295-
* \param mime_type the mime type to check for data for.
296-
* \returns true if there exists data in clipboard for the provided mime type,
295+
* \param mime_type the mime type to check for data.
296+
* \returns true if data exists in the clipboard for the provided mime type,
297297
* false if it does not.
298298
*
299299
* \threadsafety This function should only be called on the main thread.
@@ -310,7 +310,7 @@ extern SDL_DECLSPEC bool SDLCALL SDL_HasClipboardData(const char *mime_type);
310310
*
311311
* \param num_mime_types a pointer filled with the number of mime types, may
312312
* be NULL.
313-
* \returns a null terminated array of strings with mime types, or NULL on
313+
* \returns a null-terminated array of strings with mime types, or NULL on
314314
* failure; call SDL_GetError() for more information. This should be
315315
* freed with SDL_free() when it is no longer needed.
316316
*

include/SDL3/SDL_gpu.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1549,7 +1549,7 @@ typedef struct SDL_GPUSamplerCreateInfo
15491549
typedef struct SDL_GPUVertexBufferDescription
15501550
{
15511551
Uint32 slot; /**< The binding slot of the vertex buffer. */
1552-
Uint32 pitch; /**< The byte pitch between consecutive elements of the vertex buffer. */
1552+
Uint32 pitch; /**< The size of a single element + the offset between elements. */
15531553
SDL_GPUVertexInputRate input_rate; /**< Whether attribute addressing is a function of the vertex index or instance index. */
15541554
Uint32 instance_step_rate; /**< Reserved for future use. Must be set to 0. */
15551555
} SDL_GPUVertexBufferDescription;

include/SDL3/SDL_scancode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ typedef enum SDL_Scancode
208208

209209
SDL_SCANCODE_NONUSBACKSLASH = 100, /**< This is the additional key that ISO
210210
* keyboards have over ANSI ones,
211-
* located between left shift and Y.
211+
* located between left shift and Z.
212212
* Produces GRAVE ACCENT and TILDE in a
213213
* US or UK Mac layout, REVERSE SOLIDUS
214214
* (backslash) and VERTICAL LINE in a

include/SDL3/SDL_version.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ extern "C" {
6262
*
6363
* \since This macro is available since SDL 3.2.0.
6464
*/
65-
#define SDL_MICRO_VERSION 18
65+
#define SDL_MICRO_VERSION 20
6666

6767
/**
6868
* This macro turns the version numbers into a numeric value.

include/build_config/SDL_build_config_windows.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,9 @@ typedef unsigned int uintptr_t;
111111
# define SDL_DISABLE_AVX 1
112112
#endif
113113

114+
#define HAVE_STDARG_H 1
115+
#define HAVE_STDDEF_H 1
116+
114117
/* This can be disabled to avoid C runtime dependencies and manifest requirements */
115118
#ifndef HAVE_LIBC
116119
#define HAVE_LIBC 1
@@ -122,8 +125,6 @@ typedef unsigned int uintptr_t;
122125
#define HAVE_LIMITS_H 1
123126
#define HAVE_MATH_H 1
124127
#define HAVE_SIGNAL_H 1
125-
#define HAVE_STDARG_H 1
126-
#define HAVE_STDDEF_H 1
127128
#define HAVE_STDIO_H 1
128129
#define HAVE_STDLIB_H 1
129130
#define HAVE_STRING_H 1
@@ -153,7 +154,6 @@ typedef unsigned int uintptr_t;
153154
#define HAVE_STRCMP 1
154155
#define HAVE_STRNCMP 1
155156
#define HAVE_STRPBRK 1
156-
#define HAVE_VSSCANF 1
157157
#define HAVE_VSNPRINTF 1
158158
#define HAVE_ACOS 1
159159
#define HAVE_ASIN 1
@@ -211,10 +211,7 @@ typedef unsigned int uintptr_t;
211211
#if _MSC_VER >= 1400
212212
#define HAVE__FSEEKI64 1
213213
#endif
214-
#endif /* _MSC_VER */
215-
#else
216-
#define HAVE_STDARG_H 1
217-
#define HAVE_STDDEF_H 1
214+
#endif /* _MSC_VER */
218215
#endif
219216

220217
/* Enable various audio drivers */

src/audio/SDL_audio.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,7 +1153,10 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
11531153
// We should have updated this elsewhere if the format changed!
11541154
SDL_assert(SDL_AudioSpecsEqual(&stream->dst_spec, &device->spec, NULL, NULL));
11551155

1156+
SDL_assert(stream->src_spec.format != SDL_AUDIO_UNKNOWN);
1157+
11561158
const int br = SDL_GetAtomicInt(&logdev->paused) ? 0 : SDL_GetAudioStreamDataAdjustGain(stream, device_buffer, buffer_size, logdev->gain);
1159+
11571160
if (br < 0) { // Probably OOM. Kill the audio device; the whole thing is likely dying soon anyhow.
11581161
failed = true;
11591162
SDL_memset(device_buffer, device->silence_value, buffer_size); // just supply silence to the device before we die.
@@ -1195,6 +1198,8 @@ bool SDL_PlaybackAudioThreadIterate(SDL_AudioDevice *device)
11951198
// We should have updated this elsewhere if the format changed!
11961199
SDL_assert(SDL_AudioSpecsEqual(&stream->dst_spec, &outspec, NULL, NULL));
11971200

1201+
SDL_assert(stream->src_spec.format != SDL_AUDIO_UNKNOWN);
1202+
11981203
/* this will hold a lock on `stream` while getting. We don't explicitly lock the streams
11991204
for iterating here because the binding linked list can only change while the device lock is held.
12001205
(we _do_ lock the stream during binding/unbinding to make sure that two threads can't try to bind
@@ -1330,6 +1335,7 @@ bool SDL_RecordingAudioThreadIterate(SDL_AudioDevice *device)
13301335
SDL_assert(stream->src_spec.format == ((logdev->postmix || (logdev->gain != 1.0f)) ? SDL_AUDIO_F32 : device->spec.format));
13311336
SDL_assert(stream->src_spec.channels == device->spec.channels);
13321337
SDL_assert(stream->src_spec.freq == device->spec.freq);
1338+
SDL_assert(stream->dst_spec.format != SDL_AUDIO_UNKNOWN);
13331339

13341340
void *final_buf = output_buffer;
13351341

@@ -1975,10 +1981,6 @@ bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *stre
19751981
} else if (logdev->simplified) {
19761982
result = SDL_SetError("Cannot change stream bindings on device opened with SDL_OpenAudioDeviceStream");
19771983
} else {
1978-
1979-
// !!! FIXME: We'll set the device's side's format below, but maybe we should refuse to bind a stream if the app's side doesn't have a format set yet.
1980-
// !!! FIXME: Actually, why do we allow there to be an invalid format, again?
1981-
19821984
// make sure start of list is sane.
19831985
SDL_assert(!logdev->bound_streams || (logdev->bound_streams->prev_binding == NULL));
19841986

@@ -2013,9 +2015,17 @@ bool SDL_BindAudioStreams(SDL_AudioDeviceID devid, SDL_AudioStream * const *stre
20132015

20142016
if (result) {
20152017
// Now that everything is verified, chain everything together.
2018+
const bool recording = device->recording;
20162019
for (int i = 0; i < num_streams; i++) {
20172020
SDL_AudioStream *stream = streams[i];
20182021
if (stream) { // shouldn't be NULL, but just in case...
2022+
// if the stream never had its non-device-end format set, just set it to the device end's format.
2023+
if (recording && (stream->dst_spec.format == SDL_AUDIO_UNKNOWN)) {
2024+
SDL_copyp(&stream->dst_spec, &device->spec);
2025+
} else if (!recording && (stream->src_spec.format == SDL_AUDIO_UNKNOWN)) {
2026+
SDL_copyp(&stream->src_spec, &device->spec);
2027+
}
2028+
20192029
stream->bound_device = logdev;
20202030
stream->prev_binding = NULL;
20212031
stream->next_binding = logdev->bound_streams;

src/audio/SDL_audiotypecvt.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,10 @@ static void SDL_TARGETING("ssse3") SDL_Convert_Swap32_SSSE3(Uint32* dst, const U
537537
// behavior. However, the compiler support for this pragma is bad.
538538
#if defined(__clang__)
539539
#if __clang_major__ >= 12
540+
#if defined(__aarch64__)
540541
#pragma STDC FENV_ACCESS ON
541542
#endif
543+
#endif
542544
#elif defined(_MSC_VER)
543545
#pragma fenv_access (on)
544546
#elif defined(__GNUC__)
@@ -814,8 +816,10 @@ static void SDL_Convert_Swap32_NEON(Uint32* dst, const Uint32* src, int num_samp
814816

815817
#if defined(__clang__)
816818
#if __clang_major__ >= 12
819+
#if defined(__aarch64__)
817820
#pragma STDC FENV_ACCESS DEFAULT
818821
#endif
822+
#endif
819823
#elif defined(_MSC_VER)
820824
#pragma fenv_access (off)
821825
#elif defined(__GNUC__)

0 commit comments

Comments
 (0)