Commit graph

156 commits

Author SHA1 Message Date
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
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
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
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
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
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
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
Sylvain c265fb74b0 Renamed AUDIODRIVER and VIDEODRIVER hint/env to AUDIO_DRIVER and VIDEO_DRIVER 2022-12-08 09:50:09 -05: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
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
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
Ozkan Sezer 016b757311 reverted jack audio backend removal. 2022-11-23 06:50:20 +03:00
Ozkan Sezer 7df102d220 reverted sndio backend removal. 2022-11-22 22:04:10 +03:00
Ozkan Sezer 5cedc2f1ff removed QNX support. 2022-11-22 20:23:40 +03:00
Ozkan Sezer e89a1f9157 removed NaCL support. 2022-11-22 20:10:47 +03:00
Ozkan Sezer cdb54ad21e removed arts, esd, fusionsound, nas, paudio, sndio, sunaudio, winmm audio backends. 2022-11-22 19:51:56 +03:00
Ozkan Sezer 8d6fda4810 removed os2 support & support for building SDL with watcom. 2022-11-22 19:18:47 +03:00
Daniel Bomar 22461383c6 SDL_audiocvt: Respct the SDL_HINT_AUDIO_RESAMPLING_MODE hint
This implements using libsamplerate for the SDL_AudioCVT API.
This library was already being used for audio streams when this hint is
set.
2022-10-15 14:31:00 -07:00
Pierre Wendling 655275378d N3DS port (squashed)
A dedicated renderer using Citro3D would likely allow for better
much better graphical performances.
2022-10-10 08:50:59 -07:00
Nicolas Cian 484d5fd6cf audio open: ensure 2 devices don't get the same id 2022-10-07 06:45:01 -07:00
Ryan C. Gordon 8ff738f234
audio: Report SDL_AUDIODEVICEREMOVED for unopened devices.
Unopened devices, if removed, now send SDL_AUDIODEVICEREMOVED events with
a `which` field set to zero. Apps can use this to decide if they need to
refresh a list of devices being shown in an options menu, etc.

It's safe to call SDL_CloseAudioDevice(0), so even if they try to clean
up this bogus id, it should be safe.

Fixes #5199.
2022-07-26 12:40:47 -04:00
Ethan Lee f3008e4aab
audio: 3- and 5-channel formats are now supported 2022-07-20 19:08:31 -04:00
Sam Lantinga b299cb3d3c Added a utility function to calculate the next power of 2 for a value 2022-07-17 08:31:16 -07:00
Ethan Lee 90b86b132a audio: Handle non-power-of-two spec.samples when unsupported
Fixes #3685
2022-07-17 10:36:15 -04:00
Ethan Lee 2f0816adb7 Add SDL_GetDefaultAudioInfo.
This API is supported on pipewire, pulseaudio, wasapi, and directsound.

Co-authored-by: Frank Praznik <frank.praznik@gmail.com>
2022-07-11 13:34:35 -04:00
Francisco Javier Trujillo Mata e4a8087551 Initial Audio driver 2022-06-27 15:18:48 -07:00
Sam Lantinga abe38bca3e Support SDL_AUDIODRIVER set to "dsound", which was used by SDL 1.2
Fixes https://github.com/libsdl-org/SDL/issues/5818
2022-06-18 13:08:58 -07:00
Sam Lantinga adc6875870 Added SDL_copyp to avoid size mismatch when copying values (thanks @1bsyl!)
Closes https://github.com/libsdl-org/SDL/pull/5811
2022-06-17 10:22:28 -07:00
Ryan C. Gordon de019568dc audio: Prebake the resampler's kaiser table instead of doing it at runtime. 2022-04-26 13:32:42 -04:00
Ryan C. Gordon c1336b21ed hints: Make SDL_VIDEODRIVER and SDL_AUDIODRIVER formal hints.
They were just environment variables before.

Fixes #5528.
2022-04-17 11:31:55 -07:00
pionere a70bb259c7 drop handle parameter of OpenDevice 2022-01-28 20:40:19 -05:00
pionere 3939ef72f8 cleanup SDL_GetAudioDeviceSpec
- drop unnecessary hascapture check
- call SDL_InvalidParamError and return -1 in case the index is out of range
- do not zfill SDL_AudioSpec
- adjust documentation to reflect the behavior
2022-01-28 20:40:19 -05:00
pionere 113109f839 cleanup SDL_GetAudioDeviceName
- drop unnecessary hascapture check
- call SDL_InvalidParamError in case the index is out of range
2022-01-28 20:40:19 -05:00
pionere c9e8d1573a re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory II. 2022-01-28 20:40:19 -05:00
pionere 1043dd8c0d adjust handling of iscapture
- drop iscapture parameter of OpenDevice
- use SDL_bool for iscapture
2022-01-28 20:40:19 -05:00
pionere 60deadba59 re-use return value of SDL_SetError/WIN_SetErrorFromHRESULT/SDL_OutOfMemory 2022-01-28 20:40:19 -05:00
pionere 4a17612bff get rid of BeginLoopIteration 2022-01-28 20:40:19 -05:00
pionere 0770c5829c get rid of PrepareToClose 2022-01-28 20:40:19 -05:00
Ryan C. Gordon e0236c02ce audio: Removed an unnecessary commented-out line. 2022-01-28 20:40:19 -05:00
pionere 0dda8a7f4c cleanup init functions of audio
- use SDL_bool if possible
- assume NULL/SDL_FALSE filled impl
- skip zfill of current_audio at the beginning of SDL_AudioInit (done before the init() calls)
2022-01-28 20:40:19 -05:00
pionere 6fcfcc3d6f get rid of SkipMixerLock 2022-01-28 20:40:19 -05:00
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sylvain 38cfe25bc5 Remove 'malloc' from comment 2021-11-22 08:38:46 -08:00