Commit graph

707 commits

Author SHA1 Message Date
Francisco Javier Trujillo Mata b728de788e Fixed audio 2023-02-11 13:23:08 -08:00
Bruce Mitchener a8e89f2567 emscripten: Update deprecated calls to EM_ASM*.
`EM_ASM_` and `EM_ASM_INT_V` are calls that have been deprecated
for a long time.

Since the return value isn't used for the call to `EM_ASM_`, it
can be replaced with `EM_ASM`.

`EM_ASM_INT_V` is now (for the last few years) `EM_ASM_INT`.
2023-02-09 23:10:17 -08:00
Sam Lantinga 5b77ad54c4 Fixed order and constness of parameters to SDL_ConvertAudioSamples() 2023-02-09 17:49:35 -08:00
Sylvain e2e5e670bf Remove returns int from Destroy/Close/Unlock functions 2023-02-09 07:57:14 -08:00
Linus Probert 3bd737d44c Add error returns to void functions that can fail/set errors.
This takes care of the last set of void functions that could
potentially be shifted to instead return an int indicating success and
setting an error in case of an error.
2023-02-09 07:23:21 -08:00
Sylvain b305d9e3c0 Change return type from void to int for audio function. Eventually set invalid parameter error. 2023-02-08 17:43:44 -08:00
Sylvain c5c94a6be6 Change return type from void to int, for functions that set an error
(SDL_SetError(), SDL_OutOfMemory(), SDL_Unsupported(), SDL_InvalidParam())

Update prototype to forward errors to generic layer, for the functions:
MoveCursor, WarpMouse, GL_DeleteContext, GetDisplayModes.

Check invalid parameter in SDL_SetTextInputRect() generic layer.
2023-02-07 13:51:45 -08:00
Sylvain Becker cb6b8b0132
Simplify flags testing (#7220) 2023-02-03 13:08:42 -08:00
Sylvain 052b14eb65 Add SDL_ConvertAudioSamples() helper function 2023-01-24 08:26:09 -08:00
Sam Lantinga 7b50bae524 Renamed SDL events for clarity
Fixes https://github.com/libsdl-org/SDL/issues/6877
2023-01-24 07:26:48 -08:00
Sylvain 64bc0a1612 Remove AudioCVT interface in favor of SDL_AudioStream 2023-01-22 11:31:30 -05:00
Fabian Greffrath 9b861d2ea4
add support for libsamplerate's "linear" resampling mode
Fixes #6998

(cherry picked from commit 8efa1f8fc6)
2023-01-16 23:49:26 -05:00
Sylvain 4156e6f52e SDL_CreateAudioStream: check for invalid parameters 2023-01-16 09:24:27 +01:00
Sam Lantinga 237086c917 Fixed Xcode 14.2 warnings 2023-01-10 15:51:14 -08:00
Sam Lantinga dc280c17a0 Moved SDL_intrin.h back into the public headers for application use 2023-01-10 15:50:35 -08:00
Sam Lantinga e9b86eebf3 Functions which return function pointers now return SDL_FunctionPointer instead of void*
This fixes the clang warning "Cast between pointer-to-function and pointer-to-object is an extension"

You can define SDL_FUNCTION_POINTER_IS_VOID_POINTER in your project to restore the previous behavior.

Fixes https://github.com/libsdl-org/SDL/issues/2866
2023-01-09 15:46:21 -08:00
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sylvain 93e2903ac5 Add SDL_PlayAudioDevice() to play audio. Remove pause_on param from SDL_PauseAudioDevice() 2023-01-06 09:15:39 -08:00
Sylvain 2d7f8d7d51 Remove legacy SDL_Audio functions that acts on device id == 1 2023-01-05 09:40:06 -05:00
Sylvain Becker d7d3c22dbf
Remove more reserved identifiers (#6925) 2022-12-29 13:58:16 -08:00
Sam Lantinga 66351fd4ba Replace tri-state functions SDL_EventState(), SDL_GetJoystickEventState(), SDL_GetGamepadEventState(), SDL_ShowCursor()
`SDL_QUERY`, `SDL_IGNORE`, `SDL_ENABLE`, and `SDL_DISABLE` have been removed.

SDL_EventState() has been replaced with SDL_SetEventEnabled()
SDL_GetEventState() has been replaced with SDL_EventEnabled()
SDL_GameControllerEventState has been replaced with SDL_SetGamepadEventsEnabled() and SDL_GamepadEventsEnabled()
SDL_JoystickEventState has been replaced with SDL_SetJoystickEventsEnabled() and SDL_JoystickEventsEnabled()

SDL_ShowCursor() has been split into three functions: SDL_ShowCursor(), SDL_HideCursor(), and SDL_CursorVisible()

Fixes https://github.com/libsdl-org/SDL/issues/6929
2022-12-28 17:49:34 -08:00
Sam Lantinga 36d4395c97 SDL API renaming: internal functions 2022-12-27 15:05:51 -08:00
Sylvain Becker 07808d6a03
Remove underscore in guard header defines (#6922) 2022-12-27 12:31:12 -08:00
Sam Lantinga 701e965235 Removed leading underscore in structure names
Fixes https://github.com/libsdl-org/SDL/issues/6856
Closes https://github.com/libsdl-org/SDL/pull/6914
Closes https://github.com/libsdl-org/SDL/pull/6915
Closes https://github.com/libsdl-org/SDL/pull/6916
Closes https://github.com/libsdl-org/SDL/pull/6917
Closes https://github.com/libsdl-org/SDL/pull/6918
Closes https://github.com/libsdl-org/SDL/pull/6919
2022-12-27 10:35:53 -08:00
Sam Lantinga 713ba2e31a SDL API renaming: SDL_audio.h
Fixes https://github.com/libsdl-org/SDL/issues/6879
2022-12-27 05:32:55 -08:00
Sylvain Becker 47170d288e
Don't export SDL_AudioInit/Quit, use SDL_InitSubsystem instead (#6912)
* Don't export SDL_AudioInit/Quit, use SDL_InitSubsystem instead

* Update README

Co-authored-by: Sam Lantinga <slouken@libsdl.org>
2022-12-27 05:22:22 -08:00
Sylvain 3fb0c8b54a Remove/Rename SDL_FreeWAV() to SDL_free() 2022-12-27 05:14:52 -08:00
Sam Lantinga 63724c113b Removed the vi format comments from the source
Vim users can use the [editorconfig plugin](https://github.com/editorconfig/editorconfig-vim) to automatically set tab spacing for the SDL coding style.

Fixes https://github.com/libsdl-org/SDL/issues/6903
2022-12-26 11:17:23 -08:00
meyraud705 126c60cb45 Add "SDL_" prefix to RW_SEEK macros 2022-12-23 09:25:37 -08:00
Sylvain Becker 186687bda9
Android: make Detect devices common between aaudio and android driver. (#6828)
remove VLA, dynamic alloc, check max length get using GetIntArrayRegion
2022-12-18 12:07:38 +01:00
Maido abf5cc5203
Android audio device selection (#6824)
Make it possible to select a specific audio device for Android
2022-12-16 16:40:02 +01:00
Daniel Gibson 63d3fb469d Move src/main/haiku/ to src/core/
turns out that this wasn't even built as a static libSDLmain,
but as part of the (possibly dynamic) libSDL3
2022-12-15 08:01:01 -08:00
Ryan C. Gordon c637031294
rwops: Fixed another Windows build failure. 2022-12-15 00:16:02 -05:00
Ryan C. Gordon 72c1f73bc5
rwops: Make read and write work like POSIX, not stdio.
This simplifies some things, clarifies some things, and also allows
for the possibility of RWops that offer non-blocking i/o (although
none of the current built-in ones do, intentionally, we could add this
later if we choose, or people could provide things like network socket
RWops implementations now, etc.

Fixes #6729.
2022-12-14 15:47:13 -05:00
Sam Lantinga 5c29b58e95 Added support for clang thread-safety analysis
The annotations have been added to SDL_mutex.h and have been made public so applications can enable this for their own code.

Clang assumes that locking and unlocking can't fail, but SDL has the concept of a NULL mutex, so the mutex functions have been changed not to report errors if a mutex hasn't been initialized. We do have mutexes that might be accessed when they are NULL, notably in the event system, so this is an important change.

This commit cleans up a bunch of rare race conditions in the joystick and game controller code so now everything should be completely protected by the joystick lock.

To test this, change the compiler to "clang -Wthread-safety -Werror=thread-safety -DSDL_THREAD_SAFETY_ANALYSIS"
2022-12-14 09:53:39 -08:00
Ryan C. Gordon 12486e144b
wasapi: Fixed incorrect assertions.
Fixes #6795.
2022-12-12 16:07:48 -05:00
Sylvain c265fb74b0 Renamed AUDIODRIVER and VIDEODRIVER hint/env to AUDIO_DRIVER and VIDEO_DRIVER 2022-12-08 09:50:09 -05:00
Sylvain af5bda5ef3 Fix warnings 'macro argument should be enclosed in parentheses' 2022-12-05 09:06:44 -08:00
Ozkan Sezer d6327a00fb re-applied the SDL_NewAudioStream deconstification, including to its definition
we should keep this to SDL3 only.
2022-12-04 20:50:20 +03:00
Cameron Cawley ee0e9e979c Move intrinsic includes into a private header 2022-12-04 09:34:10 -08:00
Sam Lantinga 0a3262e819 Pass the OS event timestamp for keyboard, mouse, and touch events where possible
Currently implemented for Windows and Apple platforms
2022-12-02 12:37:41 -08:00
Sam Lantinga 8121bbd083 Convert ticks to 64-bit, added nanosecond precision to the API
Fixes https://github.com/libsdl-org/SDL/issues/5512
Fixes https://github.com/libsdl-org/SDL/issues/6731
2022-12-02 12:37:41 -08:00
Frank Praznik 378b1c286a Fix formatting on Wayland and Pipewire function signatures
Fixes the formatting on some function signatures that clang-format missed.
2022-12-01 15:13:28 -08:00
Pierre Wendling 3c501b963d
Clang-Tidy fixes (#6725) 2022-12-01 13:07:03 -08:00
Sam Lantinga 5750bcb174
Update for SDL3 coding style (#6717)
I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base.

In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted.

The script I ran for the src directory is added as build-scripts/clang-format-src.sh

This fixes:
#6592
#6593
#6594
2022-11-30 12:51:59 -08:00
Sam Lantinga c5790359fd
Added precompiled header support for Visual Studio and Xcode (#6710)
Fixes https://github.com/libsdl-org/SDL/issues/6704
2022-11-29 18:34:15 -08:00
Markus Mittendrein f3c466ec1e
SDL_ResampleAudio: Fix float accumulation error
While 78f97108f9 reduced the accumulation error, it was still big enough to cause distortions.
Fixes #6196.

(cherry picked from commit 8145212103)
2022-11-27 21:15:44 -05:00
Sylvain Becker 6a2200823c
Cleanup add brace (#6545)
* Add braces after if conditions

* More add braces after if conditions

* Add braces after while() conditions

* Fix compilation because of macro being modified

* Add braces to for loop

* Add braces after if/goto

* Move comments up

* Remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements

* More remove extra () in the 'return ...;' statements after merge

* Fix inconsistent patterns are xxx == NULL vs !xxx

* More "{}" for "if() break;"  and "if() continue;"

* More "{}" after if() short statement

* More "{}" after "if () return;" statement

* More fix inconsistent patterns are xxx == NULL vs !xxx

* Revert some modificaion on SDL_RLEaccel.c

* SDL_RLEaccel: no short statement

* Cleanup 'if' where the bracket is in a new line

* Cleanup 'while' where the bracket is in a new line

* Cleanup 'for' where the bracket is in a new line

* Cleanup 'else' where the bracket is in a new line
2022-11-27 08:38:43 -08:00
Sam Lantinga 0a48abc860 Switch header convention from #include "SDL.h" to #include <SDL3/SDLh>
I ran this script in the include directory:
```sh
sed -i '' -e 's,#include "\(SDL.*\)",#include <SDL3/\1>,' *.h
```

I ran this script in the src directory:
```sh
for i in ../include/SDL3/SDL*.h
do hdr=$(basename $i)
   if [ x"$(echo $hdr | egrep 'SDL_main|SDL_name|SDL_test|SDL_syswm|SDL_opengl|SDL_egl|SDL_vulkan')" != x ]; then
        find . -type f -exec sed -i '' -e 's,#include "\('$hdr'\)",#include <SDL3/\1>,' {} \;
    else
        find . -type f -exec sed -i '' -e '/#include "'$hdr'"/d' {} \;
    fi
done
```

Fixes https://github.com/libsdl-org/SDL/issues/6575
2022-11-26 22:15:18 -08:00
Sam Lantinga cc1f9eb983 Use Apple's nomenclature for macOS and iOS
Fixes https://github.com/libsdl-org/SDL/issues/6621
2022-11-25 16:00:06 -08:00