Commit graph

21 commits

Author SHA1 Message Date
Sam Lantinga fde78d12f2 Updated copyright for 2023 2023-01-09 09:41:41 -08:00
Sylvain Becker d7d3c22dbf
Remove more reserved identifiers (#6925) 2022-12-29 13:58:16 -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
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
Sam Lantinga 120c76c84b Updated copyright for 2022 2022-01-03 09:40:21 -08:00
Sam Lantinga bf97c5a22f Make sure SDL file descriptors don't leak into child processes 2021-09-08 14:47:40 -07:00
Jessica Clarke 8f38ba4d68 Fix casts that should be using uintptr_t
This is needed to support CHERI, and thus Arm's experimental Morello
prototype, where pointers are implemented using unforgeable capabilities
that include bounds and permissions metadata to provide fine-grained
spatial and referential memory safety, as well as revocation by sweeping
memory to provide heap temporal memory safety.

On most systems (anything with a flat memory hierarchy rather than using
segment-based addressing), size_t and uintptr_t are the same type.
However, on CHERI, size_t is just an integer offset, whereas uintptr_t
is still a capability as described above. Casting a pointer to size_t
will strip the metadata and validity tag, and casting from size_t to a
pointer will result in a null-derived capability whose validity tag is
not set, and thus cannot be dereferenced without faulting.

The audio and cursor casts were harmless as they intend to stuff an
integer into a pointer, but using uintptr_t is the idiomatic way to do
that and silences our compiler warnings (which our build tool makes
fatal by default as they often indicate real problems). The iconv and
egl casts were true positives as SDL_iconv_t and iconv_t are pointer
types, as is NativeDisplayType on most OSes, so this would have trapped
at run time when using the round-tripped pointers. The gles2 casts were
also harmless; the OpenGL API defines this argument to be a pointer type
(and uses the argument name "pointer"), but it in fact represents an
integer offset, so like audio and cursor the additional idiomatic cast
is needed to silence the warning.
2021-07-29 14:42:15 -07:00
Ethan Lee 67e8522d31 Add SDL_GetAudioDeviceSpec.
This API is supported by pipewire, pulseaudio, coreaudio, wasapi, and disk.
2021-03-05 12:03:07 -08:00
Sam Lantinga 9130f7c377 Updated copyright for 2021 2021-01-02 10:25:38 -08:00
Sam Lantinga a8780c6a28 Updated copyright date for 2020 2020-01-16 20:49:25 -08:00
Sam Lantinga 5e13087b0f Updated copyright for 2019 2019-01-04 22:01:14 -08:00
Sam Lantinga e3cc5b2c6b Updated copyright for 2018 2018-01-03 10:03:25 -08:00
Ryan C. Gordon a7fc2822d4 audio: rename bsd target to netbsd.
Apparently this is no longer a generic BSD audio target, and hasn't been for
years, so rename it for NetBSD.
2017-05-24 19:56:59 -04:00
Sam Lantinga 45b774e3f7 Updated copyright for 2017 2017-01-01 18:33:28 -08:00
Sam Lantinga 302a6e62aa Fixed bug 3484 - DSP driver does not detect /dev/dsp0
Tobias Kortkamp

using SDL 2.0.5 (and a repository checkout) on FreeBSD 11.0 I get this output
from testaudioinfo with SDL_AUDIODRIVER=dsp:

INFO: Found 8 output devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp1
INFO:   2: /dev/dsp2
INFO:   3: /dev/dsp3
INFO:   4: /dev/dsp4
INFO:   5: /dev/dsp5
INFO:   6: /dev/dsp6
INFO:   7: /dev/dsp7
INFO:
INFO: Found 3 capture devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp4
INFO:   2: /dev/dsp5
INFO:

This is /dev/sndstat:

Installed devices:
pcm0: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm1: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm2: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm3: <NVIDIA (0x0040) (HDMI/DP 8ch)> (play)
pcm4: <Realtek ALC887 (Rear Analog 7.1/2.0)> (play/rec)
pcm5: <Realtek ALC887 (Front Analog)> (play/rec) default
pcm6: <Realtek ALC887 (Rear Digital)> (play)
pcm7: <Realtek ALC887 (Onboard Digital)> (play)
No devices installed from userspace.

I'd expect to find /dev/dsp0 in the output device list.  It's not detected
because of a a small logic error in SDL_audiodev.c (see attached patch).

With the patch applied I get this which is what I'd expect:

INFO: Found 9 output devices:
INFO:   0: /dev/dsp
INFO:   1: /dev/dsp0
INFO:   2: /dev/dsp1
INFO:   3: /dev/dsp2
INFO:   4: /dev/dsp3
INFO:   5: /dev/dsp4
INFO:   6: /dev/dsp5
INFO:   7: /dev/dsp6
INFO:   8: /dev/dsp7
2016-11-11 12:41:06 -08:00
Sam Lantinga 42065e785d Updated copyright to 2016 2016-01-02 10:10:34 -08:00
Philipp Wiesemann 0e45984fa0 Fixed crash if initialization of EGL failed but was tried again later.
The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly
uninitialized data structure if loading the library first failed. A later try to
use EGL then skipped initialization and assumed it was previously successful
because the data structure now already existed. This led to at least one crash
in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was
dereferenced to make a call to eglBindAPI().
2015-06-21 17:33:46 +02:00