Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/libsdl-org/SDL into libsdl-…
Browse files Browse the repository at this point in the history
…org-main
  • Loading branch information
capehill committed Oct 28, 2023
2 parents c31c29d + 552bee4 commit 0ec97ae
Show file tree
Hide file tree
Showing 138 changed files with 2,179 additions and 1,997 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ private boolean isXboxOneController(UsbDevice usbDevice, UsbInterface usbInterfa
final int XB1_IFACE_SUBCLASS = 71;
final int XB1_IFACE_PROTOCOL = 208;
final int[] SUPPORTED_VENDORS = {
0x03f0, // HP
0x044f, // Thrustmaster
0x045e, // Microsoft
0x0738, // Mad Catz
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/gen_audio_channel_conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static void write_converter(const int fromchans, const int tochans)
"\n", lowercase(fromstr), lowercase(tostr));

if (convert_backwards) { /* must convert backwards when growing the output in-place. */
printf(" /* convert backwards, since output is growing in-place. */\n");
printf(" // convert backwards, since output is growing in-place.\n");
printf(" src += (num_frames-1)");
if (fromchans != 1) {
printf(" * %d", fromchans);
Expand Down Expand Up @@ -425,7 +425,7 @@ int main(void)
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
"/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */\n"
"// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c\n"
"\n"
"\n"
"typedef void (*SDL_AudioChannelConverter)(float *dst, const float *src, int num_frames);\n"
Expand Down
4 changes: 2 additions & 2 deletions build-scripts/gen_audio_resampler_filter.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Built with:
gcc -o genfilter build-scripts/gen_audio_resampler_filter.c -lm && ./genfilter > src/audio/SDL_audio_resampler_filter.h
*/
*/

/*
SDL's resampler uses a "bandlimited interpolation" algorithm:
Expand Down Expand Up @@ -128,7 +128,7 @@ int main(void)
" 3. This notice may not be removed or altered from any source distribution.\n"
"*/\n"
"\n"
"/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c */\n"
"// DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_resampler_filter.c\n"
"\n"
"#define RESAMPLER_ZERO_CROSSINGS %d\n"
"#define RESAMPLER_BITS_PER_SAMPLE %d\n"
Expand Down
2 changes: 1 addition & 1 deletion build-scripts/rename_symbols.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def main():

else:
if len(args.args) < 3:
print("Usage: %s oldname newname files_or_directories ..." % sys.argv[0])
print("Usage: %s [--substring] oldname newname files_or_directories ..." % sys.argv[0])
exit(1)

replacements = { args.args[0]: args.args[1] }
Expand Down
6 changes: 5 additions & 1 deletion docs/README-migration.md
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,10 @@ The following functions have been renamed:

## SDL_mutex.h

SDL_MUTEX_MAXWAIT has been removed; it suggested there was a maximum timeout one could outlive, instead of an infinite wait. Instead, pass a -1 to functions that accepted this symbol.

SDL_LockMutex and SDL_UnlockMutex now return void; if the mutex is valid (including being a NULL pointer, which returns immediately), these functions never fail. If the mutex is invalid or the caller does something illegal, like unlock another thread's mutex, this is considered undefined behavior.

The following functions have been renamed:
* SDL_CondBroadcast() => SDL_BroadcastCondition()
* SDL_CondSignal() => SDL_SignalCondition()
Expand Down Expand Up @@ -738,7 +742,7 @@ The following functions have been renamed:
* SDL_PixelFormatEnumToMasks() => SDL_GetMasksForPixelFormatEnum()

The following symbols have been renamed:
* SDL_DISPLAYEVENT_DISCONNECTED => SDL_EVENT_DISPLAY_DISCONNECTED
* SDL_DISPLAYEVENT_DISCONNECTED => SDL_EVENT_DISPLAY_REMOVED
* SDL_DISPLAYEVENT_MOVED => SDL_EVENT_DISPLAY_MOVED
* SDL_DISPLAYEVENT_ORIENTATION => SDL_EVENT_DISPLAY_ORIENTATION
* SDL_WINDOWEVENT_CLOSE => SDL_EVENT_WINDOW_CLOSE_REQUESTED
Expand Down
5 changes: 2 additions & 3 deletions include/SDL3/SDL_audio.h
Original file line number Diff line number Diff line change
Expand Up @@ -660,7 +660,7 @@ extern DECLSPEC SDL_AudioDeviceID SDLCALL SDL_GetAudioStreamDevice(SDL_AudioStre
*
* \param src_spec The format details of the input audio
* \param dst_spec The format details of the output audio
* \returns 0 on success, or -1 on error.
* \returns a new audio stream on success, or NULL on failure.
*
* \threadsafety It is safe to call this function from any thread.
*
Expand Down Expand Up @@ -1281,8 +1281,7 @@ extern DECLSPEC int SDLCALL SDL_SetAudioPostmixCallback(SDL_AudioDeviceID devid,
* audio data allocated by the function is written to `audio_buf` and its
* length in bytes to `audio_len`. The SDL_AudioSpec members `freq`,
* `channels`, and `format` are set to the values of the audio data in the
* buffer. The `samples` member is set to a sane default and all others are
* set to zero.
* buffer.
*
* It's necessary to use SDL_free() to free the audio data returned in
* `audio_buf` when it is no longer used.
Expand Down
4 changes: 2 additions & 2 deletions include/SDL3/SDL_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ typedef enum
/* Display events */
/* 0x150 was SDL_DISPLAYEVENT, reserve the number for sdl2-compat */
SDL_EVENT_DISPLAY_ORIENTATION = 0x151, /**< Display orientation has changed to data1 */
SDL_EVENT_DISPLAY_CONNECTED, /**< Display has been added to the system */
SDL_EVENT_DISPLAY_DISCONNECTED, /**< Display has been removed from the system */
SDL_EVENT_DISPLAY_ADDED, /**< Display has been added to the system */
SDL_EVENT_DISPLAY_REMOVED, /**< Display has been removed from the system */
SDL_EVENT_DISPLAY_MOVED, /**< Display has changed position */
SDL_EVENT_DISPLAY_CONTENT_SCALE_CHANGED, /**< Display has changed content scale */
SDL_EVENT_DISPLAY_FIRST = SDL_EVENT_DISPLAY_ORIENTATION,
Expand Down
69 changes: 39 additions & 30 deletions include/SDL3/SDL_mutex.h
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,6 @@ extern "C" {
*/
#define SDL_MUTEX_TIMEDOUT 1

/**
* This is the timeout value which corresponds to never time out.
*/
#define SDL_MUTEX_MAXWAIT -1


/**
* \name Mutex functions
Expand Down Expand Up @@ -169,13 +164,15 @@ extern DECLSPEC SDL_Mutex *SDLCALL SDL_CreateMutex(void);
* unlock it the same number of times before it is actually made available for
* other threads in the system (this is known as a "recursive mutex").
*
* This function does not fail; if mutex is NULL, it will return immediately
* having locked nothing. If the mutex is valid, this function will always
* block until it can lock the mutex, and return with it locked.
*
* \param mutex the mutex to lock
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mutex);
extern DECLSPEC void SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mutex);

/**
* Try to lock a mutex without blocking.
Expand All @@ -186,9 +183,13 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_Mutex *mutex) SDL_ACQUIRE(mutex);
* This technique is useful if you need exclusive access to a resource but
* don't want to wait for it, and will return to it to try again later.
*
* This function does not fail; if mutex is NULL, it will return 0 immediately
* having locked nothing. If the mutex is valid, this function will always
* either lock the mutex and return 0, or return SDL_MUTEX_TIMEOUT and lock
* nothing.
*
* \param mutex the mutex to try to lock
* \returns 0, `SDL_MUTEX_TIMEDOUT`, or -1 on error; call SDL_GetError() for
* more information.
* \returns 0 or `SDL_MUTEX_TIMEDOUT`
*
* \since This function is available since SDL 3.0.0.
*
Expand All @@ -210,12 +211,10 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_Mutex *mutex) SDL_TRY_ACQUIRE(0
* thread, and doing so results in undefined behavior.
*
* \param mutex the mutex to unlock.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_Mutex *mutex) SDL_RELEASE(mutex);
extern DECLSPEC void SDLCALL SDL_UnlockMutex(SDL_Mutex *mutex) SDL_RELEASE(mutex);

/**
* Destroy a mutex created with SDL_CreateMutex().
Expand Down Expand Up @@ -321,15 +320,17 @@ extern DECLSPEC SDL_RWLock *SDLCALL SDL_CreateRWLock(void);
* lock before requesting a read-only lock. (But, of course, if you have the
* write lock, you don't need further locks to read in any case.)
*
* This function does not fail; if rwlock is NULL, it will return immediately
* having locked nothing. If the rwlock is valid, this function will always
* block until it can lock the mutex, and return with it locked.
*
* \param rwlock the read/write lock to lock
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_UnlockRWLock
*/
extern DECLSPEC int SDLCALL SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_ACQUIRE_SHARED(rwlock);
extern DECLSPEC void SDLCALL SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_ACQUIRE_SHARED(rwlock);

/**
* Lock the read/write lock for _write_ operations.
Expand All @@ -348,15 +349,17 @@ extern DECLSPEC int SDLCALL SDL_LockRWLockForReading(SDL_RWLock *rwlock) SDL_ACQ
* read-only lock. Doing so results in undefined behavior. Unlock the
* read-only lock before requesting a write lock.
*
* This function does not fail; if rwlock is NULL, it will return immediately
* having locked nothing. If the rwlock is valid, this function will always
* block until it can lock the mutex, and return with it locked.
*
* \param rwlock the read/write lock to lock
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_UnlockRWLock
*/
extern DECLSPEC int SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_ACQUIRE(rwlock);
extern DECLSPEC void SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_ACQUIRE(rwlock);

/**
* Try to lock a read/write lock _for reading_ without blocking.
Expand All @@ -370,9 +373,13 @@ extern DECLSPEC int SDLCALL SDL_LockRWLockForWriting(SDL_RWLock *rwlock) SDL_ACQ
* Trying to lock for read-only access can succeed if other threads are
* holding read-only locks, as this won't prevent access.
*
* This function does not fail; if rwlock is NULL, it will return 0
* immediately having locked nothing. If rwlock is valid, this function will
* always either lock the rwlock and return 0, or return SDL_RWLOCK_TIMEOUT
* and lock nothing.
*
* \param rwlock the rwlock to try to lock
* \returns 0, `SDL_RWLOCK_TIMEDOUT`, or -1 on error; call SDL_GetError() for
* more information.
* \returns 0 or `SDL_RWLOCK_TIMEDOUT`
*
* \since This function is available since SDL 3.0.0.
*
Expand Down Expand Up @@ -400,9 +407,13 @@ extern DECLSPEC int SDLCALL SDL_TryLockRWLockForReading(SDL_RWLock *rwlock) SDL_
* read-only lock. Doing so results in undefined behavior. Unlock the
* read-only lock before requesting a write lock.
*
* This function does not fail; if rwlock is NULL, it will return 0
* immediately having locked nothing. If rwlock is valid, this function will
* always either lock the rwlock and return 0, or return SDL_RWLOCK_TIMEOUT
* and lock nothing.
*
* \param rwlock the rwlock to try to lock
* \returns 0, `SDL_RWLOCK_TIMEDOUT`, or -1 on error; call SDL_GetError() for
* more information.
* \returns 0 or `SDL_RWLOCK_TIMEDOUT`
*
* \since This function is available since SDL 3.0.0.
*
Expand All @@ -428,12 +439,10 @@ extern DECLSPEC int SDLCALL SDL_TryLockRWLockForWriting(SDL_RWLock *rwlock) SDL_
* thread, and doing so results in undefined behavior.
*
* \param rwlock the rwlock to unlock.
* \returns 0 on success or a negative error code on failure; call
* SDL_GetError() for more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern DECLSPEC int SDLCALL SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_RELEASE_SHARED(rwlock);
extern DECLSPEC void SDLCALL SDL_UnlockRWLock(SDL_RWLock *rwlock) SDL_RELEASE_GENERIC(rwlock);

/**
* Destroy a read/write lock created with SDL_CreateRWLock().
Expand Down Expand Up @@ -521,7 +530,7 @@ extern DECLSPEC void SDLCALL SDL_DestroySemaphore(SDL_Semaphore *sem);
* semaphore value.
*
* This function is the equivalent of calling SDL_WaitSemaphoreTimeout() with
* a time length of `SDL_MUTEX_MAXWAIT`.
* a time length of -1.
*
* \param sem the semaphore wait on
* \returns 0 on success or a negative error code on failure; call
Expand Down Expand Up @@ -708,7 +717,7 @@ extern DECLSPEC int SDLCALL SDL_BroadcastCondition(SDL_Condition *cond);
* behavior.
*
* This function is the equivalent of calling SDL_WaitConditionTimeout() with
* a time length of `SDL_MUTEX_MAXWAIT`.
* a time length of -1.
*
* \param cond the condition variable to wait on
* \param mutex the mutex used to coordinate thread access
Expand Down Expand Up @@ -740,8 +749,8 @@ extern DECLSPEC int SDLCALL SDL_WaitCondition(SDL_Condition *cond, SDL_Mutex *mu
*
* \param cond the condition variable to wait on
* \param mutex the mutex used to coordinate thread access
* \param timeoutMS the maximum time to wait, in milliseconds, or
* `SDL_MUTEX_MAXWAIT` to wait indefinitely
* \param timeoutMS the maximum time to wait, in milliseconds, or -1 to wait
* indefinitely
* \returns 0 if the condition variable is signaled, `SDL_MUTEX_TIMEDOUT` if
* the condition is not signaled in the allotted time, or a negative
* error code on failure; call SDL_GetError() for more information.
Expand Down
22 changes: 11 additions & 11 deletions include/SDL3/SDL_oldnames.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@
#define SDL_ControllerDeviceEvent SDL_GamepadDeviceEvent
#define SDL_ControllerSensorEvent SDL_GamepadSensorEvent
#define SDL_ControllerTouchpadEvent SDL_GamepadTouchpadEvent
#define SDL_DISPLAYEVENT_CONNECTED SDL_EVENT_DISPLAY_CONNECTED
#define SDL_DISPLAYEVENT_DISCONNECTED SDL_EVENT_DISPLAY_DISCONNECTED
#define SDL_DISPLAYEVENT_CONNECTED SDL_EVENT_DISPLAY_ADDED
#define SDL_DISPLAYEVENT_DISCONNECTED SDL_EVENT_DISPLAY_REMOVED
#define SDL_DISPLAYEVENT_MOVED SDL_EVENT_DISPLAY_MOVED
#define SDL_DISPLAYEVENT_ORIENTATION SDL_EVENT_DISPLAY_ORIENTATION
#define SDL_DROPBEGIN SDL_EVENT_DROP_BEGIN
Expand Down Expand Up @@ -524,23 +524,23 @@
#define SDL_AUDIODEVICEADDED SDL_AUDIODEVICEADDED_renamed_SDL_EVENT_AUDIO_DEVICE_ADDED
#define SDL_AUDIODEVICEREMOVED SDL_AUDIODEVICEREMOVED_renamed_SDL_EVENT_AUDIO_DEVICE_REMOVED
#define SDL_CLIPBOARDUPDATE SDL_CLIPBOARDUPDATE_renamed_SDL_EVENT_CLIPBOARD_UPDATE
#define SDL_CONTROLLERAXISMOTION SDL_CONTROLLERAXISMOTION_renamed_SDL_GAMEPADAXISMOTION
#define SDL_CONTROLLERBUTTONDOWN SDL_CONTROLLERBUTTONDOWN_renamed_SDL_GAMEPADBUTTONDOWN
#define SDL_CONTROLLERBUTTONUP SDL_CONTROLLERBUTTONUP_renamed_SDL_GAMEPADBUTTONUP
#define SDL_CONTROLLERAXISMOTION SDL_CONTROLLERAXISMOTION_renamed_SDL_EVENT_GAMEPAD_AXIS_MOTION
#define SDL_CONTROLLERBUTTONDOWN SDL_CONTROLLERBUTTONDOWN_renamed_SDL_EVENT_GAMEPAD_BUTTON_DOWN
#define SDL_CONTROLLERBUTTONUP SDL_CONTROLLERBUTTONUP_renamed_SDL_EVENT_GAMEPAD_BUTTON_UP
#define SDL_CONTROLLERDEVICEADDED SDL_CONTROLLERDEVICEADDED_renamed_SDL_EVENT_GAMEPAD_ADDED
#define SDL_CONTROLLERDEVICEREMAPPED SDL_CONTROLLERDEVICEREMAPPED_renamed_SDL_EVENT_GAMEPAD_REMAPPED
#define SDL_CONTROLLERDEVICEREMOVED SDL_CONTROLLERDEVICEREMOVED_renamed_SDL_EVENT_GAMEPAD_REMOVED
#define SDL_CONTROLLERSENSORUPDATE SDL_CONTROLLERSENSORUPDATE_renamed_SDL_GAMEPADSENSORUPDATE
#define SDL_CONTROLLERTOUCHPADDOWN SDL_CONTROLLERTOUCHPADDOWN_renamed_SDL_GAMEPADTOUCHPADDOWN
#define SDL_CONTROLLERTOUCHPADMOTION SDL_CONTROLLERTOUCHPADMOTION_renamed_SDL_GAMEPADTOUCHPADMOTION
#define SDL_CONTROLLERTOUCHPADUP SDL_CONTROLLERTOUCHPADUP_renamed_SDL_GAMEPADTOUCHPADUP
#define SDL_CONTROLLERSENSORUPDATE SDL_CONTROLLERSENSORUPDATE_renamed_SDL_EVENT_GAMEPAD_SENSOR_UPDATE
#define SDL_CONTROLLERTOUCHPADDOWN SDL_CONTROLLERTOUCHPADDOWN_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_DOWN
#define SDL_CONTROLLERTOUCHPADMOTION SDL_CONTROLLERTOUCHPADMOTION_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_MOTION
#define SDL_CONTROLLERTOUCHPADUP SDL_CONTROLLERTOUCHPADUP_renamed_SDL_EVENT_GAMEPAD_TOUCHPAD_UP
#define SDL_ControllerAxisEvent SDL_ControllerAxisEvent_renamed_SDL_GamepadAxisEvent
#define SDL_ControllerButtonEvent SDL_ControllerButtonEvent_renamed_SDL_GamepadButtonEvent
#define SDL_ControllerDeviceEvent SDL_ControllerDeviceEvent_renamed_SDL_GamepadDeviceEvent
#define SDL_ControllerSensorEvent SDL_ControllerSensorEvent_renamed_SDL_GamepadSensorEvent
#define SDL_ControllerTouchpadEvent SDL_ControllerTouchpadEvent_renamed_SDL_GamepadTouchpadEvent
#define SDL_DISPLAYEVENT_CONNECTED SDL_DISPLAYEVENT_CONNECTED_renamed_SDL_EVENT_DISPLAY_CONNECTED
#define SDL_DISPLAYEVENT_DISCONNECTED SDL_DISPLAYEVENT_DISCONNECTED_renamed_SDL_EVENT_DISPLAY_DISCONNECTED
#define SDL_DISPLAYEVENT_CONNECTED SDL_DISPLAYEVENT_CONNECTED_renamed_SDL_EVENT_DISPLAY_ADDED
#define SDL_DISPLAYEVENT_DISCONNECTED SDL_DISPLAYEVENT_DISCONNECTED_renamed_SDL_EVENT_DISPLAY_REMOVED
#define SDL_DISPLAYEVENT_MOVED SDL_DISPLAYEVENT_MOVED_renamed_SDL_EVENT_DISPLAY_MOVED
#define SDL_DISPLAYEVENT_ORIENTATION SDL_DISPLAYEVENT_ORIENTATION_renamed_SDL_EVENT_DISPLAY_ORIENTATION
#define SDL_DROPBEGIN SDL_DROPBEGIN_renamed_SDL_EVENT_DROP_BEGIN
Expand Down
Loading

0 comments on commit 0ec97ae

Please sign in to comment.