Compare commits
82
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ac13ca9ab6 | ||
|
|
3fae4c5c83 | ||
|
|
67100be3cf | ||
|
|
4fb81fdff9 | ||
|
|
d94b944f91 | ||
|
|
384144d632 | ||
|
|
f84428ca01 | ||
|
|
086322076a | ||
|
|
24098b75b1 | ||
|
|
519384d3b6 | ||
|
|
b01194345f | ||
|
|
848cf421c9 | ||
|
|
1545b233a6 | ||
|
|
46a3a8e88f | ||
|
|
d8cb962f9f | ||
|
|
d4a9201b52 | ||
|
|
1f514f5e3e | ||
|
|
1f5c590806 | ||
|
|
fb1a01a3dd | ||
|
|
106c0e6328 | ||
|
|
1fd1f7d565 | ||
|
|
90e2e62691 | ||
|
|
3e5497777e | ||
|
|
3cbd8823ba | ||
|
|
2fe5f3239c | ||
|
|
20e17559e5 | ||
|
|
ae5fdc0b00 | ||
|
|
45167b9d13 | ||
|
|
596a594714 | ||
|
|
69875ad80f | ||
|
|
54ca4d3879 | ||
|
|
1723e93a0c | ||
|
|
07d0f51fa2 | ||
|
|
cbc2b014b6 | ||
|
|
fa9f7c70c5 | ||
|
|
dc34e96fff | ||
|
|
6edc0100e1 | ||
|
|
9b061c04e7 | ||
|
|
718a880f91 | ||
|
|
853ee9a3e6 | ||
|
|
adf31f6ec0 | ||
|
|
20c2fa18fe | ||
|
|
4f94da5c53 | ||
|
|
c816300615 | ||
|
|
ce67788629 | ||
|
|
05b03032f1 | ||
|
|
c49d02cd13 | ||
|
|
e312fbb37d | ||
|
|
3c72e2de4d | ||
|
|
8e31fc4130 | ||
|
|
75834df37c | ||
|
|
f070c83a60 | ||
|
|
d992d4f23e | ||
|
|
81975cc2d0 | ||
|
|
278c78e34c | ||
|
|
2462262e0c | ||
|
|
162f8e6ee7 | ||
|
|
d0f8e63ed6 | ||
|
|
690e2f21f2 | ||
|
|
52176e25e1 | ||
|
|
40698ee33c | ||
|
|
6b5610752b | ||
|
|
2d86b4ef76 | ||
|
|
f17058b562 | ||
|
|
2879f2aeba | ||
|
|
45c7d838d4 | ||
|
|
79373c5a5c | ||
|
|
f4080637c4 | ||
|
|
92057e683e | ||
|
|
5edd6846db | ||
|
|
859cb13ef8 | ||
|
|
b97d2ed6c5 | ||
|
|
c76a31341c | ||
|
|
00731eb011 | ||
|
|
bf70a37606 | ||
|
|
da1bddd27c | ||
|
|
9925ee52d7 | ||
|
|
66620bd108 | ||
|
|
72823dd0cd | ||
|
|
479e972e56 | ||
|
|
3bf150e900 | ||
|
|
a8dd7a10fa |
No files matched your search
+4
-5
@@ -16,8 +16,8 @@ AllowShortFunctionsOnASingleLine: All
|
|||||||
AllowShortIfStatementsOnASingleLine: Never
|
AllowShortIfStatementsOnASingleLine: Never
|
||||||
AllowShortLoopsOnASingleLine: false
|
AllowShortLoopsOnASingleLine: false
|
||||||
|
|
||||||
AlwaysBreakAfterDefinitionReturnType: None
|
AlwaysBreakAfterDefinitionReturnType: All
|
||||||
AlwaysBreakAfterReturnType: None
|
AlwaysBreakAfterReturnType: AllDefinitions
|
||||||
AlwaysBreakBeforeMultilineStrings: false
|
AlwaysBreakBeforeMultilineStrings: false
|
||||||
AlwaysBreakTemplateDeclarations: MultiLine
|
AlwaysBreakTemplateDeclarations: MultiLine
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ BraceWrapping:
|
|||||||
AfterUnion: true
|
AfterUnion: true
|
||||||
AfterExternBlock: false
|
AfterExternBlock: false
|
||||||
BeforeElse: false
|
BeforeElse: false
|
||||||
BeforeWhile: false
|
BeforeWhile: true
|
||||||
IndentBraces: false
|
IndentBraces: false
|
||||||
SplitEmptyFunction: true
|
SplitEmptyFunction: true
|
||||||
SplitEmptyRecord: true
|
SplitEmptyRecord: true
|
||||||
@@ -62,8 +62,7 @@ IndentGotoLabels: true
|
|||||||
IndentPPDirectives: None
|
IndentPPDirectives: None
|
||||||
IndentExternBlock: NoIndent
|
IndentExternBlock: NoIndent
|
||||||
|
|
||||||
PointerAlignment: Right
|
SpaceAfterCStyleCast: true
|
||||||
SpaceAfterCStyleCast: false
|
|
||||||
SpacesInCStyleCastParentheses: false
|
SpacesInCStyleCastParentheses: false
|
||||||
SpacesInConditionalStatement: false
|
SpacesInConditionalStatement: false
|
||||||
SpacesInContainerLiterals: true
|
SpacesInContainerLiterals: true
|
||||||
|
|||||||
@@ -7,8 +7,6 @@ root = true
|
|||||||
[*.{c,cg,cpp,gradle,h,java,m,metal,pl,py,S,sh,txt}]
|
[*.{c,cg,cpp,gradle,h,java,m,metal,pl,py,S,sh,txt}]
|
||||||
indent_size = 4
|
indent_size = 4
|
||||||
indent_style = space
|
indent_style = space
|
||||||
insert_final_newline = true
|
|
||||||
trim_trailing_whitespace = true
|
|
||||||
|
|
||||||
[*.{html,js,json,m4,yml,yaml,vcxproj,vcxproj.filters}]
|
[*.{html,js,json,m4,yml,yaml,vcxproj,vcxproj.filters}]
|
||||||
indent_size = 2
|
indent_size = 2
|
||||||
|
|||||||
@@ -1,16 +0,0 @@
|
|||||||
cmake_minimum_required(VERSION 3.0)
|
|
||||||
project(ci_utils C CXX)
|
|
||||||
|
|
||||||
set(txt "CC=${CMAKE_C_COMPILER}
|
|
||||||
CXX=${CMAKE_CXX_COMPILER}
|
|
||||||
CFLAGS=${CMAKE_C_FLAGS}
|
|
||||||
CXXFLAGS=${CMAKE_CXX_FLAGS}
|
|
||||||
LDFLAGS=${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_C_STANDARD_LIBRARIES}
|
|
||||||
")
|
|
||||||
|
|
||||||
message("${txt}")
|
|
||||||
|
|
||||||
set(VAR_PATH "/tmp/env.txt" CACHE PATH "Where to write environment file")
|
|
||||||
message(STATUS "Writing CC/CXX/CFLAGS/CXXFLAGS/LDFLAGS environment to ${VAR_PATH}")
|
|
||||||
|
|
||||||
file(WRITE "${VAR_PATH}" "${txt}")
|
|
||||||
@@ -22,11 +22,6 @@ jobs:
|
|||||||
- { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64 }
|
- { name: Windows (ucrt64), os: windows-latest, shell: 'msys2 {0}', msystem: ucrt64, msys-env: mingw-w64-ucrt-x86_64 }
|
||||||
- { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh }
|
- { name: Ubuntu 20.04 (CMake), os: ubuntu-20.04, shell: sh }
|
||||||
- { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
|
- { name: Ubuntu 20.04 (autotools), os: ubuntu-20.04, shell: sh, autotools: true }
|
||||||
- { name: Intel oneAPI (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-oneapi', intel: true,
|
|
||||||
source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icx; export CXX=icx;'}
|
|
||||||
- { name: Intel Compiler (Ubuntu 20.04), os: ubuntu-20.04, shell: bash, artifact: 'SDL-ubuntu20.04-icc', intel: true, cmake: '-DSDL_CLANG_TIDY=OFF',
|
|
||||||
source_cmd: 'source /opt/intel/oneapi/setvars.sh; export CC=icc; export CXX=icpc; export CFLAGS=-diag-disable=10441; export CXXFLAGS=-diag-disable=10441; '}
|
|
||||||
|
|
||||||
- { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
|
- { name: Ubuntu 22.04 (CMake), os: ubuntu-22.04, shell: sh }
|
||||||
- { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
|
- { name: Ubuntu 22.04 (autotools), os: ubuntu-22.04, shell: sh, autotools: true }
|
||||||
- { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
|
- { name: MacOS (CMake), os: macos-latest, shell: sh, cmake: '-DCMAKE_OSX_ARCHITECTURES="x86_64;arm64"' }
|
||||||
@@ -66,19 +61,6 @@ jobs:
|
|||||||
brew install \
|
brew install \
|
||||||
ninja \
|
ninja \
|
||||||
pkg-config
|
pkg-config
|
||||||
|
|
||||||
- name: Setup Intel oneAPI
|
|
||||||
if: matrix.platform.intel
|
|
||||||
run: |
|
|
||||||
# Setup oneAPI repo
|
|
||||||
wget https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
|
||||||
sudo apt-key add GPG-PUB-KEY-INTEL-SW-PRODUCTS-2023.PUB
|
|
||||||
sudo echo "deb https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
|
|
||||||
sudo apt-get update -y
|
|
||||||
|
|
||||||
# Install oneAPI
|
|
||||||
sudo apt-get install -y intel-oneapi-compiler-dpcpp-cpp-and-cpp-classic
|
|
||||||
|
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Check that versioning is consistent
|
- name: Check that versioning is consistent
|
||||||
# We only need to run this once: arbitrarily use the Linux/CMake build
|
# We only need to run this once: arbitrarily use the Linux/CMake build
|
||||||
@@ -87,7 +69,6 @@ jobs:
|
|||||||
- name: Configure (CMake)
|
- name: Configure (CMake)
|
||||||
if: "! matrix.platform.autotools"
|
if: "! matrix.platform.autotools"
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
cmake -S . -B build -G Ninja \
|
cmake -S . -B build -G Ninja \
|
||||||
-DSDL_TESTS=ON \
|
-DSDL_TESTS=ON \
|
||||||
-DSDL_WERROR=ON \
|
-DSDL_WERROR=ON \
|
||||||
@@ -99,13 +80,11 @@ jobs:
|
|||||||
- name: Build (CMake)
|
- name: Build (CMake)
|
||||||
if: "! matrix.platform.autotools"
|
if: "! matrix.platform.autotools"
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
cmake --build build/ --config Release --verbose --parallel
|
cmake --build build/ --config Release --verbose --parallel
|
||||||
- name: Run build-time tests (CMake)
|
- name: Run build-time tests (CMake)
|
||||||
if: "! matrix.platform.autotools"
|
if: "! matrix.platform.autotools"
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
export SDL_TESTS_QUICK=1
|
export SDL_TESTS_QUICK=1
|
||||||
ctest -VV --test-dir build/
|
ctest -VV --test-dir build/
|
||||||
if test "${{ runner.os }}" = "Linux"; then
|
if test "${{ runner.os }}" = "Linux"; then
|
||||||
@@ -123,7 +102,6 @@ jobs:
|
|||||||
if: matrix.platform.autotools
|
if: matrix.platform.autotools
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
rm -fr build-autotools
|
rm -fr build-autotools
|
||||||
mkdir build-autotools
|
mkdir build-autotools
|
||||||
./autogen.sh
|
./autogen.sh
|
||||||
@@ -155,7 +133,6 @@ jobs:
|
|||||||
if: matrix.platform.autotools
|
if: matrix.platform.autotools
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
parallel="$(getconf _NPROCESSORS_ONLN)"
|
parallel="$(getconf _NPROCESSORS_ONLN)"
|
||||||
make -j"${parallel}" -C build-autotools V=1
|
make -j"${parallel}" -C build-autotools V=1
|
||||||
if test "${{ runner.os }}" != "macOS" ; then
|
if test "${{ runner.os }}" != "macOS" ; then
|
||||||
@@ -165,7 +142,6 @@ jobs:
|
|||||||
if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
|
if: ${{ matrix.platform.autotools && (runner.os != 'macOS') }}
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
curdir="$(pwd)"
|
curdir="$(pwd)"
|
||||||
parallel="$(getconf _NPROCESSORS_ONLN)"
|
parallel="$(getconf _NPROCESSORS_ONLN)"
|
||||||
export SDL_TESTS_QUICK=1
|
export SDL_TESTS_QUICK=1
|
||||||
@@ -178,7 +154,6 @@ jobs:
|
|||||||
if: matrix.platform.autotools
|
if: matrix.platform.autotools
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
curdir="$(pwd)"
|
curdir="$(pwd)"
|
||||||
parallel="$(getconf _NPROCESSORS_ONLN)"
|
parallel="$(getconf _NPROCESSORS_ONLN)"
|
||||||
make -j"${parallel}" -C build-autotools install V=1
|
make -j"${parallel}" -C build-autotools install V=1
|
||||||
@@ -189,19 +164,16 @@ jobs:
|
|||||||
echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
|
echo "SDL2_DIR=$(pwd)/autotools_prefix" >> $GITHUB_ENV
|
||||||
- name: Verify CMake configuration files
|
- name: Verify CMake configuration files
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
cmake -S cmake/test -B cmake_config_build -G Ninja \
|
cmake -S cmake/test -B cmake_config_build -G Ninja \
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
-DCMAKE_BUILD_TYPE=Release \
|
||||||
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
|
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }}
|
||||||
cmake --build cmake_config_build --verbose
|
cmake --build cmake_config_build --verbose
|
||||||
- name: Verify sdl2-config
|
- name: Verify sdl2-config
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
||||||
cmake/test/test_sdlconfig.sh
|
cmake/test/test_sdlconfig.sh
|
||||||
- name: Verify sdl2.pc
|
- name: Verify sdl2.pc
|
||||||
run: |
|
run: |
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
||||||
cmake/test/test_pkgconfig.sh
|
cmake/test/test_pkgconfig.sh
|
||||||
- name: Distcheck (Autotools)
|
- name: Distcheck (Autotools)
|
||||||
@@ -220,7 +192,6 @@ jobs:
|
|||||||
if: "runner.os == 'Linux' && matrix.platform.autotools"
|
if: "runner.os == 'Linux' && matrix.platform.autotools"
|
||||||
run: |
|
run: |
|
||||||
set -eu
|
set -eu
|
||||||
${{ matrix.platform.source_cmd }}
|
|
||||||
parallel="$(getconf _NPROCESSORS_ONLN)"
|
parallel="$(getconf _NPROCESSORS_ONLN)"
|
||||||
sudo make -j"${parallel}" -C build-autotools install
|
sudo make -j"${parallel}" -C build-autotools install
|
||||||
sudo make -j"${parallel}" -C build-autotools/test install
|
sudo make -j"${parallel}" -C build-autotools/test install
|
||||||
|
|||||||
@@ -38,18 +38,5 @@ jobs:
|
|||||||
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
|
-DCMAKE_PREFIX_PATH=${{ env.SDL2_DIR }} \
|
||||||
-DCMAKE_BUILD_TYPE=Release
|
-DCMAKE_BUILD_TYPE=Release
|
||||||
cmake --build cmake_config_build --verbose
|
cmake --build cmake_config_build --verbose
|
||||||
- name: Extract CC/CXX/CFLAGS/CXXFLAGS from CMake toolchain
|
# Not running test_pkgconfig.sh and test_sdlconfig.sh
|
||||||
run: |
|
# as invoking the compiler manually is not supported
|
||||||
cmake -S .github/cmake -B /tmp/cmake_extract \
|
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${DEVKITPRO}/cmake/3DS.cmake \
|
|
||||||
-DCMAKE_BUILD_TYPE=Release \
|
|
||||||
-DVAR_PATH=/tmp/n3ds_env.txt
|
|
||||||
cat /tmp/n3ds_env.txt >> $GITHUB_ENV
|
|
||||||
- name: Verify sdl2-config
|
|
||||||
run: |
|
|
||||||
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
|
||||||
cmake/test/test_sdlconfig.sh
|
|
||||||
- name: Verify sdl2.pc
|
|
||||||
run: |
|
|
||||||
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
|
||||||
cmake/test/test_pkgconfig.sh
|
|
||||||
@@ -50,13 +50,13 @@ jobs:
|
|||||||
- name: Verify sdl2-config
|
- name: Verify sdl2-config
|
||||||
run: |
|
run: |
|
||||||
export CC=mips64r5900el-ps2-elf-gcc
|
export CC=mips64r5900el-ps2-elf-gcc
|
||||||
export LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
|
|
||||||
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
||||||
|
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
|
||||||
cmake/test/test_sdlconfig.sh
|
cmake/test/test_sdlconfig.sh
|
||||||
- name: Verify sdl2.pc
|
- name: Verify sdl2.pc
|
||||||
run: |
|
run: |
|
||||||
export CC=mips64r5900el-ps2-elf-gcc
|
export CC=mips64r5900el-ps2-elf-gcc
|
||||||
export LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
|
export EXTRA_LDFLAGS="-L$PS2DEV/ps2sdk/ee/lib -L$PS2DEV/gsKit/lib -L$PS2DEV/ps2sdk/ports/lib"
|
||||||
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
||||||
cmake/test/test_pkgconfig.sh
|
cmake/test/test_pkgconfig.sh
|
||||||
|
|
||||||
|
|||||||
@@ -39,12 +39,12 @@ jobs:
|
|||||||
- name: Verify sdl2-config
|
- name: Verify sdl2-config
|
||||||
run: |
|
run: |
|
||||||
export CC=psp-gcc
|
export CC=psp-gcc
|
||||||
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
|
|
||||||
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
export PATH=${{ env.SDL2_DIR }}/bin:$PATH
|
||||||
|
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
|
||||||
cmake/test/test_sdlconfig.sh
|
cmake/test/test_sdlconfig.sh
|
||||||
- name: Verify sdl2.pc
|
- name: Verify sdl2.pc
|
||||||
run: |
|
run: |
|
||||||
export CC=psp-gcc
|
export CC=psp-gcc
|
||||||
export LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
|
|
||||||
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
export PKG_CONFIG_PATH=${{ env.SDL2_DIR }}/lib/pkgconfig
|
||||||
|
export EXTRA_LDFLAGS="-L$PSPDEV/lib -L$PSPDEV/psp/lib -L$PSPDEV/psp/sdk/lib"
|
||||||
cmake/test/test_pkgconfig.sh
|
cmake/test/test_pkgconfig.sh
|
||||||
@@ -8,61 +8,19 @@ defaults:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
vita:
|
vita:
|
||||||
name: ${{ matrix.platform.name }}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: vitasdk/vitasdk:latest
|
image: vitasdk/vitasdk:latest
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
platform:
|
|
||||||
- { name: GLES (pib), os: windows-latest, pib: true }
|
|
||||||
- { name: GLES (PVR_PSP2 + gl4es4vita), os: windows-latest, pvr: true }
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
- name: Install build requirements
|
- name: Install build requirements
|
||||||
run: |
|
run: |
|
||||||
apk update
|
apk update
|
||||||
apk add cmake ninja pkgconf bash
|
apk add cmake ninja pkgconf bash
|
||||||
|
|
||||||
- name: Configure PVR_PSP2 (GLES)
|
|
||||||
if: ${{ !!matrix.platform.pvr }}
|
|
||||||
run: |
|
|
||||||
pvr_psp2_version=3.9
|
|
||||||
|
|
||||||
# Configure PVR_PSP2 headers
|
|
||||||
wget https://github.com/GrapheneCt/PVR_PSP2/archive/refs/tags/v$pvr_psp2_version.zip -P/tmp
|
|
||||||
unzip /tmp/v$pvr_psp2_version.zip -d/tmp
|
|
||||||
cp -r /tmp/PVR_PSP2-$pvr_psp2_version/include/* ${VITASDK}/arm-vita-eabi/include
|
|
||||||
rm /tmp/v$pvr_psp2_version.zip
|
|
||||||
|
|
||||||
# Configure PVR_PSP2 stub libraries
|
|
||||||
wget https://github.com/GrapheneCt/PVR_PSP2/releases/download/v$pvr_psp2_version/vitasdk_stubs.zip -P/tmp
|
|
||||||
unzip /tmp/vitasdk_stubs.zip -d/tmp/pvr_psp2_stubs
|
|
||||||
find /tmp/pvr_psp2_stubs -type f -name "*.a" -exec cp {} ${VITASDK}/arm-vita-eabi/lib \;
|
|
||||||
rm /tmp/vitasdk_stubs.zip
|
|
||||||
rm -rf /tmp/pvr_psp2_stubs
|
|
||||||
|
|
||||||
- name: Configure gl4es4vita (OpenGL)
|
|
||||||
if: ${{ !!matrix.platform.pvr }}
|
|
||||||
run: |
|
|
||||||
gl4es4vita_version=1.1.4
|
|
||||||
|
|
||||||
# Configure gl4es4vita headers
|
|
||||||
wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/include.zip -P/tmp
|
|
||||||
unzip -o /tmp/include.zip -d${VITASDK}/arm-vita-eabi/include
|
|
||||||
rm /tmp/include.zip
|
|
||||||
|
|
||||||
# Configure gl4es4vita stub libraries
|
|
||||||
wget https://github.com/SonicMastr/gl4es4vita/releases/download/v$gl4es4vita_version-vita/vitasdk_stubs.zip -P/tmp
|
|
||||||
unzip /tmp/vitasdk_stubs.zip -d${VITASDK}/arm-vita-eabi/lib
|
|
||||||
|
|
||||||
- name: Configure CMake
|
- name: Configure CMake
|
||||||
run: |
|
run: |
|
||||||
cmake -S . -B build -G Ninja \
|
cmake -S . -B build -G Ninja \
|
||||||
-DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \
|
-DCMAKE_TOOLCHAIN_FILE=${VITASDK}/share/vita.toolchain.cmake \
|
||||||
-DVIDEO_VITA_PIB=${{ !!matrix.platform.pib }} \
|
|
||||||
-DVIDEO_VITA_PVR=${{ !!matrix.platform.pvr }} \
|
|
||||||
-DSDL_WERROR=ON \
|
-DSDL_WERROR=ON \
|
||||||
-DSDL_TESTS=ON \
|
-DSDL_TESTS=ON \
|
||||||
-DSDL_INSTALL_TESTS=ON \
|
-DSDL_INSTALL_TESTS=ON \
|
||||||
|
|||||||
@@ -62,11 +62,6 @@ cmake-build-*
|
|||||||
xcuserdata
|
xcuserdata
|
||||||
*.xcworkspace
|
*.xcworkspace
|
||||||
|
|
||||||
# for QtCreator
|
|
||||||
CMakeLists.txt.user
|
|
||||||
build*/
|
|
||||||
*.pro.user*
|
|
||||||
|
|
||||||
# for Visual C++
|
# for Visual C++
|
||||||
.vs
|
.vs
|
||||||
Debug
|
Debug
|
||||||
@@ -178,7 +173,6 @@ test/testyuv
|
|||||||
test/torturethread
|
test/torturethread
|
||||||
|
|
||||||
builddir/
|
builddir/
|
||||||
!build-scripts/
|
|
||||||
debian/*.debhelper.log
|
debian/*.debhelper.log
|
||||||
debian/*.substvars
|
debian/*.substvars
|
||||||
debian/*.tar.gz
|
debian/*.tar.gz
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
projectfullname = SDL2
|
projectfullname = SDL_mixer
|
||||||
projectshortname = SDL2
|
projectshortname = SDL_mixer
|
||||||
incsubdir = include
|
incsubdir = include
|
||||||
wikisubdir = SDL2
|
wikisubdir =
|
||||||
readmesubdir = docs
|
|
||||||
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
|
apiprefixregex = (SDL_|SDLK_|KMOD_|AUDIO_)
|
||||||
mainincludefname = SDL.h
|
mainincludefname = SDL.h
|
||||||
versionfname = include/SDL_version.h
|
versionfname = include/SDL_version.h
|
||||||
@@ -11,7 +10,6 @@ versionminorregex = \A\#define\s+SDL_MINOR_VERSION\s+(\d+)\Z
|
|||||||
versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z
|
versionpatchregex = \A\#define\s+SDL_PATCHLEVEL\s+(\d+)\Z
|
||||||
selectheaderregex = \ASDL.*?\.h\Z
|
selectheaderregex = \ASDL.*?\.h\Z
|
||||||
projecturl = https://libsdl.org/
|
projecturl = https://libsdl.org/
|
||||||
wikiurl = https://wiki.libsdl.org/SDL2
|
wikiurl = https://wiki.libsdl.org
|
||||||
bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new
|
bugreporturl = https://github.com/libsdl-org/sdlwiki/issues/new
|
||||||
warn_about_missing = 0
|
warn_about_missing = 0
|
||||||
wikipreamble = (This is the legacy documentation for stable SDL2, the current stable version; [SDL3](https://wiki.libsdl.org/SDL3/) is the current development version.)
|
|
||||||
+1
-2
@@ -63,6 +63,7 @@ LOCAL_CFLAGS += -DGL_GLEXT_PROTOTYPES
|
|||||||
LOCAL_CFLAGS += \
|
LOCAL_CFLAGS += \
|
||||||
-Wall -Wextra \
|
-Wall -Wextra \
|
||||||
-Wdocumentation \
|
-Wdocumentation \
|
||||||
|
-Wdocumentation-unknown-command \
|
||||||
-Wmissing-prototypes \
|
-Wmissing-prototypes \
|
||||||
-Wunreachable-code-break \
|
-Wunreachable-code-break \
|
||||||
-Wunneeded-internal-declaration \
|
-Wunneeded-internal-declaration \
|
||||||
@@ -77,8 +78,6 @@ LOCAL_CFLAGS += \
|
|||||||
# Warnings we haven't fixed (yet)
|
# Warnings we haven't fixed (yet)
|
||||||
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
|
LOCAL_CFLAGS += -Wno-unused-parameter -Wno-sign-compare
|
||||||
|
|
||||||
LOCAL_CXXFLAGS += -std=gnu++11
|
|
||||||
|
|
||||||
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
|
LOCAL_LDLIBS := -ldl -lGLESv1_CM -lGLESv2 -lOpenSLES -llog -landroid
|
||||||
|
|
||||||
LOCAL_LDFLAGS := -Wl,--no-undefined
|
LOCAL_LDFLAGS := -Wl,--no-undefined
|
||||||
|
|||||||
+132
-196
@@ -2,7 +2,7 @@ if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
|
|||||||
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
|
message(FATAL_ERROR "Prevented in-tree build. Please create a build directory outside of the SDL source code and run \"cmake -S ${CMAKE_SOURCE_DIR} -B .\" from there")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.0.0...3.5)
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
project(SDL2 C CXX)
|
project(SDL2 C CXX)
|
||||||
|
|
||||||
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
|
||||||
@@ -18,9 +18,6 @@ endif()
|
|||||||
set(EXTRA_LIBS)
|
set(EXTRA_LIBS)
|
||||||
set(EXTRA_LDFLAGS)
|
set(EXTRA_LDFLAGS)
|
||||||
|
|
||||||
set(CMAKE_DEPENDS)
|
|
||||||
set(PKGCONFIG_DEPENDS)
|
|
||||||
|
|
||||||
# This is a virtual "library" that just exists to collect up compiler and
|
# This is a virtual "library" that just exists to collect up compiler and
|
||||||
# linker options that used to be global to this CMake project. When you
|
# linker options that used to be global to this CMake project. When you
|
||||||
# specify it as part of a real library's target_link_libraries(), that
|
# specify it as part of a real library's target_link_libraries(), that
|
||||||
@@ -30,10 +27,16 @@ set(PKGCONFIG_DEPENDS)
|
|||||||
add_library(sdl-build-options INTERFACE)
|
add_library(sdl-build-options INTERFACE)
|
||||||
|
|
||||||
if(WINDOWS_STORE)
|
if(WINDOWS_STORE)
|
||||||
|
cmake_minimum_required(VERSION 3.11.0)
|
||||||
target_compile_definitions(sdl-build-options INTERFACE "-DSDL_BUILDING_WINRT=1")
|
target_compile_definitions(sdl-build-options INTERFACE "-DSDL_BUILDING_WINRT=1")
|
||||||
target_compile_options(sdl-build-options INTERFACE "-ZW")
|
target_compile_options(sdl-build-options INTERFACE "-ZW")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
# Build in parallel under Visual Studio. Not enabled by default.
|
||||||
|
if(MSVC)
|
||||||
|
target_compile_options(sdl-build-options INTERFACE "/MP")
|
||||||
|
endif()
|
||||||
|
|
||||||
# CMake 3.0 expands the "if(${A})" in "set(OFF 1);set(A OFF);if(${A})" to "if(1)"
|
# CMake 3.0 expands the "if(${A})" in "set(OFF 1);set(A OFF);if(${A})" to "if(1)"
|
||||||
# CMake 3.24+ emits a warning when not set.
|
# CMake 3.24+ emits a warning when not set.
|
||||||
unset(OFF)
|
unset(OFF)
|
||||||
@@ -71,7 +74,6 @@ find_package(PkgConfig)
|
|||||||
list(APPEND CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
|
list(APPEND CMAKE_MODULE_PATH "${SDL2_SOURCE_DIR}/cmake")
|
||||||
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
|
include(${SDL2_SOURCE_DIR}/cmake/macros.cmake)
|
||||||
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
|
include(${SDL2_SOURCE_DIR}/cmake/sdlchecks.cmake)
|
||||||
include(${SDL2_SOURCE_DIR}/cmake/sdlplatform.cmake)
|
|
||||||
include(${SDL2_SOURCE_DIR}/cmake/CheckCPUArchitecture.cmake)
|
include(${SDL2_SOURCE_DIR}/cmake/CheckCPUArchitecture.cmake)
|
||||||
|
|
||||||
# Enable large file support on 32-bit glibc, so that we can access files
|
# Enable large file support on 32-bit glibc, so that we can access files
|
||||||
@@ -83,8 +85,8 @@ endif()
|
|||||||
|
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
set(SDL_MAJOR_VERSION 2)
|
set(SDL_MAJOR_VERSION 2)
|
||||||
set(SDL_MINOR_VERSION 27)
|
set(SDL_MINOR_VERSION 26)
|
||||||
set(SDL_MICRO_VERSION 1)
|
set(SDL_MICRO_VERSION 5)
|
||||||
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
set(SDL_VERSION "${SDL_MAJOR_VERSION}.${SDL_MINOR_VERSION}.${SDL_MICRO_VERSION}")
|
||||||
|
|
||||||
# Set defaults preventing destination file conflicts
|
# Set defaults preventing destination file conflicts
|
||||||
@@ -133,12 +135,8 @@ set(SDL_GENERATED_HEADERS)
|
|||||||
|
|
||||||
#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
|
#message(STATUS "${LT_VERSION} :: ${LT_AGE} :: ${LT_REVISION} :: ${LT_CURRENT} :: ${LT_RELEASE}")
|
||||||
|
|
||||||
check_cpu_architecture(x86 SDL_CPU_X86)
|
# General settings & flags
|
||||||
check_cpu_architecture(x64 SDL_CPU_X64)
|
set(LIBRARY_OUTPUT_DIRECTORY "build")
|
||||||
check_cpu_architecture(arm32 SDL_CPU_ARM32)
|
|
||||||
check_cpu_architecture(arm64 SDL_CPU_ARM64)
|
|
||||||
check_cpu_architecture(loongarch64 SDL_CPU_LOONGARCH64)
|
|
||||||
|
|
||||||
# Check for 64 or 32 bit
|
# Check for 64 or 32 bit
|
||||||
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
|
set(SIZEOF_VOIDP ${CMAKE_SIZEOF_VOID_P})
|
||||||
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||||
@@ -154,7 +152,56 @@ if(NOT LIBTYPE)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Get the platform
|
# Get the platform
|
||||||
SDL_DetectCMakePlatform()
|
if(WIN32)
|
||||||
|
if(NOT WINDOWS)
|
||||||
|
set(WINDOWS TRUE)
|
||||||
|
endif()
|
||||||
|
elseif(UNIX AND NOT APPLE)
|
||||||
|
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
|
||||||
|
set(LINUX TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
|
||||||
|
set(FREEBSD TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
|
||||||
|
set(NETBSD TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
|
||||||
|
set(OPENBSD TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
|
||||||
|
set(GNU TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
||||||
|
set(BSDI TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
|
||||||
|
set(FREEBSD TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
|
||||||
|
set(SYSV5 TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
|
||||||
|
set(SOLARIS TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
|
||||||
|
set(HPUX TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
|
||||||
|
set(AIX TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
|
||||||
|
set(MINIX TRUE)
|
||||||
|
endif()
|
||||||
|
elseif(APPLE)
|
||||||
|
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
|
||||||
|
set(DARWIN TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
|
||||||
|
set(MACOSX TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
|
||||||
|
set(TVOS TRUE)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
|
||||||
|
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
|
||||||
|
if(CMAKE_VERSION VERSION_LESS 3.14)
|
||||||
|
set(IOS TRUE)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
|
||||||
|
message_error("BeOS support has been removed as of SDL 2.0.2.")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
|
||||||
|
set(HAIKU TRUE)
|
||||||
|
elseif(NINTENDO_3DS)
|
||||||
|
set(N3DS TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
# Don't mistake osx for unix
|
# Don't mistake osx for unix
|
||||||
if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT RISCOS)
|
if(UNIX AND NOT ANDROID AND NOT APPLE AND NOT RISCOS)
|
||||||
@@ -207,7 +254,7 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compiler info
|
# Compiler info
|
||||||
if(CMAKE_C_COMPILER_ID MATCHES "Clang|IntelLLVM")
|
if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||||
set(USE_CLANG TRUE)
|
set(USE_CLANG TRUE)
|
||||||
set(OPT_DEF_ASM TRUE)
|
set(OPT_DEF_ASM TRUE)
|
||||||
# Visual Studio 2019 v16.2 added support for Clang/LLVM.
|
# Visual Studio 2019 v16.2 added support for Clang/LLVM.
|
||||||
@@ -221,18 +268,20 @@ elseif(CMAKE_COMPILER_IS_GNUCC)
|
|||||||
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
|
elseif(MSVC_VERSION GREATER 1400) # VisualStudio 8.0+
|
||||||
set(OPT_DEF_ASM TRUE)
|
set(OPT_DEF_ASM TRUE)
|
||||||
#set(CMAKE_C_FLAGS "/ZI /WX- /
|
#set(CMAKE_C_FLAGS "/ZI /WX- /
|
||||||
elseif(CMAKE_C_COMPILER_ID MATCHES "^Intel$")
|
|
||||||
set(OPT_DEF_ASM TRUE)
|
|
||||||
set(USE_INTELCC TRUE)
|
|
||||||
else()
|
else()
|
||||||
set(OPT_DEF_ASM FALSE)
|
set(OPT_DEF_ASM FALSE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG)
|
||||||
set(OPT_DEF_GCC_ATOMICS ON)
|
set(OPT_DEF_GCC_ATOMICS ON)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Default option knobs
|
# Default option knobs
|
||||||
|
if(APPLE OR ARCH_64 OR MSVC_CLANG)
|
||||||
|
if(NOT "${CMAKE_OSX_ARCHITECTURES}" MATCHES "arm")
|
||||||
|
set(OPT_DEF_SSEMATH ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
|
if(UNIX OR MINGW OR MSYS OR (USE_CLANG AND NOT WINDOWS) OR VITA OR PSP OR PS2 OR N3DS)
|
||||||
set(OPT_DEF_LIBC ON)
|
set(OPT_DEF_LIBC ON)
|
||||||
endif()
|
endif()
|
||||||
@@ -245,11 +294,6 @@ if(NOT ("$ENV{CFLAGS}" STREQUAL ""))
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build in parallel under Visual Studio. Not enabled by default.
|
|
||||||
if(MSVC AND NOT USE_CLANG)
|
|
||||||
target_compile_options(sdl-build-options INTERFACE "/MP")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
|
option(SDL_FORCE_STATIC_VCRT "Force /MT for static VC runtimes" OFF)
|
||||||
if(SDL_FORCE_STATIC_VCRT)
|
if(SDL_FORCE_STATIC_VCRT)
|
||||||
@@ -327,6 +371,7 @@ endif()
|
|||||||
|
|
||||||
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
|
# All these ENABLED_BY_DEFAULT vars will default to ON if not specified, so
|
||||||
# you only need to have a platform override them if they are disabling.
|
# you only need to have a platform override them if they are disabling.
|
||||||
|
set(OPT_DEF_ASM TRUE)
|
||||||
if(EMSCRIPTEN)
|
if(EMSCRIPTEN)
|
||||||
# Set up default values for the currently supported set of subsystems:
|
# Set up default values for the currently supported set of subsystems:
|
||||||
# Emscripten/Javascript does not have assembly support, a dynamic library
|
# Emscripten/Javascript does not have assembly support, a dynamic library
|
||||||
@@ -390,21 +435,18 @@ set_option(SDL2_DISABLE_UNINSTALL "Disable uninstallation of SDL2" OFF)
|
|||||||
|
|
||||||
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
|
option_string(SDL_ASSERTIONS "Enable internal sanity checks (auto/disabled/release/enabled/paranoid)" "auto")
|
||||||
#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
|
#set_option(SDL_DEPENDENCY_TRACKING "Use gcc -MMD -MT dependency tracking" ON)
|
||||||
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
|
|
||||||
dep_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_SSE "Use SSE assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_SSE2 "Use SSE2 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_SSE3 "Use SSE3 assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_MMX "Use MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_X86 OR SDL_CPU_X64" OFF)
|
|
||||||
dep_option(SDL_ALTIVEC "Use Altivec assembly routines" ON "SDL_ASSEMBLY" OFF)
|
|
||||||
dep_option(SDL_ARMSIMD "Use SIMD assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
|
|
||||||
dep_option(SDL_ARMNEON "Use NEON assembly blitters on ARM" OFF "SDL_ASSEMBLY;SDL_CPU_ARM32" OFF)
|
|
||||||
dep_option(SDL_LSX "Use LSX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
|
|
||||||
dep_option(SDL_LASX "Use LASX assembly routines" ON "SDL_ASSEMBLY;SDL_CPU_LOONGARCH64" OFF)
|
|
||||||
|
|
||||||
set_option(SDL_LIBC "Use the system C library" ${OPT_DEF_LIBC})
|
set_option(SDL_LIBC "Use the system C library" ${OPT_DEF_LIBC})
|
||||||
set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
|
set_option(SDL_GCC_ATOMICS "Use gcc builtin atomics" ${OPT_DEF_GCC_ATOMICS})
|
||||||
|
set_option(SDL_ASSEMBLY "Enable assembly routines" ${OPT_DEF_ASM})
|
||||||
|
set_option(SDL_SSEMATH "Allow GCC to use SSE floating point math" ${OPT_DEF_SSEMATH})
|
||||||
|
set_option(SDL_MMX "Use MMX assembly routines" ${OPT_DEF_ASM})
|
||||||
|
set_option(SDL_3DNOW "Use 3Dnow! MMX assembly routines" ${OPT_DEF_ASM})
|
||||||
|
set_option(SDL_SSE "Use SSE assembly routines" ${OPT_DEF_ASM})
|
||||||
|
set_option(SDL_SSE2 "Use SSE2 assembly routines" ${OPT_DEF_SSEMATH})
|
||||||
|
set_option(SDL_SSE3 "Use SSE3 assembly routines" ${OPT_DEF_SSEMATH})
|
||||||
|
set_option(SDL_ALTIVEC "Use Altivec assembly routines" ${OPT_DEF_ASM})
|
||||||
|
set_option(SDL_ARMSIMD "use SIMD assembly blitters on ARM" OFF)
|
||||||
|
set_option(SDL_ARMNEON "use NEON assembly blitters on ARM" OFF)
|
||||||
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
|
dep_option(SDL_DBUS "Enable D-Bus support" ON ${UNIX_SYS} OFF)
|
||||||
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
|
set_option(SDL_DISKAUDIO "Support the disk writer audio driver" ON)
|
||||||
set_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON)
|
set_option(SDL_DUMMYAUDIO "Support the dummy audio driver" ON)
|
||||||
@@ -471,7 +513,6 @@ set_option(SDL_HIDAPI "Enable the HIDAPI subsystem" ON)
|
|||||||
dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI OFF)
|
dep_option(SDL_HIDAPI_LIBUSB "Use libusb for low level joystick drivers" OFF SDL_HIDAPI OFF)
|
||||||
dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF)
|
dep_option(SDL_HIDAPI_JOYSTICK "Use HIDAPI for low level joystick drivers" ON SDL_HIDAPI OFF)
|
||||||
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
|
dep_option(SDL_VIRTUAL_JOYSTICK "Enable the virtual-joystick driver" ON SDL_HIDAPI OFF)
|
||||||
set_option(SDL_LIBUDEV "Enable libudev support" ON)
|
|
||||||
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
|
set_option(SDL_ASAN "Use AddressSanitizer to detect memory errors" OFF)
|
||||||
option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "")
|
option_string(SDL_VENDOR_INFO "Vendor name and/or version to add to SDL_REVISION" "")
|
||||||
set_option(SDL_CCACHE "Use Ccache to speed up build" ON)
|
set_option(SDL_CCACHE "Use Ccache to speed up build" ON)
|
||||||
@@ -526,15 +567,6 @@ file(GLOB SOURCE_FILES
|
|||||||
${SDL2_SOURCE_DIR}/src/video/*.c
|
${SDL2_SOURCE_DIR}/src/video/*.c
|
||||||
${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
|
${SDL2_SOURCE_DIR}/src/video/yuv2rgb/*.c)
|
||||||
|
|
||||||
if(USE_INTELCC)
|
|
||||||
# warning #39: division by zero
|
|
||||||
# warning #239: floating point underflow
|
|
||||||
# warning #264: floating-point value does not fit in required floating-point type
|
|
||||||
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_exp.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd239 -wd264")
|
|
||||||
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_log.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd39")
|
|
||||||
set_property(SOURCE "${SDL2_SOURCE_DIR}/src/libm/e_log10.c" APPEND_STRING PROPERTY COMPILE_FLAGS " -wd39")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
|
|
||||||
set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 1)
|
set(SDL_DEFAULT_ASSERT_LEVEL_CONFIGURED 1)
|
||||||
if(SDL_ASSERTIONS MATCHES "^(auto|)$")
|
if(SDL_ASSERTIONS MATCHES "^(auto|)$")
|
||||||
@@ -563,7 +595,7 @@ if(NOT SDL_FOREGROUNDING_SIGNAL STREQUAL "OFF")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Compiler option evaluation
|
# Compiler option evaluation
|
||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG)
|
||||||
# Check for -Wall first, so later things can override pieces of it.
|
# Check for -Wall first, so later things can override pieces of it.
|
||||||
# Note: clang-cl treats -Wall as -Weverything (which is very loud),
|
# Note: clang-cl treats -Wall as -Weverything (which is very loud),
|
||||||
# /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough.
|
# /W3 as -Wall, and /W4 as -Wall -Wextra. So: /W3 is enough.
|
||||||
@@ -641,11 +673,6 @@ if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
|||||||
list(APPEND EXTRA_CFLAGS "-Wshadow")
|
list(APPEND EXTRA_CFLAGS "-Wshadow")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
check_c_compiler_flag(-Wunused-local-typedefs HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
|
|
||||||
if(HAVE_GCC_WUNUSED_LOCAL_TYPEDEFS)
|
|
||||||
list(APPEND EXTRA_CFLAGS "-Wno-unused-local-typedefs")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
# FIXME: don't use deprecated declarations
|
# FIXME: don't use deprecated declarations
|
||||||
@@ -706,7 +733,7 @@ if(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_ASSEMBLY)
|
if(SDL_ASSEMBLY)
|
||||||
if(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
if(USE_GCC OR USE_CLANG)
|
||||||
# TODO: Those all seem to be quite GCC specific - needs to be
|
# TODO: Those all seem to be quite GCC specific - needs to be
|
||||||
# reworked for better compiler support
|
# reworked for better compiler support
|
||||||
set(HAVE_ASSEMBLY TRUE)
|
set(HAVE_ASSEMBLY TRUE)
|
||||||
@@ -790,9 +817,8 @@ if(SDL_ASSEMBLY)
|
|||||||
#ifndef __SSE2__
|
#ifndef __SSE2__
|
||||||
#error Assembler CPP flag not enabled
|
#error Assembler CPP flag not enabled
|
||||||
#endif
|
#endif
|
||||||
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE2)
|
int main(int argc, char **argv) { return 0; }" HAVE_SSE2)
|
||||||
if(CPU_SUPPORTS_SSE2)
|
if(HAVE_SSE2)
|
||||||
set(HAVE_SSE2 TRUE)
|
|
||||||
list(APPEND EXTRA_CFLAGS "-msse2")
|
list(APPEND EXTRA_CFLAGS "-msse2")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||||
@@ -814,9 +840,8 @@ if(SDL_ASSEMBLY)
|
|||||||
#ifndef __SSE3__
|
#ifndef __SSE3__
|
||||||
#error Assembler CPP flag not enabled
|
#error Assembler CPP flag not enabled
|
||||||
#endif
|
#endif
|
||||||
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_SSE3)
|
int main(int argc, char **argv) { return 0; }" HAVE_SSE3)
|
||||||
if(CPU_SUPPORTS_SSE3)
|
if(HAVE_SSE3)
|
||||||
set(HAVE_SSE3 TRUE)
|
|
||||||
list(APPEND EXTRA_CFLAGS "-msse3")
|
list(APPEND EXTRA_CFLAGS "-msse3")
|
||||||
endif()
|
endif()
|
||||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||||
@@ -849,9 +874,9 @@ if(SDL_ASSEMBLY)
|
|||||||
vector unsigned int vzero() {
|
vector unsigned int vzero() {
|
||||||
return vec_splat_u32(0);
|
return vec_splat_u32(0);
|
||||||
}
|
}
|
||||||
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_ALTIVEC)
|
int main(int argc, char **argv) { return 0; }" HAVE_ALTIVEC)
|
||||||
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
set(CMAKE_REQUIRED_FLAGS ${ORIG_CMAKE_REQUIRED_FLAGS})
|
||||||
if(CPU_SUPPORTS_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
|
if(HAVE_ALTIVEC OR HAVE_ALTIVEC_H_HDR)
|
||||||
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
|
set(HAVE_ALTIVEC TRUE) # if only HAVE_ALTIVEC_H_HDR is set
|
||||||
list(APPEND EXTRA_CFLAGS "-maltivec")
|
list(APPEND EXTRA_CFLAGS "-maltivec")
|
||||||
set(SDL_ALTIVEC_BLITTERS 1)
|
set(SDL_ALTIVEC_BLITTERS 1)
|
||||||
@@ -861,39 +886,6 @@ if(SDL_ASSEMBLY)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_LSX)
|
|
||||||
cmake_push_check_state()
|
|
||||||
list(APPEND CMAKE_REQUIRED_FLAGS "-mlsx")
|
|
||||||
check_c_source_compiles("
|
|
||||||
#ifndef __loongarch_sx
|
|
||||||
#error Assembler CPP flag not enabled
|
|
||||||
#endif
|
|
||||||
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LSX)
|
|
||||||
check_include_file("lsxintrin.h" HAVE_LSXINTRIN_H)
|
|
||||||
cmake_pop_check_state()
|
|
||||||
|
|
||||||
if(CPU_SUPPORTS_LSX AND HAVE_LSXINTRIN_H)
|
|
||||||
list(APPEND EXTRA_CFLAGS "-mlsx")
|
|
||||||
set(HAVE_LSX TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SDL_LASX)
|
|
||||||
cmake_push_check_state()
|
|
||||||
list(APPEND CMAKE_REQUIRED_FLAGS "-mlasx")
|
|
||||||
check_c_source_compiles("
|
|
||||||
#ifndef __loongarch_asx
|
|
||||||
#error Assembler CPP flag not enabled
|
|
||||||
#endif
|
|
||||||
int main(int argc, char **argv) { return 0; }" CPU_SUPPORTS_LASX)
|
|
||||||
check_include_file("lasxintrin.h" HAVE_LASXINTRIN_H)
|
|
||||||
cmake_pop_check_state()
|
|
||||||
if(CPU_SUPPORTS_LASX AND HAVE_LASXINTRIN_H)
|
|
||||||
list(APPEND EXTRA_CFLAGS "-mlasx")
|
|
||||||
set(HAVE_LASX TRUE)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(SDL_ARMSIMD)
|
if(SDL_ARMSIMD)
|
||||||
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
set(ORIG_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
|
||||||
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -x assembler-with-cpp")
|
||||||
@@ -952,22 +944,12 @@ if(SDL_ASSEMBLY)
|
|||||||
# TODO: SDL_cpuinfo.h needs to support the user's configuration wish
|
# TODO: SDL_cpuinfo.h needs to support the user's configuration wish
|
||||||
# for MSVC - right now it is always activated
|
# for MSVC - right now it is always activated
|
||||||
if(NOT ARCH_64)
|
if(NOT ARCH_64)
|
||||||
if(SDL_MMX)
|
|
||||||
set(HAVE_MMX TRUE)
|
set(HAVE_MMX TRUE)
|
||||||
endif()
|
|
||||||
if(SDL_3DNOW)
|
|
||||||
set(HAVE_3DNOW TRUE)
|
set(HAVE_3DNOW TRUE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
if(SDL_SSE)
|
|
||||||
set(HAVE_SSE TRUE)
|
set(HAVE_SSE TRUE)
|
||||||
endif()
|
|
||||||
if(SDL_SSE2)
|
|
||||||
set(HAVE_SSE2 TRUE)
|
set(HAVE_SSE2 TRUE)
|
||||||
endif()
|
|
||||||
if(SDL_SSE3)
|
|
||||||
set(HAVE_SSE3 TRUE)
|
set(HAVE_SSE3 TRUE)
|
||||||
endif()
|
|
||||||
check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
|
check_include_file("immintrin.h" HAVE_IMMINTRIN_H)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -1119,10 +1101,6 @@ else()
|
|||||||
set(HAVE_STDARG_H 1)
|
set(HAVE_STDARG_H 1)
|
||||||
set(HAVE_STDDEF_H 1)
|
set(HAVE_STDDEF_H 1)
|
||||||
check_include_file(stdint.h HAVE_STDINT_H)
|
check_include_file(stdint.h HAVE_STDINT_H)
|
||||||
|
|
||||||
if(MSVC AND USE_CLANG)
|
|
||||||
check_c_compiler_flag("/Q_no-use-libirc" HAS_Q_NO_USE_LIBIRC )
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -1491,18 +1469,6 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
|||||||
ioctl(0, KDENABIO, 1);
|
ioctl(0, KDENABIO, 1);
|
||||||
return 0;
|
return 0;
|
||||||
}" HAVE_INPUT_KBIO)
|
}" HAVE_INPUT_KBIO)
|
||||||
elseif(OPENBSD OR NETBSD)
|
|
||||||
check_c_source_compiles("
|
|
||||||
#include <sys/time.h>
|
|
||||||
#include <dev/wscons/wsconsio.h>
|
|
||||||
#include <dev/wscons/wsksymdef.h>
|
|
||||||
#include <dev/wscons/wsksymvar.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
int main(int argc, char **argv) {
|
|
||||||
struct wskbd_map_data data;
|
|
||||||
ioctl(0, WSKBDIO_GETMAP, &data);
|
|
||||||
return 0;
|
|
||||||
}" HAVE_INPUT_WSCONS)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_INPUT_EVENTS)
|
if(HAVE_INPUT_EVENTS)
|
||||||
@@ -1524,11 +1490,7 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
|||||||
set(SDL_INPUT_FBSDKBIO 1)
|
set(SDL_INPUT_FBSDKBIO 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_INPUT_WSCONS)
|
check_include_file("libudev.h" HAVE_LIBUDEV_H)
|
||||||
set(SDL_INPUT_WSCONS 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
CheckLibUDev()
|
|
||||||
check_include_file("sys/inotify.h" HAVE_SYS_INOTIFY_H)
|
check_include_file("sys/inotify.h" HAVE_SYS_INOTIFY_H)
|
||||||
check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY_INIT)
|
check_symbol_exists(inotify_init "sys/inotify.h" HAVE_INOTIFY_INIT)
|
||||||
check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
|
check_symbol_exists(inotify_init1 "sys/inotify.h" HAVE_INOTIFY_INIT1)
|
||||||
@@ -1638,14 +1600,14 @@ elseif(UNIX AND NOT APPLE AND NOT RISCOS AND NOT HAIKU)
|
|||||||
CheckPTHREAD()
|
CheckPTHREAD()
|
||||||
|
|
||||||
if(SDL_CLOCK_GETTIME)
|
if(SDL_CLOCK_GETTIME)
|
||||||
|
check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME_LIBRT)
|
||||||
|
if(FOUND_CLOCK_GETTIME_LIBRT)
|
||||||
|
list(APPEND EXTRA_LIBS rt)
|
||||||
|
set(HAVE_CLOCK_GETTIME 1)
|
||||||
|
else()
|
||||||
check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME_LIBC)
|
check_library_exists(c clock_gettime "" FOUND_CLOCK_GETTIME_LIBC)
|
||||||
if(FOUND_CLOCK_GETTIME_LIBC)
|
if(FOUND_CLOCK_GETTIME_LIBC)
|
||||||
set(HAVE_CLOCK_GETTIME 1)
|
set(HAVE_CLOCK_GETTIME 1)
|
||||||
else()
|
|
||||||
check_library_exists(rt clock_gettime "" FOUND_CLOCK_GETTIME_LIBRT)
|
|
||||||
if(FOUND_CLOCK_GETTIME_LIBRT)
|
|
||||||
set(HAVE_CLOCK_GETTIME 1)
|
|
||||||
list(APPEND EXTRA_LIBS rt)
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@@ -1725,7 +1687,7 @@ elseif(WINDOWS)
|
|||||||
|
|
||||||
if(MSVC AND NOT SDL_LIBC)
|
if(MSVC AND NOT SDL_LIBC)
|
||||||
# Prevent codegen that would use the VC runtime libraries.
|
# Prevent codegen that would use the VC runtime libraries.
|
||||||
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-;/Gs1048576")
|
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/GS-")
|
||||||
if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
|
if(NOT ARCH_64 AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
|
||||||
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
|
set_property(DIRECTORY . APPEND PROPERTY COMPILE_OPTIONS "/arch:SSE")
|
||||||
endif()
|
endif()
|
||||||
@@ -2506,9 +2468,6 @@ elseif(VITA)
|
|||||||
set(SDL_VIDEO_OPENGL_ES2 1)
|
set(SDL_VIDEO_OPENGL_ES2 1)
|
||||||
list(APPEND EXTRA_LIBS
|
list(APPEND EXTRA_LIBS
|
||||||
pib
|
pib
|
||||||
libScePiglet_stub_weak
|
|
||||||
taihen_stub_weak
|
|
||||||
SceShaccCg_stub_weak
|
|
||||||
)
|
)
|
||||||
set(HAVE_VIDEO_VITA_PIB ON)
|
set(HAVE_VIDEO_VITA_PIB ON)
|
||||||
set(SDL_VIDEO_VITA_PIB 1)
|
set(SDL_VIDEO_VITA_PIB 1)
|
||||||
@@ -2521,6 +2480,7 @@ elseif(VITA)
|
|||||||
check_include_file(gpu_es4/psp2_pvr_hint.h HAVE_PVR_H)
|
check_include_file(gpu_es4/psp2_pvr_hint.h HAVE_PVR_H)
|
||||||
if(HAVE_PVR_H)
|
if(HAVE_PVR_H)
|
||||||
target_compile_definitions(sdl-build-options INTERFACE "-D__psp2__")
|
target_compile_definitions(sdl-build-options INTERFACE "-D__psp2__")
|
||||||
|
check_include_file(gl4esinit.h HAVE_GL4ES_H)
|
||||||
set(SDL_VIDEO_OPENGL_EGL 1)
|
set(SDL_VIDEO_OPENGL_EGL 1)
|
||||||
set(HAVE_OPENGLES TRUE)
|
set(HAVE_OPENGLES TRUE)
|
||||||
set(SDL_VIDEO_OPENGL_ES 1)
|
set(SDL_VIDEO_OPENGL_ES 1)
|
||||||
@@ -2531,14 +2491,11 @@ elseif(VITA)
|
|||||||
list(APPEND EXTRA_LIBS
|
list(APPEND EXTRA_LIBS
|
||||||
libgpu_es4_ext_stub_weak
|
libgpu_es4_ext_stub_weak
|
||||||
libIMGEGL_stub_weak
|
libIMGEGL_stub_weak
|
||||||
SceIme_stub
|
|
||||||
)
|
)
|
||||||
|
|
||||||
set(HAVE_VIDEO_VITA_PVR ON)
|
set(HAVE_VIDEO_VITA_PVR ON)
|
||||||
set(SDL_VIDEO_VITA_PVR 1)
|
set(SDL_VIDEO_VITA_PVR 1)
|
||||||
|
|
||||||
if(SDL_OPENGL)
|
|
||||||
check_include_file(gl4esinit.h HAVE_GL4ES_H)
|
|
||||||
if(HAVE_GL4ES_H)
|
if(HAVE_GL4ES_H)
|
||||||
set(HAVE_OPENGL TRUE)
|
set(HAVE_OPENGL TRUE)
|
||||||
set(SDL_VIDEO_OPENGL 1)
|
set(SDL_VIDEO_OPENGL 1)
|
||||||
@@ -2546,7 +2503,6 @@ elseif(VITA)
|
|||||||
list(APPEND EXTRA_LIBS libGL_stub)
|
list(APPEND EXTRA_LIBS libGL_stub)
|
||||||
set(SDL_VIDEO_VITA_PVR_OGL 1)
|
set(SDL_VIDEO_VITA_PVR_OGL 1)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
set(HAVE_VIDEO_VITA_PVR OFF)
|
set(HAVE_VIDEO_VITA_PVR OFF)
|
||||||
@@ -2575,6 +2531,19 @@ elseif(VITA)
|
|||||||
SceProcessmgr_stub
|
SceProcessmgr_stub
|
||||||
m
|
m
|
||||||
)
|
)
|
||||||
|
if(HAVE_VITA_PIB)
|
||||||
|
list(PREPEND EXTRA_LIBS
|
||||||
|
pib
|
||||||
|
libScePiglet_stub
|
||||||
|
SceShaccCg_stub
|
||||||
|
taihen_stub
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
if(HAVE_VITA_PVR)
|
||||||
|
list(PREPEND EXTRA_LIBS
|
||||||
|
SceIme_stub
|
||||||
|
)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(HAVE_ARMSIMD TRUE)
|
set(HAVE_ARMSIMD TRUE)
|
||||||
@@ -2657,7 +2626,7 @@ elseif(PSP)
|
|||||||
)
|
)
|
||||||
if(NOT SDL2_DISABLE_SDL2MAIN)
|
if(NOT SDL2_DISABLE_SDL2MAIN)
|
||||||
list(INSERT SDL_LIBS 0 "-lSDL2main")
|
list(INSERT SDL_LIBS 0 "-lSDL2main")
|
||||||
endif()
|
endif(NOT SDL2_DISABLE_SDL2MAIN)
|
||||||
|
|
||||||
elseif(PS2)
|
elseif(PS2)
|
||||||
list(APPEND EXTRA_CFLAGS "-DPS2" "-D__PS2__" "-I$ENV{PS2SDK}/ports/include" "-I$ENV{PS2DEV}/gsKit/include")
|
list(APPEND EXTRA_CFLAGS "-DPS2" "-D__PS2__" "-I$ENV{PS2SDK}/ports/include" "-I$ENV{PS2DEV}/gsKit/include")
|
||||||
@@ -2855,17 +2824,6 @@ elseif(N3DS)
|
|||||||
else()
|
else()
|
||||||
message_error("SDL_FILE must be enabled to build on N3DS")
|
message_error("SDL_FILE must be enabled to build on N3DS")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT SDL2_DISABLE_SDL2MAIN)
|
|
||||||
list(INSERT SDL_LIBS 0 "-lSDL2main")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
foreach(lib ${CMAKE_C_STANDARD_LIBRARIES})
|
|
||||||
if(lib MATCHES "^-l")
|
|
||||||
string(SUBSTRING "${lib}" 2 -1 lib)
|
|
||||||
endif()
|
|
||||||
list(APPEND EXTRA_LIBS ${lib})
|
|
||||||
endforeach()
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(HAVE_VULKAN AND NOT SDL_LOADSO)
|
if(HAVE_VULKAN AND NOT SDL_LOADSO)
|
||||||
@@ -2960,7 +2918,7 @@ if(SDL_WERROR)
|
|||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /WX")
|
||||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX")
|
||||||
endif()
|
endif()
|
||||||
elseif(USE_GCC OR USE_CLANG OR USE_INTELCC)
|
elseif(USE_GCC OR USE_CLANG)
|
||||||
cmake_push_check_state(RESET)
|
cmake_push_check_state(RESET)
|
||||||
check_c_compiler_flag(-Werror HAVE_WERROR)
|
check_c_compiler_flag(-Werror HAVE_WERROR)
|
||||||
if(HAVE_WERROR)
|
if(HAVE_WERROR)
|
||||||
@@ -2988,7 +2946,7 @@ string(TOLOWER "${CMAKE_BUILD_TYPE}" lower_build_type)
|
|||||||
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include-config-${lower_build_type}")
|
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_CURRENT_BINARY_DIR}/include-config-${lower_build_type}")
|
||||||
# 3. generate SDL_config in an build_type-dependent folder (which should be first in the include search path)
|
# 3. generate SDL_config in an build_type-dependent folder (which should be first in the include search path)
|
||||||
file(GENERATE
|
file(GENERATE
|
||||||
OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
|
OUTPUT "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h"
|
||||||
INPUT "${SDL2_BINARY_DIR}/SDL_config.h.intermediate")
|
INPUT "${SDL2_BINARY_DIR}/SDL_config.h.intermediate")
|
||||||
|
|
||||||
# Prepare the flags and remove duplicates
|
# Prepare the flags and remove duplicates
|
||||||
@@ -3039,9 +2997,9 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
|
configure_file("${SDL2_SOURCE_DIR}/include/SDL_revision.h.cmake"
|
||||||
"${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h")
|
"${SDL2_BINARY_DIR}/include/SDL_revision.h")
|
||||||
|
|
||||||
# Copy all non-generated headers to "${SDL2_BINARY_DIR}/include/SDL2"
|
# Copy all non-generated headers to "${SDL2_BINARY_DIR}/include"
|
||||||
# This is done to avoid the inclusion of a pre-generated SDL_config.h
|
# This is done to avoid the inclusion of a pre-generated SDL_config.h
|
||||||
file(GLOB SDL2_INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
|
file(GLOB SDL2_INCLUDE_FILES ${SDL2_SOURCE_DIR}/include/*.h)
|
||||||
set(SDL2_COPIED_INCLUDE_FILES)
|
set(SDL2_COPIED_INCLUDE_FILES)
|
||||||
@@ -3050,7 +3008,7 @@ foreach(_hdr IN LISTS SDL2_INCLUDE_FILES)
|
|||||||
list(REMOVE_ITEM SDL2_INCLUDE_FILES "${_hdr}")
|
list(REMOVE_ITEM SDL2_INCLUDE_FILES "${_hdr}")
|
||||||
else()
|
else()
|
||||||
get_filename_component(_name "${_hdr}" NAME)
|
get_filename_component(_name "${_hdr}" NAME)
|
||||||
set(_bin_hdr "${SDL2_BINARY_DIR}/include/SDL2/${_name}")
|
set(_bin_hdr "${SDL2_BINARY_DIR}/include/${_name}")
|
||||||
list(APPEND SDL2_COPIED_INCLUDE_FILES "${_bin_hdr}")
|
list(APPEND SDL2_COPIED_INCLUDE_FILES "${_bin_hdr}")
|
||||||
add_custom_command(OUTPUT "${_bin_hdr}"
|
add_custom_command(OUTPUT "${_bin_hdr}"
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_hdr}" "${_bin_hdr}"
|
COMMAND ${CMAKE_COMMAND} -E copy_if_different "${_hdr}" "${_bin_hdr}"
|
||||||
@@ -3105,7 +3063,6 @@ string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_STATIC_LIBS "$
|
|||||||
if(NOT SDL_SHARED)
|
if(NOT SDL_SHARED)
|
||||||
string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_LIBS "${SDL_LIBS}")
|
string(REGEX REPLACE "-lSDL2( |$)" "-l${sdl_static_libname} " SDL_LIBS "${SDL_LIBS}")
|
||||||
endif()
|
endif()
|
||||||
listtostr(PKGCONFIG_DEPENDS PKGCONFIG_DEPENDS)
|
|
||||||
|
|
||||||
if(SDL_STATIC AND SDL_SHARED AND NOT sdl_static_libname STREQUAL "SDL2")
|
if(SDL_STATIC AND SDL_SHARED AND NOT sdl_static_libname STREQUAL "SDL2")
|
||||||
message(STATUS "\"pkg-config --static --libs sdl2\" will return invalid information")
|
message(STATUS "\"pkg-config --static --libs sdl2\" will return invalid information")
|
||||||
@@ -3186,7 +3143,7 @@ if (SDL_ASAN)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_CCACHE AND NOT CMAKE_VERSION VERSION_LESS 3.4)
|
if(SDL_CCACHE)
|
||||||
cmake_minimum_required(VERSION 3.4)
|
cmake_minimum_required(VERSION 3.4)
|
||||||
find_program(CCACHE_BINARY ccache)
|
find_program(CCACHE_BINARY ccache)
|
||||||
if(CCACHE_BINARY)
|
if(CCACHE_BINARY)
|
||||||
@@ -3197,8 +3154,6 @@ if(SDL_CCACHE AND NOT CMAKE_VERSION VERSION_LESS 3.4)
|
|||||||
else()
|
else()
|
||||||
set(HAVE_CCACHE OFF)
|
set(HAVE_CCACHE OFF)
|
||||||
endif()
|
endif()
|
||||||
else()
|
|
||||||
set(HAVE_CCACHE OFF)
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_TESTS)
|
if(SDL_TESTS)
|
||||||
@@ -3284,11 +3239,7 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
|
|||||||
add_dependencies(SDL2main sdl_headers_copy)
|
add_dependencies(SDL2main sdl_headers_copy)
|
||||||
# alias target for in-tree builds
|
# alias target for in-tree builds
|
||||||
add_library(SDL2::SDL2main ALIAS SDL2main)
|
add_library(SDL2::SDL2main ALIAS SDL2main)
|
||||||
target_include_directories(SDL2main BEFORE
|
target_include_directories(SDL2main BEFORE PRIVATE "${SDL2_BINARY_DIR}/include" PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>")
|
||||||
PRIVATE "${SDL2_BINARY_DIR}/include"
|
|
||||||
PRIVATE "${SDL2_BINARY_DIR}/include/SDL2"
|
|
||||||
PRIVATE "${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2"
|
|
||||||
)
|
|
||||||
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
|
target_include_directories(SDL2main PUBLIC "$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>" $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}> $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>)
|
||||||
if (WIN32)
|
if (WIN32)
|
||||||
target_link_libraries(SDL2main PRIVATE shell32)
|
target_link_libraries(SDL2main PRIVATE shell32)
|
||||||
@@ -3303,8 +3254,6 @@ if(NOT WINDOWS_STORE AND NOT SDL2_DISABLE_SDL2MAIN)
|
|||||||
if (NOT ANDROID)
|
if (NOT ANDROID)
|
||||||
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
set_target_properties(SDL2main PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET SDL2main APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
|
||||||
set_property(TARGET SDL2main PROPERTY INTERFACE_SDL_VERSION "SDL2")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(ANDROID)
|
if(ANDROID)
|
||||||
@@ -3335,13 +3284,11 @@ if(SDL_SHARED)
|
|||||||
add_library(SDL2::SDL2 ALIAS SDL2)
|
add_library(SDL2::SDL2 ALIAS SDL2)
|
||||||
set_target_properties(SDL2 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
set_target_properties(SDL2 PROPERTIES POSITION_INDEPENDENT_CODE TRUE)
|
||||||
if(NOT SDL_LIBC)
|
if(NOT SDL_LIBC)
|
||||||
if(SDL_CPU_X86)
|
check_cpu_architecture(x86 HAS_X86)
|
||||||
|
if(HAS_X86)
|
||||||
# FIXME: should be added for all architectures (missing symbols for ARM)
|
# FIXME: should be added for all architectures (missing symbols for ARM)
|
||||||
target_link_libraries(SDL2 PRIVATE "-nodefaultlib:MSVCRT")
|
target_link_libraries(SDL2 PRIVATE "-nodefaultlib:MSVCRT")
|
||||||
endif()
|
endif()
|
||||||
if(HAS_Q_NO_USE_LIBIRC)
|
|
||||||
target_compile_options(SDL2 PRIVATE /Q_no-use-libirc)
|
|
||||||
endif()
|
|
||||||
endif()
|
endif()
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
# FIXME: Remove SOVERSION in SDL3
|
# FIXME: Remove SOVERSION in SDL3
|
||||||
@@ -3371,19 +3318,18 @@ if(SDL_SHARED)
|
|||||||
if(MSVC AND NOT SDL_LIBC AND NOT MSVC_CLANG AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
|
if(MSVC AND NOT SDL_LIBC AND NOT MSVC_CLANG AND NOT CMAKE_GENERATOR_PLATFORM STREQUAL "ARM")
|
||||||
# Don't try to link with the default set of libraries.
|
# Don't try to link with the default set of libraries.
|
||||||
if(NOT WINDOWS_STORE)
|
if(NOT WINDOWS_STORE)
|
||||||
set_property(TARGET SDL2 APPEND_STRING PROPERTY LINK_FLAGS " /NODEFAULTLIB")
|
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_RELEASE "/NODEFAULTLIB")
|
||||||
|
set_target_properties(SDL2 PROPERTIES LINK_FLAGS_DEBUG "/NODEFAULTLIB")
|
||||||
endif()
|
endif()
|
||||||
set_property(TARGET SDL2 APPEND_STRING PROPERTY STATIC_LIBRARY_FLAGS " /NODEFAULTLIB")
|
set_target_properties(SDL2 PROPERTIES STATIC_LIBRARY_FLAGS "/NODEFAULTLIB")
|
||||||
endif()
|
endif()
|
||||||
# FIXME: if CMAKE_VERSION >= 3.13, use target_link_options for EXTRA_LDFLAGS
|
# FIXME: if CMAKE_VERSION >= 3.13, use target_link_options for EXTRA_LDFLAGS
|
||||||
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD} ${CMAKE_DEPENDS})
|
target_link_libraries(SDL2 PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${EXTRA_LDFLAGS_BUILD})
|
||||||
target_include_directories(SDL2 PUBLIC
|
target_include_directories(SDL2 PUBLIC
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
||||||
)
|
|
||||||
# This picks up all the compiler options and such we've accumulated up to here.
|
# This picks up all the compiler options and such we've accumulated up to here.
|
||||||
target_link_libraries(SDL2 PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
|
target_link_libraries(SDL2 PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
|
||||||
if(MINGW OR CYGWIN)
|
if(MINGW OR CYGWIN)
|
||||||
@@ -3395,10 +3341,8 @@ if(SDL_SHARED)
|
|||||||
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
set_target_properties(SDL2 PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
||||||
endif()
|
endif()
|
||||||
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
||||||
set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
|
|
||||||
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL2_SHARED TRUE)
|
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL2_SHARED TRUE)
|
||||||
set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
set_property(TARGET SDL2 APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
|
||||||
set_property(TARGET SDL2 PROPERTY INTERFACE_SDL_VERSION "SDL2")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(SDL_STATIC)
|
if(SDL_STATIC)
|
||||||
@@ -3412,24 +3356,20 @@ if(SDL_STATIC)
|
|||||||
target_compile_definitions(SDL2-static PRIVATE SDL_STATIC_LIB)
|
target_compile_definitions(SDL2-static PRIVATE SDL_STATIC_LIB)
|
||||||
# TODO: Win32 platforms keep the same suffix .lib for import and static
|
# TODO: Win32 platforms keep the same suffix .lib for import and static
|
||||||
# libraries - do we need to consider this?
|
# libraries - do we need to consider this?
|
||||||
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS} ${CMAKE_DEPENDS})
|
target_link_libraries(SDL2-static PRIVATE ${EXTRA_LIBS} ${EXTRA_LDFLAGS})
|
||||||
target_include_directories(SDL2-static PUBLIC
|
target_include_directories(SDL2-static PUBLIC
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
||||||
)
|
|
||||||
# This picks up all the compiler options and such we've accumulated up to here.
|
# This picks up all the compiler options and such we've accumulated up to here.
|
||||||
target_link_libraries(SDL2-static PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
|
target_link_libraries(SDL2-static PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
|
||||||
if(NOT ANDROID)
|
if(NOT ANDROID)
|
||||||
set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
set_target_properties(SDL2-static PROPERTIES DEBUG_POSTFIX "${SDL_CMAKE_DEBUG_POSTFIX}")
|
||||||
endif()
|
endif()
|
||||||
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
# Use `Compatible Interface Properties` to allow consumers to enforce a shared/static library
|
||||||
set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
|
|
||||||
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL2_SHARED FALSE)
|
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL2_SHARED FALSE)
|
||||||
set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
set_property(TARGET SDL2-static APPEND PROPERTY COMPATIBLE_INTERFACE_BOOL SDL2_SHARED)
|
||||||
set_property(TARGET SDL2-static PROPERTY INTERFACE_SDL_VERSION "SDL2")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MAJOR_VERSION=${SDL_MAJOR_VERSION}")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSDL_BUILD_MAJOR_VERSION=${SDL_MAJOR_VERSION}")
|
||||||
@@ -3447,13 +3387,10 @@ if(SDL_TEST)
|
|||||||
EXPORT_NAME SDL2test)
|
EXPORT_NAME SDL2test)
|
||||||
target_include_directories(SDL2_test PUBLIC
|
target_include_directories(SDL2_test PUBLIC
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include/SDL2>"
|
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>>"
|
||||||
"$<BUILD_INTERFACE:${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2>"
|
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
|
||||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL2>")
|
||||||
target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS})
|
target_link_libraries(SDL2_test PRIVATE ${EXTRA_TEST_LIBS})
|
||||||
set_property(TARGET SDL2_test APPEND PROPERTY COMPATIBLE_INTERFACE_STRING "SDL_VERSION")
|
|
||||||
set_property(TARGET SDL2_test PROPERTY INTERFACE_SDL_VERSION "SDL2")
|
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
##### Installation targets #####
|
##### Installation targets #####
|
||||||
@@ -3558,7 +3495,6 @@ if(NOT SDL2_DISABLE_INSTALL)
|
|||||||
FILES
|
FILES
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/SDL2Config.cmake
|
||||||
${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake
|
${CMAKE_CURRENT_BINARY_DIR}/SDL2ConfigVersion.cmake
|
||||||
${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake
|
|
||||||
DESTINATION "${SDL_INSTALL_CMAKEDIR}"
|
DESTINATION "${SDL_INSTALL_CMAKEDIR}"
|
||||||
COMPONENT Devel
|
COMPONENT Devel
|
||||||
)
|
)
|
||||||
@@ -3566,8 +3502,8 @@ if(NOT SDL2_DISABLE_INSTALL)
|
|||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
${SDL2_INCLUDE_FILES}
|
${SDL2_INCLUDE_FILES}
|
||||||
"${SDL2_BINARY_DIR}/include/SDL2/SDL_revision.h"
|
"${SDL2_BINARY_DIR}/include/SDL_revision.h"
|
||||||
"${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL2/SDL_config.h"
|
"${SDL2_BINARY_DIR}/include-config-$<LOWER_CASE:$<CONFIG>>/SDL_config.h"
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2)
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/SDL2)
|
||||||
|
|
||||||
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
|
string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE)
|
||||||
|
|||||||
+1
-2
@@ -27,7 +27,6 @@ LDFLAGS = @BUILD_LDFLAGS@
|
|||||||
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
|
EXTRA_LDFLAGS = @EXTRA_LDFLAGS@
|
||||||
LIBTOOL = @LIBTOOL@
|
LIBTOOL = @LIBTOOL@
|
||||||
INSTALL = @INSTALL@
|
INSTALL = @INSTALL@
|
||||||
FGREP = @FGREP@
|
|
||||||
AR = @AR@
|
AR = @AR@
|
||||||
RANLIB = @RANLIB@
|
RANLIB = @RANLIB@
|
||||||
RC = @RC@
|
RC = @RC@
|
||||||
@@ -131,7 +130,7 @@ HDRS = \
|
|||||||
begin_code.h \
|
begin_code.h \
|
||||||
close_code.h
|
close_code.h
|
||||||
|
|
||||||
SDLTEST_HDRS = $(shell ls $(srcdir)/include | $(FGREP) SDL_test)
|
SDLTEST_HDRS = $(shell ls $(srcdir)/include | fgrep SDL_test)
|
||||||
|
|
||||||
LT_AGE = @LT_AGE@
|
LT_AGE = @LT_AGE@
|
||||||
LT_CURRENT = @LT_CURRENT@
|
LT_CURRENT = @LT_CURRENT@
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
# Makefile to build the SDL library
|
# Makefile to build the SDL library
|
||||||
|
|
||||||
CPPFLAGS = -I./include
|
INCLUDE = -I./include
|
||||||
CFLAGS = -g -O2
|
CFLAGS = -g -O2 $(INCLUDE)
|
||||||
AR = ar
|
AR = ar
|
||||||
RANLIB = ranlib
|
RANLIB = ranlib
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -14,8 +14,8 @@
|
|||||||
|
|
||||||
LIBNAME = SDL2
|
LIBNAME = SDL2
|
||||||
MAJOR_VERSION = 2
|
MAJOR_VERSION = 2
|
||||||
MINOR_VERSION = 27
|
MINOR_VERSION = 26
|
||||||
MICRO_VERSION = 1
|
MICRO_VERSION = 5
|
||||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||||
DESCRIPTION = Simple DirectMedia Layer 2
|
DESCRIPTION = Simple DirectMedia Layer 2
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -5,8 +5,8 @@
|
|||||||
|
|
||||||
LIBNAME = SDL2
|
LIBNAME = SDL2
|
||||||
MAJOR_VERSION = 2
|
MAJOR_VERSION = 2
|
||||||
MINOR_VERSION = 27
|
MINOR_VERSION = 26
|
||||||
MICRO_VERSION = 1
|
MICRO_VERSION = 5
|
||||||
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
VERSION = $(MAJOR_VERSION).$(MINOR_VERSION).$(MICRO_VERSION)
|
||||||
|
|
||||||
LIBHOME = .
|
LIBHOME = .
|
||||||
|
|||||||
@@ -30,18 +30,6 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL2testTargets.cmake")
|
|||||||
set(SDL2_SDL2test_FOUND TRUE)
|
set(SDL2_SDL2test_FOUND TRUE)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
include("${CMAKE_CURRENT_LIST_DIR}/sdlfind.cmake")
|
|
||||||
|
|
||||||
set(SDL_ALSA @SDL_ALSA@)
|
|
||||||
set(SDL_ALSA_SHARED @SDL_ALSA_SHARED@)
|
|
||||||
if(SDL_ALSA AND NOT SDL_ALSA_SHARED AND TARGET SDL2::SDL2-static)
|
|
||||||
sdlFindALSA()
|
|
||||||
endif()
|
|
||||||
unset(SDL_ALSA)
|
|
||||||
unset(SDL_ALSA_SHARED)
|
|
||||||
|
|
||||||
|
|
||||||
check_required_components(SDL2)
|
check_required_components(SDL2)
|
||||||
|
|
||||||
# Create SDL2::SDL2 alias for static-only builds
|
# Create SDL2::SDL2 alias for static-only builds
|
||||||
|
|||||||
@@ -239,17 +239,17 @@ LoadSprite(const char *file)
|
|||||||
/* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
|
/* This does the SDL_LoadBMP step repeatedly, but that's OK for test code. */
|
||||||
sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h);
|
sprites[i] = LoadTexture(state->renderers[i], file, SDL_TRUE, &sprite_w, &sprite_h);
|
||||||
if (!sprites[i]) {
|
if (!sprites[i]) {
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
|
if (SDL_SetTextureBlendMode(sprites[i], blendMode) < 0) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set blend mode: %s\n", SDL_GetError());
|
||||||
SDL_DestroyTexture(sprites[i]);
|
SDL_DestroyTexture(sprites[i]);
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We're ready to roll. :) */
|
/* We're ready to roll. :) */
|
||||||
return 0;
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@@ -364,9 +364,8 @@ loop()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
for (i = 0; i < state->num_windows; ++i) {
|
for (i = 0; i < state->num_windows; ++i) {
|
||||||
if (state->windows[i] == NULL) {
|
if (state->windows[i] == NULL)
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
DrawSprites(state->renderers[i], sprites[i]);
|
DrawSprites(state->renderers[i], sprites[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,7 +382,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Initialize test framework */
|
/* Initialize test framework */
|
||||||
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
state = SDLTest_CommonCreateState(argv, SDL_INIT_VIDEO | SDL_INIT_AUDIO);
|
||||||
if (state == NULL) {
|
if (!state) {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -446,7 +445,7 @@ main(int argc, char *argv[])
|
|||||||
/* Create the windows, initialize the renderers, and load the textures */
|
/* Create the windows, initialize the renderers, and load the textures */
|
||||||
sprites =
|
sprites =
|
||||||
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
|
(SDL_Texture **) SDL_malloc(state->num_windows * sizeof(*sprites));
|
||||||
if (sprites == NULL) {
|
if (!sprites) {
|
||||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Out of memory!\n");
|
||||||
quit(2);
|
quit(2);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -137,7 +137,6 @@
|
|||||||
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
<DebugInformationFormat>OldStyle</DebugInformationFormat>
|
||||||
<OmitDefaultLibName>true</OmitDefaultLibName>
|
<OmitDefaultLibName>true</OmitDefaultLibName>
|
||||||
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
<InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion>
|
||||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<ResourceCompile>
|
<ResourceCompile>
|
||||||
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ if(EXISTS "${_sdl2_library}" AND EXISTS "${_sdl2_dll_library}")
|
|||||||
IMPORTED_LOCATION "${_sdl2_dll_library}"
|
IMPORTED_LOCATION "${_sdl2_dll_library}"
|
||||||
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
|
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
|
||||||
INTERFACE_SDL2_SHARED "ON"
|
INTERFACE_SDL2_SHARED "ON"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2_FOUND TRUE)
|
set(SDL2_SDL2_FOUND TRUE)
|
||||||
@@ -86,8 +84,6 @@ if(EXISTS "${_sdl2main_library}")
|
|||||||
set_target_properties(SDL2::SDL2main
|
set_target_properties(SDL2::SDL2main
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
IMPORTED_LOCATION "${_sdl2main_library}"
|
IMPORTED_LOCATION "${_sdl2main_library}"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2main_FOUND TRUE)
|
set(SDL2_SDL2main_FOUND TRUE)
|
||||||
@@ -104,8 +100,6 @@ if(EXISTS "${_sdl2test_library}")
|
|||||||
PROPERTIES
|
PROPERTIES
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
|
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIRS}"
|
||||||
IMPORTED_LOCATION "${_sdl2test_library}"
|
IMPORTED_LOCATION "${_sdl2test_library}"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2test_FOUND TRUE)
|
set(SDL2_SDL2test_FOUND TRUE)
|
||||||
|
|||||||
@@ -1,16 +1,6 @@
|
|||||||
|
|
||||||
This is a list of major changes in SDL's version history.
|
This is a list of major changes in SDL's version history.
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
2.28.0:
|
|
||||||
---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
General:
|
|
||||||
* Added SDL_HasWindowSurface() and SDL_DestroyWindowSurface() to switch between the window surface and rendering APIs
|
|
||||||
* Added a display event SDL_DISPLAYEVENT_MOVED which is sent when the primary monitor changes or displays change position relative to each other
|
|
||||||
* Added the hint SDL_HINT_ENABLE_SCREEN_KEYBOARD to control whether the on-screen keyboard should be shown when text input is active
|
|
||||||
|
|
||||||
|
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
2.26.0:
|
2.26.0:
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ initializeTextures(SDL_Renderer *renderer)
|
|||||||
|
|
||||||
/* create ship texture from surface */
|
/* create ship texture from surface */
|
||||||
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
ship = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
||||||
if (ship == NULL) {
|
if (!ship) {
|
||||||
fatalError("could not create ship texture");
|
fatalError("could not create ship texture");
|
||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(ship, SDL_BLENDMODE_BLEND);
|
||||||
@@ -145,7 +145,7 @@ initializeTextures(SDL_Renderer *renderer)
|
|||||||
}
|
}
|
||||||
/* create space texture from surface */
|
/* create space texture from surface */
|
||||||
space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
space = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
||||||
if (space == NULL) {
|
if (!space) {
|
||||||
fatalError("could not create space texture");
|
fatalError("could not create space texture");
|
||||||
}
|
}
|
||||||
SDL_FreeSurface(bmp_surface);
|
SDL_FreeSurface(bmp_surface);
|
||||||
|
|||||||
@@ -84,16 +84,14 @@ stepParticles(double deltaTime)
|
|||||||
/* is the particle actually active, or is it marked for deletion? */
|
/* is the particle actually active, or is it marked for deletion? */
|
||||||
if (curr->isActive) {
|
if (curr->isActive) {
|
||||||
/* is the particle off the screen? */
|
/* is the particle off the screen? */
|
||||||
if (curr->y > screen_h) {
|
if (curr->y > screen_h)
|
||||||
curr->isActive = 0;
|
curr->isActive = 0;
|
||||||
} else if (curr->y < 0) {
|
else if (curr->y < 0)
|
||||||
curr->isActive = 0;
|
curr->isActive = 0;
|
||||||
}
|
if (curr->x > screen_w)
|
||||||
if (curr->x > screen_w) {
|
|
||||||
curr->isActive = 0;
|
curr->isActive = 0;
|
||||||
} else if (curr->x < 0) {
|
else if (curr->x < 0)
|
||||||
curr->isActive = 0;
|
curr->isActive = 0;
|
||||||
}
|
|
||||||
|
|
||||||
/* step velocity, then step position */
|
/* step velocity, then step position */
|
||||||
curr->yvel += ACCEL * deltaMilliseconds;
|
curr->yvel += ACCEL * deltaMilliseconds;
|
||||||
@@ -135,17 +133,15 @@ stepParticles(double deltaTime)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* if we're a dust particle, shrink our size */
|
/* if we're a dust particle, shrink our size */
|
||||||
if (curr->type == dust) {
|
if (curr->type == dust)
|
||||||
curr->size -= deltaMilliseconds * 0.010f;
|
curr->size -= deltaMilliseconds * 0.010f;
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if we're still active, pack ourselves in the array next
|
/* if we're still active, pack ourselves in the array next
|
||||||
to the last active guy (pack the array tightly) */
|
to the last active guy (pack the array tightly) */
|
||||||
if (curr->isActive) {
|
if (curr->isActive)
|
||||||
*(slot++) = *curr;
|
*(slot++) = *curr;
|
||||||
}
|
|
||||||
} /* endif (curr->isActive) */
|
} /* endif (curr->isActive) */
|
||||||
curr++;
|
curr++;
|
||||||
}
|
}
|
||||||
@@ -192,9 +188,8 @@ explodeEmitter(struct particle *emitter)
|
|||||||
int i;
|
int i;
|
||||||
for (i = 0; i < 200; i++) {
|
for (i = 0; i < 200; i++) {
|
||||||
|
|
||||||
if (num_active_particles >= MAX_PARTICLES) {
|
if (num_active_particles >= MAX_PARTICLES)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* come up with a random angle and speed for new particle */
|
/* come up with a random angle and speed for new particle */
|
||||||
float theta = randomFloat(0, 2.0f * 3.141592);
|
float theta = randomFloat(0, 2.0f * 3.141592);
|
||||||
@@ -231,9 +226,8 @@ void
|
|||||||
spawnTrailFromEmitter(struct particle *emitter)
|
spawnTrailFromEmitter(struct particle *emitter)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (num_active_particles >= MAX_PARTICLES) {
|
if (num_active_particles >= MAX_PARTICLES)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* select the particle at the slot at the end of our array */
|
/* select the particle at the slot at the end of our array */
|
||||||
struct particle *p = &particles[num_active_particles];
|
struct particle *p = &particles[num_active_particles];
|
||||||
@@ -268,9 +262,8 @@ void
|
|||||||
spawnEmitterParticle(GLfloat x, GLfloat y)
|
spawnEmitterParticle(GLfloat x, GLfloat y)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (num_active_particles >= MAX_PARTICLES) {
|
if (num_active_particles >= MAX_PARTICLES)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* find particle at endpoint of array */
|
/* find particle at endpoint of array */
|
||||||
struct particle *p = &particles[num_active_particles];
|
struct particle *p = &particles[num_active_particles];
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ initializeTexture(SDL_Renderer *renderer)
|
|||||||
|
|
||||||
/* convert RGBA surface to texture */
|
/* convert RGBA surface to texture */
|
||||||
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
texture = SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
||||||
if (texture == NULL) {
|
if (!texture) {
|
||||||
fatalError("could not create texture");
|
fatalError("could not create texture");
|
||||||
}
|
}
|
||||||
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
SDL_SetTextureBlendMode(texture, SDL_BLENDMODE_BLEND);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ loadFont(void)
|
|||||||
{
|
{
|
||||||
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
|
SDL_Surface *surface = SDL_LoadBMP("kromasky_16x16.bmp");
|
||||||
|
|
||||||
if (surface == NULL) {
|
if (!surface) {
|
||||||
printf("Error loading bitmap: %s\n", SDL_GetError());
|
printf("Error loading bitmap: %s\n", SDL_GetError());
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -183,7 +183,7 @@ loadFont(void)
|
|||||||
SDL_BlitSurface(surface, NULL, converted, NULL);
|
SDL_BlitSurface(surface, NULL, converted, NULL);
|
||||||
/* create our texture */
|
/* create our texture */
|
||||||
texture = SDL_CreateTextureFromSurface(renderer, converted);
|
texture = SDL_CreateTextureFromSurface(renderer, converted);
|
||||||
if (texture == NULL) {
|
if (!texture) {
|
||||||
printf("texture creation failed: %s\n", SDL_GetError());
|
printf("texture creation failed: %s\n", SDL_GetError());
|
||||||
} else {
|
} else {
|
||||||
/* set blend mode for our texture */
|
/* set blend mode for our texture */
|
||||||
|
|||||||
@@ -207,10 +207,10 @@ playSound(struct sound *s)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* if this channel's sound is older than the oldest so far, set it to oldest */
|
/* if this channel's sound is older than the oldest so far, set it to oldest */
|
||||||
if (mixer.channels[i].timestamp < mixer.channels[oldest_channel].timestamp) {
|
if (mixer.channels[i].timestamp <
|
||||||
|
mixer.channels[oldest_channel].timestamp)
|
||||||
oldest_channel = i;
|
oldest_channel = i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/* no empty channels, take the oldest one */
|
/* no empty channels, take the oldest one */
|
||||||
if (selected_channel == -1)
|
if (selected_channel == -1)
|
||||||
|
|||||||
@@ -58,11 +58,11 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* create window and renderer */
|
/* create window and renderer */
|
||||||
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
|
window = SDL_CreateWindow(NULL, 0, 0, 320, 480, SDL_WINDOW_ALLOW_HIGHDPI);
|
||||||
if (window == NULL) {
|
if (!window) {
|
||||||
fatalError("Could not initialize Window");
|
fatalError("Could not initialize Window");
|
||||||
}
|
}
|
||||||
renderer = SDL_CreateRenderer(window, -1, 0);
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
||||||
if (renderer == NULL) {
|
if (!renderer) {
|
||||||
fatalError("Could not create renderer");
|
fatalError("Could not create renderer");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ initializeTexture(SDL_Renderer *renderer)
|
|||||||
brush =
|
brush =
|
||||||
SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
SDL_CreateTextureFromSurface(renderer, bmp_surface);
|
||||||
SDL_FreeSurface(bmp_surface);
|
SDL_FreeSurface(bmp_surface);
|
||||||
if (brush == NULL) {
|
if (!brush) {
|
||||||
fatalError("could not create brush texture");
|
fatalError("could not create brush texture");
|
||||||
}
|
}
|
||||||
/* additive blending -- laying strokes on top of eachother makes them brighter */
|
/* additive blending -- laying strokes on top of eachother makes them brighter */
|
||||||
|
|||||||
@@ -19,10 +19,10 @@
|
|||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>FMWK</string>
|
<string>FMWK</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
<string>2.27.1</string>
|
<string>2.26.5</string>
|
||||||
<key>CFBundleSignature</key>
|
<key>CFBundleSignature</key>
|
||||||
<string>SDLX</string>
|
<string>SDLX</string>
|
||||||
<key>CFBundleVersion</key>
|
<key>CFBundleVersion</key>
|
||||||
<string>2.27.1</string>
|
<string>2.26.5</string>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>
|
</plist>
|
||||||
@@ -9528,8 +9528,8 @@
|
|||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
|
||||||
DEPLOYMENT_POSTPROCESSING = YES;
|
DEPLOYMENT_POSTPROCESSING = YES;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2601.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2601.5.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
GCC_ALTIVEC_EXTENSIONS = YES;
|
GCC_ALTIVEC_EXTENSIONS = YES;
|
||||||
@@ -9570,7 +9570,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||||
MARKETING_VERSION = 2.27.1;
|
MARKETING_VERSION = 2.0.17;
|
||||||
OTHER_LDFLAGS = "-liconv";
|
OTHER_LDFLAGS = "-liconv";
|
||||||
};
|
};
|
||||||
name = Release;
|
name = Release;
|
||||||
@@ -9613,8 +9613,8 @@
|
|||||||
CLANG_WARN_UNREACHABLE_CODE = YES;
|
CLANG_WARN_UNREACHABLE_CODE = YES;
|
||||||
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
|
||||||
DEBUG_INFORMATION_FORMAT = dwarf;
|
DEBUG_INFORMATION_FORMAT = dwarf;
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2601.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2601.5.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
ENABLE_STRICT_OBJC_MSGSEND = YES;
|
||||||
ENABLE_TESTABILITY = YES;
|
ENABLE_TESTABILITY = YES;
|
||||||
@@ -9656,7 +9656,7 @@
|
|||||||
isa = XCBuildConfiguration;
|
isa = XCBuildConfiguration;
|
||||||
buildSettings = {
|
buildSettings = {
|
||||||
CLANG_LINK_OBJC_RUNTIME = NO;
|
CLANG_LINK_OBJC_RUNTIME = NO;
|
||||||
MARKETING_VERSION = 2.27.1;
|
MARKETING_VERSION = 2.0.17;
|
||||||
OTHER_LDFLAGS = "-liconv";
|
OTHER_LDFLAGS = "-liconv";
|
||||||
};
|
};
|
||||||
name = Debug;
|
name = Debug;
|
||||||
@@ -9862,8 +9862,8 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = "";
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2601.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2601.5.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
GCC_DYNAMIC_NO_PIC = NO;
|
GCC_DYNAMIC_NO_PIC = NO;
|
||||||
@@ -9914,8 +9914,8 @@
|
|||||||
CURRENT_PROJECT_VERSION = 1;
|
CURRENT_PROJECT_VERSION = 1;
|
||||||
DEFINES_MODULE = YES;
|
DEFINES_MODULE = YES;
|
||||||
DEVELOPMENT_TEAM = "";
|
DEVELOPMENT_TEAM = "";
|
||||||
DYLIB_COMPATIBILITY_VERSION = 2702.0.0;
|
DYLIB_COMPATIBILITY_VERSION = 2601.0.0;
|
||||||
DYLIB_CURRENT_VERSION = 2702.0.0;
|
DYLIB_CURRENT_VERSION = 2601.5.0;
|
||||||
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
DYLIB_INSTALL_NAME_BASE = "@rpath";
|
||||||
ENABLE_NS_ASSERTIONS = NO;
|
ENABLE_NS_ASSERTIONS = NO;
|
||||||
GCC_C_LANGUAGE_STANDARD = gnu11;
|
GCC_C_LANGUAGE_STANDARD = gnu11;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
Title SDL 2.27.1
|
Title SDL 2.0.0
|
||||||
Version 1
|
Version 1
|
||||||
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
Description SDL Library for Mac OS X (http://www.libsdl.org)
|
||||||
DefaultLocation /Library/Frameworks
|
DefaultLocation /Library/Frameworks
|
||||||
|
|||||||
@@ -57,8 +57,6 @@ if(NOT TARGET SDL2::SDL2)
|
|||||||
INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
|
INTERFACE_LINK_OPTIONS "SHELL:-F \"${SDL2_FRAMEWORK_PARENT_PATH}\";SHELL:-framework SDL2"
|
||||||
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
|
COMPATIBLE_INTERFACE_BOOL "SDL2_SHARED"
|
||||||
INTERFACE_SDL2_SHARED "ON"
|
INTERFACE_SDL2_SHARED "ON"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2_FOUND TRUE)
|
set(SDL2_SDL2_FOUND TRUE)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@ class HIDDeviceBLESteamController extends BluetoothGattCallback implements HIDDe
|
|||||||
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
|
// Because on Chromebooks we show up as a dual-mode device, it will attempt to connect TRANSPORT_AUTO, which will use TRANSPORT_BREDR instead
|
||||||
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
|
// of TRANSPORT_LE. Let's force ourselves to connect low energy.
|
||||||
private BluetoothGatt connectGatt(boolean managed) {
|
private BluetoothGatt connectGatt(boolean managed) {
|
||||||
if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
try {
|
try {
|
||||||
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
|
return mDevice.connectGatt(mManager.getContext(), managed, this, TRANSPORT_LE);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|||||||
@@ -251,8 +251,6 @@ public class HIDDeviceManager {
|
|||||||
0x20d6, // PowerA
|
0x20d6, // PowerA
|
||||||
0x24c6, // PowerA
|
0x24c6, // PowerA
|
||||||
0x2c22, // Qanba
|
0x2c22, // Qanba
|
||||||
0x2dc8, // 8BitDo
|
|
||||||
0x9886, // ASTRO Gaming
|
|
||||||
};
|
};
|
||||||
|
|
||||||
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
if (usbInterface.getInterfaceClass() == UsbConstants.USB_CLASS_VENDOR_SPEC &&
|
||||||
@@ -273,16 +271,14 @@ public class HIDDeviceManager {
|
|||||||
final int XB1_IFACE_SUBCLASS = 71;
|
final int XB1_IFACE_SUBCLASS = 71;
|
||||||
final int XB1_IFACE_PROTOCOL = 208;
|
final int XB1_IFACE_PROTOCOL = 208;
|
||||||
final int[] SUPPORTED_VENDORS = {
|
final int[] SUPPORTED_VENDORS = {
|
||||||
0x044f, // Thrustmaster
|
|
||||||
0x045e, // Microsoft
|
0x045e, // Microsoft
|
||||||
0x0738, // Mad Catz
|
0x0738, // Mad Catz
|
||||||
0x0e6f, // PDP
|
0x0e6f, // PDP
|
||||||
0x0f0d, // Hori
|
0x0f0d, // Hori
|
||||||
0x10f5, // Turtle Beach
|
|
||||||
0x1532, // Razer Wildcat
|
0x1532, // Razer Wildcat
|
||||||
0x20d6, // PowerA
|
0x20d6, // PowerA
|
||||||
0x24c6, // PowerA
|
0x24c6, // PowerA
|
||||||
0x2dc8, // 8BitDo
|
0x2dc8, /* 8BitDo */
|
||||||
0x2e24, // Hyperkin
|
0x2e24, // Hyperkin
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -357,13 +353,13 @@ public class HIDDeviceManager {
|
|||||||
private void initializeBluetooth() {
|
private void initializeBluetooth() {
|
||||||
Log.d(TAG, "Initializing Bluetooth");
|
Log.d(TAG, "Initializing Bluetooth");
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT <= 30 /* Android 11.0 (R) */ &&
|
if (Build.VERSION.SDK_INT <= 30 &&
|
||||||
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
mContext.getPackageManager().checkPermission(android.Manifest.permission.BLUETOOTH, mContext.getPackageName()) != PackageManager.PERMISSION_GRANTED) {
|
||||||
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
|
Log.d(TAG, "Couldn't initialize Bluetooth, missing android.permission.BLUETOOTH");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18 /* Android 4.3 (JELLY_BEAN_MR2) */)) {
|
if (!mContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE) || (Build.VERSION.SDK_INT < 18)) {
|
||||||
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
|
Log.d(TAG, "Couldn't initialize Bluetooth, this version of Android does not support Bluetooth LE");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -577,7 +573,7 @@ public class HIDDeviceManager {
|
|||||||
try {
|
try {
|
||||||
final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
|
final int FLAG_MUTABLE = 0x02000000; // PendingIntent.FLAG_MUTABLE, but don't require SDK 31
|
||||||
int flags;
|
int flags;
|
||||||
if (Build.VERSION.SDK_INT >= 31 /* Android 12.0 (S) */) {
|
if (Build.VERSION.SDK_INT >= 31) {
|
||||||
flags = FLAG_MUTABLE;
|
flags = FLAG_MUTABLE;
|
||||||
} else {
|
} else {
|
||||||
flags = 0;
|
flags = 0;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class HIDDeviceUSB implements HIDDevice {
|
|||||||
@Override
|
@Override
|
||||||
public String getSerialNumber() {
|
public String getSerialNumber() {
|
||||||
String result = null;
|
String result = null;
|
||||||
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
try {
|
try {
|
||||||
result = mDevice.getSerialNumber();
|
result = mDevice.getSerialNumber();
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ class HIDDeviceUSB implements HIDDevice {
|
|||||||
@Override
|
@Override
|
||||||
public String getManufacturerName() {
|
public String getManufacturerName() {
|
||||||
String result = null;
|
String result = null;
|
||||||
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
result = mDevice.getManufacturerName();
|
result = mDevice.getManufacturerName();
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
@@ -86,7 +86,7 @@ class HIDDeviceUSB implements HIDDevice {
|
|||||||
@Override
|
@Override
|
||||||
public String getProductName() {
|
public String getProductName() {
|
||||||
String result = null;
|
String result = null;
|
||||||
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
result = mDevice.getProductName();
|
result = mDevice.getProductName();
|
||||||
}
|
}
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ public class SDL {
|
|||||||
|
|
||||||
// This function stores the current activity (SDL or not)
|
// This function stores the current activity (SDL or not)
|
||||||
public static void setContext(Context context) {
|
public static void setContext(Context context) {
|
||||||
SDLAudioManager.setContext(context);
|
|
||||||
mContext = context;
|
mContext = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ import java.util.Locale;
|
|||||||
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
public class SDLActivity extends Activity implements View.OnSystemUiVisibilityChangeListener {
|
||||||
private static final String TAG = "SDL";
|
private static final String TAG = "SDL";
|
||||||
private static final int SDL_MAJOR_VERSION = 2;
|
private static final int SDL_MAJOR_VERSION = 2;
|
||||||
private static final int SDL_MINOR_VERSION = 27;
|
private static final int SDL_MINOR_VERSION = 26;
|
||||||
private static final int SDL_MICRO_VERSION = 1;
|
private static final int SDL_MICRO_VERSION = 5;
|
||||||
/*
|
/*
|
||||||
// Display InputType.SOURCE/CLASS of events and devices
|
// Display InputType.SOURCE/CLASS of events and devices
|
||||||
//
|
//
|
||||||
@@ -93,7 +93,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
|
|
||||||
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
|
s2 = s_copy & InputDevice.SOURCE_ANY; // keep source only, no class;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 23) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
||||||
tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
|
tst = InputDevice.SOURCE_BLUETOOTH_STYLUS;
|
||||||
if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
|
if ((s & tst) == tst) src += " BLUETOOTH_STYLUS";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
@@ -107,7 +107,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
if ((s & tst) == tst) src += " GAMEPAD";
|
if ((s & tst) == tst) src += " GAMEPAD";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 21) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||||
tst = InputDevice.SOURCE_HDMI;
|
tst = InputDevice.SOURCE_HDMI;
|
||||||
if ((s & tst) == tst) src += " HDMI";
|
if ((s & tst) == tst) src += " HDMI";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
@@ -146,7 +146,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
if ((s & tst) == tst) src += " TOUCHSCREEN";
|
if ((s & tst) == tst) src += " TOUCHSCREEN";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 18) {
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||||
tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
|
tst = InputDevice.SOURCE_TOUCH_NAVIGATION;
|
||||||
if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
|
if ((s & tst) == tst) src += " TOUCH_NAVIGATION";
|
||||||
s2 &= ~tst;
|
s2 &= ~tst;
|
||||||
@@ -170,7 +170,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public static boolean mIsResumedCalled, mHasFocus;
|
public static boolean mIsResumedCalled, mHasFocus;
|
||||||
public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */);
|
public static final boolean mHasMultiWindow = (Build.VERSION.SDK_INT >= 24);
|
||||||
|
|
||||||
// Cursor types
|
// Cursor types
|
||||||
// private static final int SDL_SYSTEM_CURSOR_NONE = -1;
|
// private static final int SDL_SYSTEM_CURSOR_NONE = -1;
|
||||||
@@ -224,9 +224,9 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
|
|
||||||
protected static SDLGenericMotionListener_API12 getMotionListener() {
|
protected static SDLGenericMotionListener_API12 getMotionListener() {
|
||||||
if (mMotionListener == null) {
|
if (mMotionListener == null) {
|
||||||
if (Build.VERSION.SDK_INT >= 26 /* Android 8.0 (O) */) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
mMotionListener = new SDLGenericMotionListener_API26();
|
mMotionListener = new SDLGenericMotionListener_API26();
|
||||||
} else if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
} else if (Build.VERSION.SDK_INT >= 24) {
|
||||||
mMotionListener = new SDLGenericMotionListener_API24();
|
mMotionListener = new SDLGenericMotionListener_API24();
|
||||||
} else {
|
} else {
|
||||||
mMotionListener = new SDLGenericMotionListener_API12();
|
mMotionListener = new SDLGenericMotionListener_API12();
|
||||||
@@ -393,7 +393,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
mHIDDeviceManager = HIDDeviceManager.acquire(this);
|
mHIDDeviceManager = HIDDeviceManager.acquire(this);
|
||||||
|
|
||||||
// Set up the surface
|
// Set up the surface
|
||||||
mSurface = createSDLSurface(this);
|
mSurface = createSDLSurface(getApplication());
|
||||||
|
|
||||||
mLayout = new RelativeLayout(this);
|
mLayout = new RelativeLayout(this);
|
||||||
mLayout.addView(mSurface);
|
mLayout.addView(mSurface);
|
||||||
@@ -404,7 +404,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
SDLActivity.onNativeOrientationChanged(mCurrentOrientation);
|
SDLActivity.onNativeOrientationChanged(mCurrentOrientation);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT < 24) {
|
||||||
mCurrentLocale = getContext().getResources().getConfiguration().locale;
|
mCurrentLocale = getContext().getResources().getConfiguration().locale;
|
||||||
} else {
|
} else {
|
||||||
mCurrentLocale = getContext().getResources().getConfiguration().getLocales().get(0);
|
mCurrentLocale = getContext().getResources().getConfiguration().getLocales().get(0);
|
||||||
@@ -588,8 +588,6 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
mHIDDeviceManager = null;
|
mHIDDeviceManager = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDLAudioManager.release(this);
|
|
||||||
|
|
||||||
if (SDLActivity.mBrokenLibraries) {
|
if (SDLActivity.mBrokenLibraries) {
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
return;
|
return;
|
||||||
@@ -768,7 +766,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case COMMAND_CHANGE_WINDOW_STYLE:
|
case COMMAND_CHANGE_WINDOW_STYLE:
|
||||||
if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
if (context instanceof Activity) {
|
if (context instanceof Activity) {
|
||||||
Window window = ((Activity) context).getWindow();
|
Window window = ((Activity) context).getWindow();
|
||||||
if (window != null) {
|
if (window != null) {
|
||||||
@@ -843,7 +841,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
msg.obj = data;
|
msg.obj = data;
|
||||||
boolean result = commandHandler.sendMessage(msg);
|
boolean result = commandHandler.sendMessage(msg);
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
if (command == COMMAND_CHANGE_WINDOW_STYLE) {
|
if (command == COMMAND_CHANGE_WINDOW_STYLE) {
|
||||||
// Ensure we don't return until the resize has actually happened,
|
// Ensure we don't return until the resize has actually happened,
|
||||||
// or 500ms have passed.
|
// or 500ms have passed.
|
||||||
@@ -971,18 +969,15 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
/* If set, hint "explicitly controls which UI orientations are allowed". */
|
/* If set, hint "explicitly controls which UI orientations are allowed". */
|
||||||
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
|
if (hint.contains("LandscapeRight") && hint.contains("LandscapeLeft")) {
|
||||||
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||||
} else if (hint.contains("LandscapeLeft")) {
|
|
||||||
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
|
||||||
} else if (hint.contains("LandscapeRight")) {
|
} else if (hint.contains("LandscapeRight")) {
|
||||||
|
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||||
|
} else if (hint.contains("LandscapeLeft")) {
|
||||||
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
orientation_landscape = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* exact match to 'Portrait' to distinguish with PortraitUpsideDown */
|
if (hint.contains("Portrait") && hint.contains("PortraitUpsideDown")) {
|
||||||
boolean contains_Portrait = hint.contains("Portrait ") || hint.endsWith("Portrait");
|
|
||||||
|
|
||||||
if (contains_Portrait && hint.contains("PortraitUpsideDown")) {
|
|
||||||
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT;
|
||||||
} else if (contains_Portrait) {
|
} else if (hint.contains("Portrait")) {
|
||||||
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||||
} else if (hint.contains("PortraitUpsideDown")) {
|
} else if (hint.contains("PortraitUpsideDown")) {
|
||||||
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
orientation_portrait = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
||||||
@@ -1095,7 +1090,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
// thus SDK version 27. If we are in DeX mode and not API 27 or higher, as a result,
|
// thus SDK version 27. If we are in DeX mode and not API 27 or higher, as a result,
|
||||||
// we should stick to relative mode.
|
// we should stick to relative mode.
|
||||||
//
|
//
|
||||||
if (Build.VERSION.SDK_INT < 27 /* Android 8.1 (O_MR1) */ && isDeXMode()) {
|
if ((Build.VERSION.SDK_INT < 27) && isDeXMode()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1185,7 +1180,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static boolean isDeXMode() {
|
public static boolean isDeXMode() {
|
||||||
if (Build.VERSION.SDK_INT < 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT < 24) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -1622,7 +1617,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
private final Runnable rehideSystemUi = new Runnable() {
|
private final Runnable rehideSystemUi = new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
|
int flags = View.SYSTEM_UI_FLAG_FULLSCREEN |
|
||||||
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
View.SYSTEM_UI_FLAG_HIDE_NAVIGATION |
|
||||||
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
|
View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY |
|
||||||
@@ -1675,7 +1670,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888);
|
Bitmap bitmap = Bitmap.createBitmap(colors, width, height, Bitmap.Config.ARGB_8888);
|
||||||
++mLastCursorID;
|
++mLastCursorID;
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
try {
|
try {
|
||||||
mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY));
|
mCursors.put(mLastCursorID, PointerIcon.create(bitmap, hotSpotX, hotSpotY));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1691,7 +1686,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static void destroyCustomCursor(int cursorID) {
|
public static void destroyCustomCursor(int cursorID) {
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
try {
|
try {
|
||||||
mCursors.remove(cursorID);
|
mCursors.remove(cursorID);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1705,7 +1700,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
*/
|
*/
|
||||||
public static boolean setCustomCursor(int cursorID) {
|
public static boolean setCustomCursor(int cursorID) {
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
try {
|
try {
|
||||||
mSurface.setPointerIcon(mCursors.get(cursorID));
|
mSurface.setPointerIcon(mCursors.get(cursorID));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1760,7 +1755,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
cursor_type = 1002; //PointerIcon.TYPE_HAND;
|
cursor_type = 1002; //PointerIcon.TYPE_HAND;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
try {
|
try {
|
||||||
mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type));
|
mSurface.setPointerIcon(PointerIcon.getSystemIcon(SDL.getContext(), cursor_type));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
@@ -1774,7 +1769,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static void requestPermission(String permission, int requestCode) {
|
public static void requestPermission(String permission, int requestCode) {
|
||||||
if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
|
if (Build.VERSION.SDK_INT < 23) {
|
||||||
nativePermissionResult(requestCode, true);
|
nativePermissionResult(requestCode, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -1803,7 +1798,7 @@ public class SDLActivity extends Activity implements View.OnSystemUiVisibilityCh
|
|||||||
i.setData(Uri.parse(url));
|
i.setData(Uri.parse(url));
|
||||||
|
|
||||||
int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
|
int flags = Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
|
||||||
if (Build.VERSION.SDK_INT >= 21 /* Android 5.0 (LOLLIPOP) */) {
|
if (Build.VERSION.SDK_INT >= 21) {
|
||||||
flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
|
flags |= Intent.FLAG_ACTIVITY_NEW_DOCUMENT;
|
||||||
} else {
|
} else {
|
||||||
flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
|
flags |= Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET;
|
||||||
@@ -2007,18 +2002,6 @@ class SDLInputConnection extends BaseInputConnection {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
|
||||||
if (Build.VERSION.SDK_INT <= 29 /* Android 10.0 (Q) */) {
|
|
||||||
// Workaround to capture backspace key. Ref: http://stackoverflow.com/questions>/14560344/android-backspace-in-webview-baseinputconnection
|
|
||||||
// and https://bugzilla.libsdl.org/show_bug.cgi?id=2265
|
|
||||||
if (beforeLength > 0 && afterLength == 0) {
|
|
||||||
// backspace(s)
|
|
||||||
while (beforeLength-- > 0) {
|
|
||||||
nativeGenerateScancodeForUnichar('\b');
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!super.deleteSurroundingText(beforeLength, afterLength)) {
|
if (!super.deleteSurroundingText(beforeLength, afterLength)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,5 @@
|
|||||||
package org.libsdl.app;
|
package org.libsdl.app;
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.media.AudioDeviceCallback;
|
|
||||||
import android.media.AudioDeviceInfo;
|
|
||||||
import android.media.AudioFormat;
|
import android.media.AudioFormat;
|
||||||
import android.media.AudioManager;
|
import android.media.AudioManager;
|
||||||
import android.media.AudioRecord;
|
import android.media.AudioRecord;
|
||||||
@@ -11,49 +8,16 @@ import android.media.MediaRecorder;
|
|||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import java.util.Arrays;
|
public class SDLAudioManager
|
||||||
|
{
|
||||||
public class SDLAudioManager {
|
|
||||||
protected static final String TAG = "SDLAudio";
|
protected static final String TAG = "SDLAudio";
|
||||||
|
|
||||||
protected static AudioTrack mAudioTrack;
|
protected static AudioTrack mAudioTrack;
|
||||||
protected static AudioRecord mAudioRecord;
|
protected static AudioRecord mAudioRecord;
|
||||||
protected static Context mContext;
|
|
||||||
|
|
||||||
private static final int[] NO_DEVICES = {};
|
|
||||||
|
|
||||||
private static AudioDeviceCallback mAudioDeviceCallback;
|
|
||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
mAudioTrack = null;
|
mAudioTrack = null;
|
||||||
mAudioRecord = null;
|
mAudioRecord = null;
|
||||||
mAudioDeviceCallback = null;
|
|
||||||
|
|
||||||
if(Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */)
|
|
||||||
{
|
|
||||||
mAudioDeviceCallback = new AudioDeviceCallback() {
|
|
||||||
@Override
|
|
||||||
public void onAudioDevicesAdded(AudioDeviceInfo[] addedDevices) {
|
|
||||||
Arrays.stream(addedDevices).forEach(deviceInfo -> addAudioDevice(deviceInfo.isSink(), deviceInfo.getId()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onAudioDevicesRemoved(AudioDeviceInfo[] removedDevices) {
|
|
||||||
Arrays.stream(removedDevices).forEach(deviceInfo -> removeAudioDevice(deviceInfo.isSink(), deviceInfo.getId()));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setContext(Context context) {
|
|
||||||
mContext = context;
|
|
||||||
if (context != null) {
|
|
||||||
registerAudioDeviceCallback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void release(Context context) {
|
|
||||||
unregisterAudioDeviceCallback(context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
@@ -71,7 +35,7 @@ public class SDLAudioManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
|
protected static int[] open(boolean isCapture, int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||||
int channelConfig;
|
int channelConfig;
|
||||||
int sampleSize;
|
int sampleSize;
|
||||||
int frameSize;
|
int frameSize;
|
||||||
@@ -79,14 +43,14 @@ public class SDLAudioManager {
|
|||||||
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
|
Log.v(TAG, "Opening " + (isCapture ? "capture" : "playback") + ", requested " + desiredFrames + " frames of " + desiredChannels + " channel " + getAudioFormatString(audioFormat) + " audio at " + sampleRate + " Hz");
|
||||||
|
|
||||||
/* On older devices let's use known good settings */
|
/* On older devices let's use known good settings */
|
||||||
if (Build.VERSION.SDK_INT < 21 /* Android 5.0 (LOLLIPOP) */) {
|
if (Build.VERSION.SDK_INT < 21) {
|
||||||
if (desiredChannels > 2) {
|
if (desiredChannels > 2) {
|
||||||
desiredChannels = 2;
|
desiredChannels = 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* AudioTrack has sample rate limitation of 48000 (fixed in 5.0.2) */
|
/* AudioTrack has sample rate limitation of 48000 (fixed in 5.0.2) */
|
||||||
if (Build.VERSION.SDK_INT < 22 /* Android 5.1 (LOLLIPOP_MR1) */) {
|
if (Build.VERSION.SDK_INT < 22) {
|
||||||
if (sampleRate < 8000) {
|
if (sampleRate < 8000) {
|
||||||
sampleRate = 8000;
|
sampleRate = 8000;
|
||||||
} else if (sampleRate > 48000) {
|
} else if (sampleRate > 48000) {
|
||||||
@@ -95,7 +59,7 @@ public class SDLAudioManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
|
if (audioFormat == AudioFormat.ENCODING_PCM_FLOAT) {
|
||||||
int minSDKVersion = (isCapture ? 23 /* Android 6.0 (M) */ : 21 /* Android 5.0 (LOLLIPOP) */);
|
int minSDKVersion = (isCapture ? 23 : 21);
|
||||||
if (Build.VERSION.SDK_INT < minSDKVersion) {
|
if (Build.VERSION.SDK_INT < minSDKVersion) {
|
||||||
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
audioFormat = AudioFormat.ENCODING_PCM_16BIT;
|
||||||
}
|
}
|
||||||
@@ -156,7 +120,7 @@ public class SDLAudioManager {
|
|||||||
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
|
channelConfig = AudioFormat.CHANNEL_OUT_5POINT1 | AudioFormat.CHANNEL_OUT_BACK_CENTER;
|
||||||
break;
|
break;
|
||||||
case 8:
|
case 8:
|
||||||
if (Build.VERSION.SDK_INT >= 23 /* Android 6.0 (M) */) {
|
if (Build.VERSION.SDK_INT >= 23) {
|
||||||
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
channelConfig = AudioFormat.CHANNEL_OUT_7POINT1_SURROUND;
|
||||||
} else {
|
} else {
|
||||||
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
|
Log.v(TAG, "Requested " + desiredChannels + " channels, getting 5.1 surround");
|
||||||
@@ -237,10 +201,6 @@ public class SDLAudioManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */ && deviceId != 0) {
|
|
||||||
mAudioRecord.setPreferredDevice(getOutputAudioDeviceInfo(deviceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
mAudioRecord.startRecording();
|
mAudioRecord.startRecording();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -264,10 +224,6 @@ public class SDLAudioManager {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */ && deviceId != 0) {
|
|
||||||
mAudioTrack.setPreferredDevice(getInputAudioDeviceInfo(deviceId));
|
|
||||||
}
|
|
||||||
|
|
||||||
mAudioTrack.play();
|
mAudioTrack.play();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -282,73 +238,11 @@ public class SDLAudioManager {
|
|||||||
return results;
|
return results;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static AudioDeviceInfo getInputAudioDeviceInfo(int deviceId) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS))
|
|
||||||
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static AudioDeviceInfo getOutputAudioDeviceInfo(int deviceId) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS))
|
|
||||||
.filter(deviceInfo -> deviceInfo.getId() == deviceId)
|
|
||||||
.findFirst()
|
|
||||||
.orElse(null);
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void registerAudioDeviceCallback() {
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
audioManager.registerAudioDeviceCallback(mAudioDeviceCallback, null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void unregisterAudioDeviceCallback(Context context) {
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
|
||||||
AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
audioManager.unregisterAudioDeviceCallback(mAudioDeviceCallback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static int[] getAudioOutputDevices() {
|
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_OUTPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
|
||||||
} else {
|
|
||||||
return NO_DEVICES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called by SDL using JNI.
|
|
||||||
*/
|
|
||||||
public static int[] getAudioInputDevices() {
|
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
|
||||||
AudioManager audioManager = (AudioManager) mContext.getSystemService(Context.AUDIO_SERVICE);
|
|
||||||
return Arrays.stream(audioManager.getDevices(AudioManager.GET_DEVICES_INPUTS)).mapToInt(AudioDeviceInfo::getId).toArray();
|
|
||||||
} else {
|
|
||||||
return NO_DEVICES;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method is called by SDL using JNI.
|
|
||||||
*/
|
|
||||||
public static int[] audioOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
|
|
||||||
return open(false, sampleRate, audioFormat, desiredChannels, desiredFrames, deviceId);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -360,11 +254,6 @@ public class SDLAudioManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (android.os.Build.VERSION.SDK_INT < 21 /* Android 5.0 (LOLLIPOP) */) {
|
|
||||||
Log.e(TAG, "Attempted to make an incompatible audio call with uninitialized audio! (floating-point output is supported since Android 5.0 Lollipop)");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (int i = 0; i < buffer.length;) {
|
for (int i = 0; i < buffer.length;) {
|
||||||
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
|
int result = mAudioTrack.write(buffer, i, buffer.length - i, AudioTrack.WRITE_BLOCKING);
|
||||||
if (result > 0) {
|
if (result > 0) {
|
||||||
@@ -437,22 +326,18 @@ public class SDLAudioManager {
|
|||||||
/**
|
/**
|
||||||
* This method is called by SDL using JNI.
|
* This method is called by SDL using JNI.
|
||||||
*/
|
*/
|
||||||
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames, int deviceId) {
|
public static int[] captureOpen(int sampleRate, int audioFormat, int desiredChannels, int desiredFrames) {
|
||||||
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames, deviceId);
|
return open(true, sampleRate, audioFormat, desiredChannels, desiredFrames);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** This method is called by SDL using JNI. */
|
/** This method is called by SDL using JNI. */
|
||||||
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
|
public static int captureReadFloatBuffer(float[] buffer, boolean blocking) {
|
||||||
if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
|
|
||||||
return 0;
|
|
||||||
} else {
|
|
||||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/** This method is called by SDL using JNI. */
|
/** This method is called by SDL using JNI. */
|
||||||
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
|
public static int captureReadShortBuffer(short[] buffer, boolean blocking) {
|
||||||
if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
|
if (Build.VERSION.SDK_INT < 23) {
|
||||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||||
} else {
|
} else {
|
||||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||||
@@ -461,7 +346,7 @@ public class SDLAudioManager {
|
|||||||
|
|
||||||
/** This method is called by SDL using JNI. */
|
/** This method is called by SDL using JNI. */
|
||||||
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
|
public static int captureReadByteBuffer(byte[] buffer, boolean blocking) {
|
||||||
if (Build.VERSION.SDK_INT < 23 /* Android 6.0 (M) */) {
|
if (Build.VERSION.SDK_INT < 23) {
|
||||||
return mAudioRecord.read(buffer, 0, buffer.length);
|
return mAudioRecord.read(buffer, 0, buffer.length);
|
||||||
} else {
|
} else {
|
||||||
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
return mAudioRecord.read(buffer, 0, buffer.length, blocking ? AudioRecord.READ_BLOCKING : AudioRecord.READ_NON_BLOCKING);
|
||||||
@@ -506,9 +391,4 @@ public class SDLAudioManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static native int nativeSetupJNI();
|
public static native int nativeSetupJNI();
|
||||||
|
|
||||||
public static native void removeAudioDevice(boolean isCapture, int deviceId);
|
|
||||||
|
|
||||||
public static native void addAudioDevice(boolean isCapture, int deviceId);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -24,7 +24,7 @@ public class SDLControllerManager
|
|||||||
public static native int nativeAddJoystick(int device_id, String name, String desc,
|
public static native int nativeAddJoystick(int device_id, String name, String desc,
|
||||||
int vendor_id, int product_id,
|
int vendor_id, int product_id,
|
||||||
boolean is_accelerometer, int button_mask,
|
boolean is_accelerometer, int button_mask,
|
||||||
int naxes, int axis_mask, int nhats, int nballs);
|
int naxes, int nhats, int nballs);
|
||||||
public static native int nativeRemoveJoystick(int device_id);
|
public static native int nativeRemoveJoystick(int device_id);
|
||||||
public static native int nativeAddHaptic(int device_id, String name);
|
public static native int nativeAddHaptic(int device_id, String name);
|
||||||
public static native int nativeRemoveHaptic(int device_id);
|
public static native int nativeRemoveHaptic(int device_id);
|
||||||
@@ -42,7 +42,7 @@ public class SDLControllerManager
|
|||||||
|
|
||||||
public static void initialize() {
|
public static void initialize() {
|
||||||
if (mJoystickHandler == null) {
|
if (mJoystickHandler == null) {
|
||||||
if (Build.VERSION.SDK_INT >= 19 /* Android 4.4 (KITKAT) */) {
|
if (Build.VERSION.SDK_INT >= 19) {
|
||||||
mJoystickHandler = new SDLJoystickHandler_API19();
|
mJoystickHandler = new SDLJoystickHandler_API19();
|
||||||
} else {
|
} else {
|
||||||
mJoystickHandler = new SDLJoystickHandler_API16();
|
mJoystickHandler = new SDLJoystickHandler_API16();
|
||||||
@@ -50,7 +50,7 @@ public class SDLControllerManager
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mHapticHandler == null) {
|
if (mHapticHandler == null) {
|
||||||
if (Build.VERSION.SDK_INT >= 26 /* Android 8.0 (O) */) {
|
if (Build.VERSION.SDK_INT >= 26) {
|
||||||
mHapticHandler = new SDLHapticHandler_API26();
|
mHapticHandler = new SDLHapticHandler_API26();
|
||||||
} else {
|
} else {
|
||||||
mHapticHandler = new SDLHapticHandler();
|
mHapticHandler = new SDLHapticHandler();
|
||||||
@@ -236,7 +236,7 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
|||||||
mJoysticks.add(joystick);
|
mJoysticks.add(joystick);
|
||||||
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc,
|
SDLControllerManager.nativeAddJoystick(joystick.device_id, joystick.name, joystick.desc,
|
||||||
getVendorId(joystickDevice), getProductId(joystickDevice), false,
|
getVendorId(joystickDevice), getProductId(joystickDevice), false,
|
||||||
getButtonMask(joystickDevice), joystick.axes.size(), getAxisMask(joystick.axes), joystick.hats.size()/2, 0);
|
getButtonMask(joystickDevice), joystick.axes.size(), joystick.hats.size()/2, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -317,9 +317,6 @@ class SDLJoystickHandler_API16 extends SDLJoystickHandler {
|
|||||||
public int getVendorId(InputDevice joystickDevice) {
|
public int getVendorId(InputDevice joystickDevice) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
public int getAxisMask(List<InputDevice.MotionRange> ranges) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
public int getButtonMask(InputDevice joystickDevice) {
|
public int getButtonMask(InputDevice joystickDevice) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -337,43 +334,6 @@ class SDLJoystickHandler_API19 extends SDLJoystickHandler_API16 {
|
|||||||
return joystickDevice.getVendorId();
|
return joystickDevice.getVendorId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getAxisMask(List<InputDevice.MotionRange> ranges) {
|
|
||||||
// For compatibility, keep computing the axis mask like before,
|
|
||||||
// only really distinguishing 2, 4 and 6 axes.
|
|
||||||
int axis_mask = 0;
|
|
||||||
if (ranges.size() >= 2) {
|
|
||||||
// ((1 << SDL_GAMEPAD_AXIS_LEFTX) | (1 << SDL_GAMEPAD_AXIS_LEFTY))
|
|
||||||
axis_mask |= 0x0003;
|
|
||||||
}
|
|
||||||
if (ranges.size() >= 4) {
|
|
||||||
// ((1 << SDL_GAMEPAD_AXIS_RIGHTX) | (1 << SDL_GAMEPAD_AXIS_RIGHTY))
|
|
||||||
axis_mask |= 0x000c;
|
|
||||||
}
|
|
||||||
if (ranges.size() >= 6) {
|
|
||||||
// ((1 << SDL_GAMEPAD_AXIS_LEFT_TRIGGER) | (1 << SDL_GAMEPAD_AXIS_RIGHT_TRIGGER))
|
|
||||||
axis_mask |= 0x0030;
|
|
||||||
}
|
|
||||||
// Also add an indicator bit for whether the sorting order has changed.
|
|
||||||
// This serves to disable outdated gamecontrollerdb.txt mappings.
|
|
||||||
boolean have_z = false;
|
|
||||||
boolean have_past_z_before_rz = false;
|
|
||||||
for (InputDevice.MotionRange range : ranges) {
|
|
||||||
int axis = range.getAxis();
|
|
||||||
if (axis == MotionEvent.AXIS_Z) {
|
|
||||||
have_z = true;
|
|
||||||
} else if (axis > MotionEvent.AXIS_Z && axis < MotionEvent.AXIS_RZ) {
|
|
||||||
have_past_z_before_rz = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (have_z && have_past_z_before_rz) {
|
|
||||||
// If both these exist, the compare() function changed sorting order.
|
|
||||||
// Set a bit to indicate this fact.
|
|
||||||
axis_mask |= 0x8000;
|
|
||||||
}
|
|
||||||
return axis_mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getButtonMask(InputDevice joystickDevice) {
|
public int getButtonMask(InputDevice joystickDevice) {
|
||||||
int button_mask = 0;
|
int button_mask = 0;
|
||||||
@@ -809,7 +769,7 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean supportsRelativeMouse() {
|
public boolean supportsRelativeMouse() {
|
||||||
return (!SDLActivity.isDeXMode() || Build.VERSION.SDK_INT >= 27 /* Android 8.1 (O_MR1) */);
|
return (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -819,7 +779,7 @@ class SDLGenericMotionListener_API26 extends SDLGenericMotionListener_API24 {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean setRelativeMouseEnabled(boolean enabled) {
|
public boolean setRelativeMouseEnabled(boolean enabled) {
|
||||||
if (!SDLActivity.isDeXMode() || Build.VERSION.SDK_INT >= 27 /* Android 8.1 (O_MR1) */) {
|
if (!SDLActivity.isDeXMode() || (Build.VERSION.SDK_INT >= 27)) {
|
||||||
if (enabled) {
|
if (enabled) {
|
||||||
SDLActivity.getContentView().requestPointerCapture();
|
SDLActivity.getContentView().requestPointerCapture();
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -116,7 +116,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
int nDeviceHeight = height;
|
int nDeviceHeight = height;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (Build.VERSION.SDK_INT >= 17 /* Android 4.2 (JELLY_BEAN_MR1) */) {
|
if (Build.VERSION.SDK_INT >= 17) {
|
||||||
DisplayMetrics realMetrics = new DisplayMetrics();
|
DisplayMetrics realMetrics = new DisplayMetrics();
|
||||||
mDisplay.getRealMetrics( realMetrics );
|
mDisplay.getRealMetrics( realMetrics );
|
||||||
nDeviceWidth = realMetrics.widthPixels;
|
nDeviceWidth = realMetrics.widthPixels;
|
||||||
@@ -163,7 +163,7 @@ public class SDLSurface extends SurfaceView implements SurfaceHolder.Callback,
|
|||||||
|
|
||||||
// Don't skip in MultiWindow.
|
// Don't skip in MultiWindow.
|
||||||
if (skip) {
|
if (skip) {
|
||||||
if (Build.VERSION.SDK_INT >= 24 /* Android 7.0 (N) */) {
|
if (Build.VERSION.SDK_INT >= 24) {
|
||||||
if (SDLActivity.mSingleton.isInMultiWindowMode()) {
|
if (SDLActivity.mSingleton.isInMultiWindowMode()) {
|
||||||
Log.v("SDL", "Don't skip in Multi-Window");
|
Log.v("SDL", "Don't skip in Multi-Window");
|
||||||
skip = false;
|
skip = false;
|
||||||
|
|||||||
Vendored
+2
-2
@@ -126,8 +126,8 @@ if $cygwin ; then
|
|||||||
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
# Now convert the arguments - kludge to limit ourselves to /bin/sh
|
||||||
i=0
|
i=0
|
||||||
for arg in "$@" ; do
|
for arg in "$@" ; do
|
||||||
CHECK=`echo "$arg"|grep -E -c "$OURCYGPATTERN" -`
|
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
|
||||||
CHECK2=`echo "$arg"|grep -E -c "^-"` ### Determine if an option
|
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
|
||||||
|
|
||||||
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
|
||||||
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
#
|
#
|
||||||
# Build the Android libraries without needing a project
|
# Build the Android libraries without needing a project
|
||||||
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
|
# (AndroidManifest.xml, jni/{Application,Android}.mk, etc.)
|
||||||
|
|||||||
@@ -1,32 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
cd "$(dirname $0)/../src"
|
|
||||||
|
|
||||||
echo "Running clang-format in $(pwd)"
|
|
||||||
|
|
||||||
find . -regex '.*\.[chm]p*' -exec clang-format -i {} \;
|
|
||||||
|
|
||||||
# Revert third-party code
|
|
||||||
git checkout \
|
|
||||||
events/imKStoUCS.* \
|
|
||||||
hidapi \
|
|
||||||
joystick/controller_type.c \
|
|
||||||
joystick/controller_type.h \
|
|
||||||
joystick/hidapi/steam/controller_constants.h \
|
|
||||||
joystick/hidapi/steam/controller_structs.h \
|
|
||||||
libm \
|
|
||||||
stdlib/SDL_malloc.c \
|
|
||||||
stdlib/SDL_qsort.c \
|
|
||||||
stdlib/SDL_strtokr.c \
|
|
||||||
video/arm \
|
|
||||||
video/khronos \
|
|
||||||
video/x11/edid-parse.c \
|
|
||||||
video/yuv2rgb
|
|
||||||
clang-format -i hidapi/SDL_hidapi.c
|
|
||||||
|
|
||||||
# Revert generated code
|
|
||||||
git checkout dynapi/SDL_dynapi_overrides.h
|
|
||||||
git checkout dynapi/SDL_dynapi_procs.h
|
|
||||||
git checkout render/metal/SDL_shaders_metal_*.h
|
|
||||||
|
|
||||||
echo "clang-format complete!"
|
|
||||||
@@ -4,8 +4,6 @@
|
|||||||
|
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd `dirname $0`/..
|
|
||||||
|
|
||||||
ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
|
ref_major=$(sed -ne 's/^#define SDL_MAJOR_VERSION *//p' include/SDL_version.h)
|
||||||
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
|
ref_minor=$(sed -ne 's/^#define SDL_MINOR_VERSION *//p' include/SDL_version.h)
|
||||||
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
|
ref_micro=$(sed -ne 's/^#define SDL_PATCHLEVEL *//p' include/SDL_version.h)
|
||||||
@@ -141,25 +139,6 @@ else
|
|||||||
not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
|
not_ok "Info-Framework.plist CFBundleVersion $version disagrees with SDL_version.h $ref_version"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
version=$(sed -Ene 's/Title SDL (.*)/\1/p' Xcode/SDL/pkg-support/SDL.info)
|
|
||||||
|
|
||||||
if [ "$ref_version" = "$version" ]; then
|
|
||||||
ok "SDL.info Title $version"
|
|
||||||
else
|
|
||||||
not_ok "SDL.info Title $version disagrees with SDL_version.h $ref_version"
|
|
||||||
fi
|
|
||||||
|
|
||||||
marketing=$(sed -Ene 's/.*MARKETING_VERSION = (.*);/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
|
|
||||||
|
|
||||||
ref="$ref_version
|
|
||||||
$ref_version"
|
|
||||||
|
|
||||||
if [ "$ref" = "$marketing" ]; then
|
|
||||||
ok "project.pbxproj MARKETING_VERSION is consistent"
|
|
||||||
else
|
|
||||||
not_ok "project.pbxproj MARKETING_VERSION is inconsistent, expected $ref, got $marketing"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# For simplicity this assumes we'll never break ABI before SDL 3.
|
# For simplicity this assumes we'll never break ABI before SDL 3.
|
||||||
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
|
dylib_compat=$(sed -Ene 's/.*DYLIB_COMPATIBILITY_VERSION = (.*);$/\1/p' Xcode/SDL/SDL.xcodeproj/project.pbxproj)
|
||||||
|
|
||||||
|
|||||||
@@ -30,10 +30,6 @@ echo "Updating version to '$NEWVERSION' ..."
|
|||||||
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
|
# !!! FIXME: This first one is a kinda scary search/replace that might fail later if another X.Y.Z version is added to the file.
|
||||||
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
|
perl -w -pi -e 's/(\<string\>)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/Info-Framework.plist
|
||||||
|
|
||||||
perl -w -pi -e 's/(Title SDL )\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/pkg-support/SDL.info
|
|
||||||
|
|
||||||
perl -w -pi -e 's/(MARKETING_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$NEWVERSION'/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
|
|
||||||
|
|
||||||
DYVER=`expr $MINOR \* 100 + 1`
|
DYVER=`expr $MINOR \* 100 + 1`
|
||||||
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
|
perl -w -pi -e 's/(DYLIB_CURRENT_VERSION\s*=\s*)\d+\.\d+\.\d+/${1}'$DYVER'.0.0/;' Xcode/SDL/SDL.xcodeproj/project.pbxproj
|
||||||
|
|
||||||
|
|||||||
+22
-274
@@ -10,7 +10,6 @@ my $projectfullname = 'Simple Directmedia Layer';
|
|||||||
my $projectshortname = 'SDL';
|
my $projectshortname = 'SDL';
|
||||||
my $wikisubdir = '';
|
my $wikisubdir = '';
|
||||||
my $incsubdir = 'include';
|
my $incsubdir = 'include';
|
||||||
my $readmesubdir = undef;
|
|
||||||
my $apiprefixregex = undef;
|
my $apiprefixregex = undef;
|
||||||
my $versionfname = 'include/SDL_version.h';
|
my $versionfname = 'include/SDL_version.h';
|
||||||
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
my $versionmajorregex = '\A\#define\s+SDL_MAJOR_VERSION\s+(\d+)\Z';
|
||||||
@@ -23,12 +22,10 @@ my $wikiurl = 'https://wiki.libsdl.org';
|
|||||||
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
|
my $bugreporturl = 'https://github.com/libsdl-org/sdlwiki/issues/new';
|
||||||
my $srcpath = undef;
|
my $srcpath = undef;
|
||||||
my $wikipath = undef;
|
my $wikipath = undef;
|
||||||
my $wikireadmesubdir = 'README';
|
|
||||||
my $warn_about_missing = 0;
|
my $warn_about_missing = 0;
|
||||||
my $copy_direction = 0;
|
my $copy_direction = 0;
|
||||||
my $optionsfname = undef;
|
my $optionsfname = undef;
|
||||||
my $wikipreamble = undef;
|
my $wikipreamble = undef;
|
||||||
my $changeformat = undef;
|
|
||||||
|
|
||||||
foreach (@ARGV) {
|
foreach (@ARGV) {
|
||||||
$warn_about_missing = 1, next if $_ eq '--warn-about-missing';
|
$warn_about_missing = 1, next if $_ eq '--warn-about-missing';
|
||||||
@@ -39,9 +36,6 @@ foreach (@ARGV) {
|
|||||||
if (/\A--options=(.*)\Z/) {
|
if (/\A--options=(.*)\Z/) {
|
||||||
$optionsfname = $1;
|
$optionsfname = $1;
|
||||||
next;
|
next;
|
||||||
} elsif (/\A--changeformat=(.*)\Z/) {
|
|
||||||
$changeformat = $1;
|
|
||||||
next;
|
|
||||||
}
|
}
|
||||||
$srcpath = $_, next if not defined $srcpath;
|
$srcpath = $_, next if not defined $srcpath;
|
||||||
$wikipath = $_, next if not defined $wikipath;
|
$wikipath = $_, next if not defined $wikipath;
|
||||||
@@ -73,7 +67,6 @@ if (defined $optionsfname) {
|
|||||||
$projectshortname = $val, next if $key eq 'projectshortname';
|
$projectshortname = $val, next if $key eq 'projectshortname';
|
||||||
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
$wikisubdir = $val, next if $key eq 'wikisubdir';
|
||||||
$incsubdir = $val, next if $key eq 'incsubdir';
|
$incsubdir = $val, next if $key eq 'incsubdir';
|
||||||
$readmesubdir = $val, next if $key eq 'readmesubdir';
|
|
||||||
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
|
$versionmajorregex = $val, next if $key eq 'versionmajorregex';
|
||||||
$versionminorregex = $val, next if $key eq 'versionminorregex';
|
$versionminorregex = $val, next if $key eq 'versionminorregex';
|
||||||
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
|
$versionpatchregex = $val, next if $key eq 'versionpatchregex';
|
||||||
@@ -138,7 +131,6 @@ sub wordwrap_with_bullet_indent { # don't call this directly.
|
|||||||
my $usual_prefix = ' ' x $bulletlen;
|
my $usual_prefix = ' ' x $bulletlen;
|
||||||
|
|
||||||
foreach (@wrappedlines) {
|
foreach (@wrappedlines) {
|
||||||
s/\s*\Z//;
|
|
||||||
$retval .= "$prefix$_\n";
|
$retval .= "$prefix$_\n";
|
||||||
$prefix = $usual_prefix;
|
$prefix = $usual_prefix;
|
||||||
}
|
}
|
||||||
@@ -263,30 +255,10 @@ sub wikify_chunk {
|
|||||||
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
|
$str .= "<syntaxhighlight lang='$codelang'>$code<\/syntaxhighlight>";
|
||||||
}
|
}
|
||||||
} elsif ($wikitype eq 'md') {
|
} elsif ($wikitype eq 'md') {
|
||||||
# convert `code` things first, so they aren't mistaken for other markdown items.
|
|
||||||
my $codedstr = '';
|
|
||||||
while ($str =~ s/\A(.*?)(\`.*?\`)//ms) {
|
|
||||||
my $codeblock = $2;
|
|
||||||
$codedstr .= wikify_chunk($wikitype, $1, undef, undef);
|
|
||||||
if (defined $apiprefixregex) {
|
|
||||||
# Convert obvious API things to wikilinks, even inside `code` blocks,
|
|
||||||
# BUT ONLY IF the entire code block is the API thing,
|
|
||||||
# So something like "just call `SDL_Whatever`" will become
|
|
||||||
# "just call [`SDL_Whatever`](SDL_Whatever)", but
|
|
||||||
# "just call `SDL_Whatever(7)`" will not. It's just the safest
|
|
||||||
# way to do this without resorting to wrapping things in html <code> tags.
|
|
||||||
$codeblock =~ s/\A\`($apiprefixregex[a-zA-Z0-9_]+)\`\Z/[`$1`]($1)/gms;
|
|
||||||
}
|
|
||||||
$codedstr .= $codeblock;
|
|
||||||
}
|
|
||||||
|
|
||||||
# Convert obvious API things to wikilinks.
|
# Convert obvious API things to wikilinks.
|
||||||
if (defined $apiprefixregex) {
|
if (defined $apiprefixregex) {
|
||||||
$str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[$1]($1)/gms;
|
$str =~ s/\b($apiprefixregex[a-zA-Z0-9_]+)/[$1]($1)/gms;
|
||||||
}
|
}
|
||||||
|
|
||||||
$str = $codedstr . $str;
|
|
||||||
|
|
||||||
if (defined $code) {
|
if (defined $code) {
|
||||||
$str .= "```$codelang$code```";
|
$str .= "```$codelang$code```";
|
||||||
}
|
}
|
||||||
@@ -353,11 +325,6 @@ sub dewikify_chunk {
|
|||||||
|
|
||||||
# bullets
|
# bullets
|
||||||
$str =~ s/^\* /- /gm;
|
$str =~ s/^\* /- /gm;
|
||||||
} elsif ($wikitype eq 'md') {
|
|
||||||
# Dump obvious wikilinks. The rest can just passthrough.
|
|
||||||
if (defined $apiprefixregex) {
|
|
||||||
$str =~ s/\[(\`?$apiprefixregex[a-zA-Z0-9_]+\`?)\]\($apiprefixregex[a-zA-Z0-9_]+\)/$1/gms;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $code) {
|
if (defined $code) {
|
||||||
@@ -388,30 +355,6 @@ sub dewikify_chunk {
|
|||||||
|
|
||||||
# bullets
|
# bullets
|
||||||
$str =~ s/^\* /\n\\\(bu /gm;
|
$str =~ s/^\* /\n\\\(bu /gm;
|
||||||
} elsif ($wikitype eq 'md') {
|
|
||||||
# Dump obvious wikilinks.
|
|
||||||
if (defined $apiprefixregex) {
|
|
||||||
$str =~ s/\[(\`?$apiprefixregex[a-zA-Z0-9_]+\`?)\]\($apiprefixregex[a-zA-Z0-9_]+\)/\n.BR $1\n/gms;
|
|
||||||
}
|
|
||||||
|
|
||||||
# links
|
|
||||||
$str =~ s/\[(.*?)]\((https?\:\/\/.*?)\)/\n.URL "$2" "$1"\n/g;
|
|
||||||
|
|
||||||
# <code></code> is also popular. :/
|
|
||||||
$str =~ s/\s*\`(.*?)\`\s*/\n.BR $1\n/gms;
|
|
||||||
|
|
||||||
# bold+italic
|
|
||||||
$str =~ s/\s*\*\*\*(.*?)\*\*\*\s*/\n.BI $1\n/gms;
|
|
||||||
|
|
||||||
# bold
|
|
||||||
$str =~ s/\s*\*\*(.*?)\*\*\s*/\n.B $1\n/gms;
|
|
||||||
|
|
||||||
# italic
|
|
||||||
$str =~ s/\s*\*(.*?)\*\s*/\n.I $1\n/gms;
|
|
||||||
|
|
||||||
# bullets
|
|
||||||
$str =~ s/^\- /\n\\\(bu /gm;
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
die("Unexpected wikitype when converting to manpages\n"); # !!! FIXME: need to handle Markdown wiki pages.
|
die("Unexpected wikitype when converting to manpages\n"); # !!! FIXME: need to handle Markdown wiki pages.
|
||||||
}
|
}
|
||||||
@@ -456,23 +399,6 @@ sub dewikify {
|
|||||||
return $retval;
|
return $retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
sub filecopy {
|
|
||||||
my $src = shift;
|
|
||||||
my $dst = shift;
|
|
||||||
my $endline = shift;
|
|
||||||
$endline = "\n" if not defined $endline;
|
|
||||||
|
|
||||||
open(COPYIN, '<', $src) or die("Failed to open '$src' for reading: $!\n");
|
|
||||||
open(COPYOUT, '>', $dst) or die("Failed to open '$dst' for writing: $!\n");
|
|
||||||
while (<COPYIN>) {
|
|
||||||
chomp;
|
|
||||||
s/[ \t\r\n]*\Z//;
|
|
||||||
print COPYOUT "$_$endline";
|
|
||||||
}
|
|
||||||
close(COPYOUT);
|
|
||||||
close(COPYIN);
|
|
||||||
}
|
|
||||||
|
|
||||||
sub usage {
|
sub usage {
|
||||||
die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n");
|
die("USAGE: $0 <source code git clone path> <wiki git clone path> [--copy-to-headers|--copy-to-wiki|--copy-to-manpages] [--warn-about-missing]\n\n");
|
||||||
}
|
}
|
||||||
@@ -489,7 +415,6 @@ my @standard_wiki_sections = (
|
|||||||
'Function Parameters',
|
'Function Parameters',
|
||||||
'Return Value',
|
'Return Value',
|
||||||
'Remarks',
|
'Remarks',
|
||||||
'Thread Safety',
|
|
||||||
'Version',
|
'Version',
|
||||||
'Code Examples',
|
'Code Examples',
|
||||||
'Related Functions'
|
'Related Functions'
|
||||||
@@ -513,15 +438,9 @@ my %headerfuncshasdoxygen = (); # $headerfuncschunk{"SDL_OpenAudio"} -> 1 if t
|
|||||||
my $incpath = "$srcpath";
|
my $incpath = "$srcpath";
|
||||||
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
$incpath .= "/$incsubdir" if $incsubdir ne '';
|
||||||
|
|
||||||
my $wikireadmepath = "$wikipath/$wikireadmesubdir";
|
|
||||||
my $readmepath = undef;
|
|
||||||
if (defined $readmesubdir) {
|
|
||||||
$readmepath = "$srcpath/$readmesubdir";
|
|
||||||
}
|
|
||||||
|
|
||||||
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
opendir(DH, $incpath) or die("Can't opendir '$incpath': $!\n");
|
||||||
while (my $d = readdir(DH)) {
|
while (readdir(DH)) {
|
||||||
my $dent = $d;
|
my $dent = $_;
|
||||||
next if not $dent =~ /$selectheaderregex/; # just selected headers.
|
next if not $dent =~ /$selectheaderregex/; # just selected headers.
|
||||||
open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n");
|
open(FH, '<', "$incpath/$dent") or die("Can't open '$incpath/$dent': $!\n");
|
||||||
|
|
||||||
@@ -669,8 +588,8 @@ my %wikitypes = (); # contains string of wiki page extension, like $wikitypes{"
|
|||||||
my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}.
|
my %wikifuncs = (); # contains references to hash of strings, each string being the full contents of a section of a wiki page, like $wikifuncs{"SDL_OpenAudio"}{"Remarks"}.
|
||||||
my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks'
|
my %wikisectionorder = (); # contains references to array, each array item being a key to a wikipage section in the correct order, like $wikisectionorder{"SDL_OpenAudio"}[2] == 'Remarks'
|
||||||
opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n");
|
opendir(DH, $wikipath) or die("Can't opendir '$wikipath': $!\n");
|
||||||
while (my $d = readdir(DH)) {
|
while (readdir(DH)) {
|
||||||
my $dent = $d;
|
my $dent = $_;
|
||||||
my $type = '';
|
my $type = '';
|
||||||
if ($dent =~ /\.(md|mediawiki)\Z/) {
|
if ($dent =~ /\.(md|mediawiki)\Z/) {
|
||||||
$type = $1;
|
$type = $1;
|
||||||
@@ -807,14 +726,13 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
||||||
my $wikitype = $wikitypes{$fn};
|
my $wikitype = $wikitypes{$fn};
|
||||||
my $sectionsref = $wikifuncs{$fn};
|
my $sectionsref = $wikifuncs{$fn};
|
||||||
my $remarks = $sectionsref->{'Remarks'};
|
my $remarks = %$sectionsref{'Remarks'};
|
||||||
my $params = $sectionsref->{'Function Parameters'};
|
my $params = %$sectionsref{'Function Parameters'};
|
||||||
my $returns = $sectionsref->{'Return Value'};
|
my $returns = %$sectionsref{'Return Value'};
|
||||||
my $threadsafety = $sectionsref->{'Thread Safety'};
|
my $version = %$sectionsref{'Version'};
|
||||||
my $version = $sectionsref->{'Version'};
|
my $related = %$sectionsref{'Related Functions'};
|
||||||
my $related = $sectionsref->{'Related Functions'};
|
my $deprecated = %$sectionsref{'Deprecated'};
|
||||||
my $deprecated = $sectionsref->{'Deprecated'};
|
my $brief = %$sectionsref{'[Brief]'};
|
||||||
my $brief = $sectionsref->{'[Brief]'};
|
|
||||||
my $addblank = 0;
|
my $addblank = 0;
|
||||||
my $str = '';
|
my $str = '';
|
||||||
|
|
||||||
@@ -879,33 +797,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
$str .= "${whitespace}$_\n";
|
$str .= "${whitespace}$_\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} elsif ($wikitype eq 'md') {
|
|
||||||
my $l;
|
|
||||||
$l = shift @lines;
|
|
||||||
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\|\s*\|\s*\Z/);
|
|
||||||
$l = shift @lines;
|
|
||||||
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\-*\s*\|\s*\-*\s*\|\s*\Z/);
|
|
||||||
while (scalar(@lines) >= 1) {
|
|
||||||
$l = shift @lines;
|
|
||||||
if ($l =~ /\A\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*\Z/) {
|
|
||||||
my $name = $1;
|
|
||||||
my $desc = $2;
|
|
||||||
$name =~ s/\A\*\*(.*?)\*\*/$1/;
|
|
||||||
$name =~ s/\A\'\'\'(.*?)\'\'\'/$1/;
|
|
||||||
#print STDERR "FN: $fn NAME: $name DESC: $desc\n";
|
|
||||||
my $whitespacelen = length($name) + 8;
|
|
||||||
my $whitespace = ' ' x $whitespacelen;
|
|
||||||
$desc = wordwrap($desc, -$whitespacelen);
|
|
||||||
my @desclines = split /\n/, $desc;
|
|
||||||
my $firstline = shift @desclines;
|
|
||||||
$str .= "\\param $name $firstline\n";
|
|
||||||
foreach (@desclines) {
|
|
||||||
$str .= "${whitespace}$_\n";
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
last; # we seem to have run out of table.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
die("write me");
|
die("write me");
|
||||||
}
|
}
|
||||||
@@ -930,21 +821,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $threadsafety) {
|
|
||||||
# !!! FIXME: lots of code duplication in all of these.
|
|
||||||
$str .= "\n" if $addblank; $addblank = 1;
|
|
||||||
my $v = dewikify($wikitype, $threadsafety);
|
|
||||||
my $whitespacelen = length("\\threadsafety") + 1;
|
|
||||||
my $whitespace = ' ' x $whitespacelen;
|
|
||||||
$v = wordwrap($v, -$whitespacelen);
|
|
||||||
my @desclines = split /\n/, $v;
|
|
||||||
my $firstline = shift @desclines;
|
|
||||||
$str .= "\\threadsafety $firstline\n";
|
|
||||||
foreach (@desclines) {
|
|
||||||
$str .= "${whitespace}$_\n";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $version) {
|
if (defined $version) {
|
||||||
# !!! FIXME: lots of code duplication in all of these.
|
# !!! FIXME: lots of code duplication in all of these.
|
||||||
$str .= "\n" if $addblank; $addblank = 1;
|
$str .= "\n" if $addblank; $addblank = 1;
|
||||||
@@ -969,7 +845,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
s/\A(\:|\* )//;
|
s/\A(\:|\* )//;
|
||||||
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
||||||
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
|
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
|
||||||
s/\[(.*?)\]\(.*?\)/$1/; # in case some wikilinks remain.
|
|
||||||
s/\A\/*//;
|
s/\A\/*//;
|
||||||
$str .= "\\sa $_\n";
|
$str .= "\\sa $_\n";
|
||||||
}
|
}
|
||||||
@@ -1030,32 +905,11 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
|
rename($path, "$incpath/$header") or die("Can't rename '$path' to '$incpath/$header': $!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $readmepath) {
|
|
||||||
if ( -d $wikireadmepath ) {
|
|
||||||
mkdir($readmepath); # just in case
|
|
||||||
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
|
|
||||||
while (readdir(DH)) {
|
|
||||||
my $dent = $_;
|
|
||||||
if ($dent =~ /\A(.*?)\.md\Z/) { # we only bridge Markdown files here.
|
|
||||||
next if $1 eq 'FrontPage';
|
|
||||||
filecopy("$wikireadmepath/$dent", "$readmepath/README-$dent", "\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(DH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} elsif ($copy_direction == -1) { # --copy-to-wiki
|
} elsif ($copy_direction == -1) { # --copy-to-wiki
|
||||||
|
|
||||||
if (defined $changeformat) {
|
|
||||||
$dewikify_mode = $changeformat;
|
|
||||||
$wordwrap_mode = $changeformat;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (keys %headerfuncs) {
|
foreach (keys %headerfuncs) {
|
||||||
my $fn = $_;
|
my $fn = $_;
|
||||||
next if not $headerfuncshasdoxygen{$fn};
|
next if not $headerfuncshasdoxygen{$fn};
|
||||||
my $origwikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'md'; # default to MarkDown for new stuff.
|
my $wikitype = defined $wikitypes{$fn} ? $wikitypes{$fn} : 'mediawiki'; # default to MediaWiki for new stuff FOR NOW.
|
||||||
my $wikitype = (defined $changeformat) ? $changeformat : $origwikitype;
|
|
||||||
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md') and ($wikitype ne 'manpage'));
|
die("Unexpected wikitype '$wikitype'\n") if (($wikitype ne 'mediawiki') and ($wikitype ne 'md') and ($wikitype ne 'manpage'));
|
||||||
|
|
||||||
#print("$fn\n"); next;
|
#print("$fn\n"); next;
|
||||||
@@ -1193,21 +1047,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
}
|
}
|
||||||
$desc =~ s/[\s\n]+\Z//ms;
|
$desc =~ s/[\s\n]+\Z//ms;
|
||||||
$sections{'Version'} = wordwrap(wikify($wikitype, $desc)) . "\n";
|
$sections{'Version'} = wordwrap(wikify($wikitype, $desc)) . "\n";
|
||||||
} elsif ($l =~ /\A\\threadsafety\s+(.*)\Z/) {
|
|
||||||
my $desc = $1;
|
|
||||||
while (@doxygenlines) {
|
|
||||||
my $subline = $doxygenlines[0];
|
|
||||||
$subline =~ s/\A\s*//;
|
|
||||||
last if $subline =~ /\A\\/; # some sort of doxygen command, assume we're past this thing.
|
|
||||||
shift @doxygenlines; # dump this line from the array; we're using it.
|
|
||||||
if ($subline eq '') { # empty line, make sure it keeps the newline char.
|
|
||||||
$desc .= "\n";
|
|
||||||
} else {
|
|
||||||
$desc .= " $subline";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$desc =~ s/[\s\n]+\Z//ms;
|
|
||||||
$sections{'Thread Safety'} = wordwrap(wikify($wikitype, $desc)) . "\n";
|
|
||||||
} elsif ($l =~ /\A\\sa\s+(.*)\Z/) {
|
} elsif ($l =~ /\A\\sa\s+(.*)\Z/) {
|
||||||
my $sa = $1;
|
my $sa = $1;
|
||||||
$sa =~ s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
$sa =~ s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
||||||
@@ -1286,25 +1125,8 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
push @$wikisectionorderref, '[footer]';
|
push @$wikisectionorderref, '[footer]';
|
||||||
}
|
}
|
||||||
|
|
||||||
# If changing format, convert things that otherwise are passed through unmolested.
|
|
||||||
if (defined $changeformat) {
|
|
||||||
if (($dewikify_mode eq 'md') and ($origwikitype eq 'mediawiki')) {
|
|
||||||
$$sectionsref{'[footer]'} =~ s/\[\[(Category[a-zA-Z0-9_]+)\]\]/[$1]($1)/g;
|
|
||||||
} elsif (($dewikify_mode eq 'mediawiki') and ($origwikitype eq 'md')) {
|
|
||||||
$$sectionsref{'[footer]'} =~ s/\[(Category[a-zA-Z0-9_]+)\]\(.*?\)/[[$1]]/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (keys %only_wiki_sections) {
|
|
||||||
my $sect = $_;
|
|
||||||
if (defined $$sectionsref{$sect}) {
|
|
||||||
$$sectionsref{$sect} = wikify($wikitype, dewikify($origwikitype, $$sectionsref{$sect}));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
# !!! FIXME: This won't be CategoryAPI if we eventually handle things other than functions.
|
# !!! FIXME: This won't be CategoryAPI if we eventually handle things other than functions.
|
||||||
my $footer = $$sectionsref{'[footer]'};
|
my $footer = $$sectionsref{'[footer]'};
|
||||||
|
|
||||||
if ($wikitype eq 'mediawiki') {
|
if ($wikitype eq 'mediawiki') {
|
||||||
$footer =~ s/\[\[CategoryAPI\]\],?\s*//g;
|
$footer =~ s/\[\[CategoryAPI\]\],?\s*//g;
|
||||||
$footer = '[[CategoryAPI]]' . (($footer eq '') ? "\n" : ", $footer");
|
$footer = '[[CategoryAPI]]' . (($footer eq '') ? "\n" : ", $footer");
|
||||||
@@ -1315,11 +1137,10 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
$$sectionsref{'[footer]'} = $footer;
|
$$sectionsref{'[footer]'} = $footer;
|
||||||
|
|
||||||
if (defined $wikipreamble) {
|
if (defined $wikipreamble) {
|
||||||
my $wikified_preamble = wikify($wikitype, $wikipreamble);
|
|
||||||
if ($wikitype eq 'mediawiki') {
|
if ($wikitype eq 'mediawiki') {
|
||||||
print FH "====== $wikified_preamble ======\n";
|
print FH "====== $wikipreamble ======\n";
|
||||||
} elsif ($wikitype eq 'md') {
|
} elsif ($wikitype eq 'md') {
|
||||||
print FH "###### $wikified_preamble\n";
|
print FH "###### $wikipreamble\n";
|
||||||
} else { die("Unexpected wikitype '$wikitype'\n"); }
|
} else { die("Unexpected wikitype '$wikitype'\n"); }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1364,51 +1185,9 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
|
|
||||||
print FH "\n\n";
|
print FH "\n\n";
|
||||||
close(FH);
|
close(FH);
|
||||||
|
|
||||||
if (defined $changeformat and ($origwikitype ne $wikitype)) {
|
|
||||||
system("cd '$wikipath' ; git mv '$_.${origwikitype}' '$_.${wikitype}'");
|
|
||||||
unlink("$wikipath/$_.${origwikitype}");
|
|
||||||
}
|
|
||||||
|
|
||||||
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
|
rename($path, "$wikipath/$_.${wikitype}") or die("Can't rename '$path' to '$wikipath/$_.${wikitype}': $!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $readmepath) {
|
|
||||||
if ( -d $readmepath ) {
|
|
||||||
mkdir($wikireadmepath); # just in case
|
|
||||||
opendir(DH, $readmepath) or die("Can't opendir '$readmepath': $!\n");
|
|
||||||
while (my $d = readdir(DH)) {
|
|
||||||
my $dent = $d;
|
|
||||||
if ($dent =~ /\AREADME\-(.*?\.md)\Z/) { # we only bridge Markdown files here.
|
|
||||||
my $wikifname = $1;
|
|
||||||
next if $wikifname eq 'FrontPage.md';
|
|
||||||
filecopy("$readmepath/$dent", "$wikireadmepath/$wikifname", "\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(DH);
|
|
||||||
|
|
||||||
my @pages = ();
|
|
||||||
opendir(DH, $wikireadmepath) or die("Can't opendir '$wikireadmepath': $!\n");
|
|
||||||
while (my $d = readdir(DH)) {
|
|
||||||
my $dent = $d;
|
|
||||||
if ($dent =~ /\A(.*?)\.(mediawiki|md)\Z/) {
|
|
||||||
my $wikiname = $1;
|
|
||||||
next if $wikiname eq 'FrontPage';
|
|
||||||
push @pages, $wikiname;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
closedir(DH);
|
|
||||||
|
|
||||||
open(FH, '>', "$wikireadmepath/FrontPage.md") or die("Can't open '$wikireadmepath/FrontPage.md': $!\n");
|
|
||||||
print FH "# All READMEs available here\n\n";
|
|
||||||
foreach (sort @pages) {
|
|
||||||
my $wikiname = $_;
|
|
||||||
print FH "- [$wikiname]($wikiname)\n";
|
|
||||||
}
|
|
||||||
close(FH);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
} elsif ($copy_direction == -2) { # --copy-to-manpages
|
} elsif ($copy_direction == -2) { # --copy-to-manpages
|
||||||
# This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
|
# This only takes from the wiki data, since it has sections we omit from the headers, like code examples.
|
||||||
|
|
||||||
@@ -1456,15 +1235,14 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
next if not defined $wikifuncs{$fn}; # don't have a page for that function, skip it.
|
||||||
my $wikitype = $wikitypes{$fn};
|
my $wikitype = $wikitypes{$fn};
|
||||||
my $sectionsref = $wikifuncs{$fn};
|
my $sectionsref = $wikifuncs{$fn};
|
||||||
my $remarks = $sectionsref->{'Remarks'};
|
my $remarks = %$sectionsref{'Remarks'};
|
||||||
my $params = $sectionsref->{'Function Parameters'};
|
my $params = %$sectionsref{'Function Parameters'};
|
||||||
my $returns = $sectionsref->{'Return Value'};
|
my $returns = %$sectionsref{'Return Value'};
|
||||||
my $version = $sectionsref->{'Version'};
|
my $version = %$sectionsref{'Version'};
|
||||||
my $threadsafety = $sectionsref->{'Thread Safety'};
|
my $related = %$sectionsref{'Related Functions'};
|
||||||
my $related = $sectionsref->{'Related Functions'};
|
my $examples = %$sectionsref{'Code Examples'};
|
||||||
my $examples = $sectionsref->{'Code Examples'};
|
my $deprecated = %$sectionsref{'Deprecated'};
|
||||||
my $deprecated = $sectionsref->{'Deprecated'};
|
my $brief = %$sectionsref{'[Brief]'};
|
||||||
my $brief = $sectionsref->{'[Brief]'};
|
|
||||||
my $decl = $headerdecls{$fn};
|
my $decl = $headerdecls{$fn};
|
||||||
my $str = '';
|
my $str = '';
|
||||||
|
|
||||||
@@ -1551,28 +1329,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
$str .= ".I $name\n";
|
$str .= ".I $name\n";
|
||||||
$str .= "$desc\n";
|
$str .= "$desc\n";
|
||||||
}
|
}
|
||||||
} elsif ($wikitype eq 'md') {
|
|
||||||
my $l;
|
|
||||||
$l = shift @lines;
|
|
||||||
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\|\s*\|\s*\Z/);
|
|
||||||
$l = shift @lines;
|
|
||||||
die("Unexpected data parsing Markdown table") if (not $l =~ /\A\s*\|\s*\-*\s*\|\s*\-*\s*\|\s*\Z/);
|
|
||||||
while (scalar(@lines) >= 1) {
|
|
||||||
$l = shift @lines;
|
|
||||||
if ($l =~ /\A\s*\|\s*(.*?)\s*\|\s*(.*?)\s*\|\s*\Z/) {
|
|
||||||
my $name = $1;
|
|
||||||
my $desc = $2;
|
|
||||||
$name =~ s/\A\*\*(.*?)\*\*/$1/;
|
|
||||||
$name =~ s/\A\'\'\'(.*?)\'\'\'/$1/;
|
|
||||||
$desc = dewikify($wikitype, $desc);
|
|
||||||
|
|
||||||
$str .= ".TP\n";
|
|
||||||
$str .= ".I $name\n";
|
|
||||||
$str .= "$desc\n";
|
|
||||||
} else {
|
|
||||||
last; # we seem to have run out of table.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
die("write me");
|
die("write me");
|
||||||
}
|
}
|
||||||
@@ -1590,11 +1346,6 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
$dewikify_manpage_code_indent = 1;
|
$dewikify_manpage_code_indent = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (defined $threadsafety) {
|
|
||||||
$str .= ".SH THREAD SAFETY\n";
|
|
||||||
$str .= dewikify($wikitype, $threadsafety) . "\n";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (defined $version) {
|
if (defined $version) {
|
||||||
$str .= ".SH AVAILABILITY\n";
|
$str .= ".SH AVAILABILITY\n";
|
||||||
$str .= dewikify($wikitype, $version) . "\n";
|
$str .= dewikify($wikitype, $version) . "\n";
|
||||||
@@ -1610,11 +1361,8 @@ if ($copy_direction == 1) { # --copy-to-headers
|
|||||||
s/\A(\:|\* )//;
|
s/\A(\:|\* )//;
|
||||||
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
s/\(\)\Z//; # Convert "SDL_Func()" to "SDL_Func"
|
||||||
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
|
s/\[\[(.*?)\]\]/$1/; # in case some wikilinks remain.
|
||||||
s/\[(.*?)\]\(.*?\)/$1/; # in case some wikilinks remain.
|
|
||||||
s/\A\*\s*\Z//;
|
|
||||||
s/\A\/*//;
|
s/\A\/*//;
|
||||||
s/\A\.BR\s+//; # dewikify added this, but we want to handle it.
|
s/\A\.BR\s+//; # dewikify added this, but we want to handle it.
|
||||||
s/\A\.I\s+//; # dewikify added this, but we want to handle it.
|
|
||||||
s/\A\s+//;
|
s/\A\s+//;
|
||||||
s/\s+\Z//;
|
s/\s+\Z//;
|
||||||
next if $_ eq '';
|
next if $_ eq '';
|
||||||
|
|||||||
@@ -32,8 +32,6 @@ function(check_cpu_architecture ARCH VARIABLE)
|
|||||||
_internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE})
|
_internal_check_cpu_architecture("defined(__arm__) || defined(_M_ARM)" arm32 ${VARIABLE})
|
||||||
elseif(ARCH STREQUAL "arm64")
|
elseif(ARCH STREQUAL "arm64")
|
||||||
_internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE})
|
_internal_check_cpu_architecture("defined(__aarch64__) || defined(_M_ARM64)" arm64 ${VARIABLE})
|
||||||
elseif(ARCH STREQUAL "loongarch64")
|
|
||||||
_internal_check_cpu_architecture("defined(__loongarch64)" loongarch64 ${VARIABLE})
|
|
||||||
else()
|
else()
|
||||||
message(WARNING "Unknown CPU architectures (${ARCH}).")
|
message(WARNING "Unknown CPU architectures (${ARCH}).")
|
||||||
set(${VARIABLE} FALSE)
|
set(${VARIABLE} FALSE)
|
||||||
|
|||||||
+4
-6
@@ -29,7 +29,7 @@ ENDMACRO()
|
|||||||
|
|
||||||
# Message Output
|
# Message Output
|
||||||
macro(MESSAGE_WARN _TEXT)
|
macro(MESSAGE_WARN _TEXT)
|
||||||
message(WARNING "${_TEXT}")
|
message(STATUS "*** WARNING: ${_TEXT}")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(MESSAGE_ERROR _TEXT)
|
macro(MESSAGE_ERROR _TEXT)
|
||||||
@@ -64,7 +64,7 @@ macro(MESSAGE_TESTED_OPTION _NAME)
|
|||||||
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
|
message(STATUS " ${_NAME}${_PAD}(Wanted: ${_REQVALUE}): ${HAVE_${_STRIPPEDNAME}}")
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
function(LISTTOSTR _LIST _OUTPUT)
|
macro(LISTTOSTR _LIST _OUTPUT)
|
||||||
if(${ARGC} EQUAL 3)
|
if(${ARGC} EQUAL 3)
|
||||||
# prefix for each element
|
# prefix for each element
|
||||||
set(_LPREFIX ${ARGV2})
|
set(_LPREFIX ${ARGV2})
|
||||||
@@ -73,12 +73,10 @@ function(LISTTOSTR _LIST _OUTPUT)
|
|||||||
endif()
|
endif()
|
||||||
# Do not use string(REPLACE ";" " ") here to avoid messing up list
|
# Do not use string(REPLACE ";" " ") here to avoid messing up list
|
||||||
# entries
|
# entries
|
||||||
set(res)
|
|
||||||
foreach(_ITEM ${${_LIST}})
|
foreach(_ITEM ${${_LIST}})
|
||||||
set(res "${res} ${_LPREFIX}${_ITEM}")
|
set(${_OUTPUT} "${${_OUTPUT}} ${_LPREFIX}${_ITEM}")
|
||||||
endforeach()
|
endforeach()
|
||||||
set(${_OUTPUT} "${res}" PARENT_SCOPE)
|
endmacro()
|
||||||
endfunction()
|
|
||||||
|
|
||||||
macro(LISTTOSTRREV _LIST _OUTPUT)
|
macro(LISTTOSTRREV _LIST _OUTPUT)
|
||||||
if(${ARGC} EQUAL 3)
|
if(${ARGC} EQUAL 3)
|
||||||
|
|||||||
+12
-53
@@ -1,5 +1,4 @@
|
|||||||
include(CMakeParseArguments)
|
include(CMakeParseArguments)
|
||||||
include(${SDL2_SOURCE_DIR}/cmake/sdlfind.cmake)
|
|
||||||
macro(FindLibraryAndSONAME _LIB)
|
macro(FindLibraryAndSONAME _LIB)
|
||||||
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
|
cmake_parse_arguments(FLAS "" "" "LIBDIRS" ${ARGN})
|
||||||
|
|
||||||
@@ -7,13 +6,6 @@ macro(FindLibraryAndSONAME _LIB)
|
|||||||
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
|
string(REGEX REPLACE "\\-" "_" _LNAME "${_UPPERLNAME}")
|
||||||
|
|
||||||
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
|
find_library(${_LNAME}_LIB ${_LIB} PATHS ${FLAS_LIBDIRS})
|
||||||
|
|
||||||
if(${_LNAME}_LIB MATCHES ".*\\${CMAKE_SHARED_LIBRARY_SUFFIX}.*" AND NOT ${_LNAME}_LIB MATCHES ".*\\${CMAKE_STATIC_LIBRARY_SUFFIX}.*")
|
|
||||||
set(${_LNAME}_SHARED TRUE)
|
|
||||||
else()
|
|
||||||
set(${_LNAME}_SHARED FALSE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(${_LNAME}_LIB)
|
if(${_LNAME}_LIB)
|
||||||
# reduce the library name for shared linking
|
# reduce the library name for shared linking
|
||||||
|
|
||||||
@@ -91,35 +83,26 @@ endmacro()
|
|||||||
# - HAVE_SDL_LOADSO opt
|
# - HAVE_SDL_LOADSO opt
|
||||||
macro(CheckALSA)
|
macro(CheckALSA)
|
||||||
if(SDL_ALSA)
|
if(SDL_ALSA)
|
||||||
sdlFindALSA()
|
CHECK_INCLUDE_FILE(alsa/asoundlib.h HAVE_ASOUNDLIB_H)
|
||||||
if(ALSA_FOUND)
|
if(HAVE_ASOUNDLIB_H)
|
||||||
file(GLOB ALSA_SOURCES "${SDL2_SOURCE_DIR}/src/audio/alsa/*.c")
|
CHECK_LIBRARY_EXISTS(asound snd_pcm_recover "" HAVE_LIBASOUND)
|
||||||
|
endif()
|
||||||
|
if(HAVE_LIBASOUND)
|
||||||
|
set(HAVE_ALSA TRUE)
|
||||||
|
file(GLOB ALSA_SOURCES ${SDL2_SOURCE_DIR}/src/audio/alsa/*.c)
|
||||||
list(APPEND SOURCE_FILES ${ALSA_SOURCES})
|
list(APPEND SOURCE_FILES ${ALSA_SOURCES})
|
||||||
set(SDL_AUDIO_DRIVER_ALSA 1)
|
set(SDL_AUDIO_DRIVER_ALSA 1)
|
||||||
set(HAVE_ALSA TRUE)
|
if(SDL_ALSA_SHARED AND NOT HAVE_SDL_LOADSO)
|
||||||
set(HAVE_ALSA_SHARED FALSE)
|
message_warn("You must have SDL_LoadObject() support for dynamic ALSA loading")
|
||||||
if(SDL_ALSA_SHARED)
|
endif()
|
||||||
if(HAVE_SDL_LOADSO)
|
|
||||||
FindLibraryAndSONAME("asound")
|
FindLibraryAndSONAME("asound")
|
||||||
if(ASOUND_LIB AND ASOUND_SHARED)
|
if(SDL_ALSA_SHARED AND ASOUND_LIB AND HAVE_SDL_LOADSO)
|
||||||
target_include_directories(sdl-build-options INTERFACE $<TARGET_PROPERTY:ALSA::ALSA,INTERFACE_INCLUDE_DIRECTORIES>)
|
|
||||||
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
|
set(SDL_AUDIO_DRIVER_ALSA_DYNAMIC "\"${ASOUND_LIB_SONAME}\"")
|
||||||
set(HAVE_ALSA_SHARED TRUE)
|
set(HAVE_ALSA_SHARED TRUE)
|
||||||
else()
|
else()
|
||||||
message(WARNING "Unable to find asound shared object")
|
list(APPEND EXTRA_LIBS asound)
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
message(WARNING "You must have SDL_LoadObject() support for dynamic ALSA loading")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
if(NOT HAVE_ALSA_SHARED)
|
|
||||||
list(APPEND CMAKE_DEPENDS ALSA::ALSA)
|
|
||||||
list(APPEND PKGCONFIG_DEPENDS alsa)
|
|
||||||
endif()
|
endif()
|
||||||
set(HAVE_SDL_AUDIO TRUE)
|
set(HAVE_SDL_AUDIO TRUE)
|
||||||
else()
|
|
||||||
set(HAVE_ALSA FALSE)
|
|
||||||
message(WARNING "Unable to found the alsa development library")
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
@@ -734,17 +717,6 @@ macro(CheckWayland)
|
|||||||
else()
|
else()
|
||||||
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
|
list(APPEND EXTRA_LIBS ${PKG_LIBDECOR_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
cmake_push_check_state()
|
|
||||||
list(APPEND CMAKE_REQUIRED_FLAGS ${PKG_LIBDECOR_CFLAGS})
|
|
||||||
list(APPEND CMAKE_REQUIRED_INCLUDES ${PKG_LIBDECOR_INCLUDE_DIRS})
|
|
||||||
list(APPEND CMAKE_REQUIRED_LIBRARIES ${PKG_LIBDECOR_LINK_LIBRARIES})
|
|
||||||
check_symbol_exists(libdecor_frame_get_max_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE)
|
|
||||||
check_symbol_exists(libdecor_frame_get_min_content_size "libdecor.h" HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
|
|
||||||
if(HAVE_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE AND HAVE_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE)
|
|
||||||
set(SDL_HAVE_LIBDECOR_GET_MIN_MAX 1)
|
|
||||||
endif()
|
|
||||||
cmake_pop_check_state()
|
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -1323,16 +1295,3 @@ macro(CheckKMSDRM)
|
|||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
macro(CheckLibUDev)
|
|
||||||
if(SDL_LIBUDEV)
|
|
||||||
check_include_file("libudev.h" have_libudev_header)
|
|
||||||
if(have_libudev_header)
|
|
||||||
set(HAVE_LIBUDEV_H TRUE)
|
|
||||||
FindLibraryAndSONAME(udev)
|
|
||||||
if(UDEV_LIB_SONAME)
|
|
||||||
set(SDL_UDEV_DYNAMIC "\"${UDEV_LIB_SONAME}\"")
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
|
|
||||||
macro(sdlFindALSA)
|
|
||||||
find_package(ALSA MODULE)
|
|
||||||
if(ALSA_FOUND AND (NOT TARGET ALSA::ALSA) )
|
|
||||||
add_Library(ALSA::ALSA UNKNOWN IMPORTED)
|
|
||||||
set_property(TARGET ALSA::ALSA PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ALSA_INCLUDE_DIRS})
|
|
||||||
set_property(TARGET ALSA::ALSA APPEND PROPERTY IMPORTED_LOCATION ${ALSA_LIBRARY})
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
macro(SDL_DetectCMakePlatform)
|
|
||||||
set(SDL_CMAKE_PLATFORM )
|
|
||||||
# Get the platform
|
|
||||||
if(WIN32)
|
|
||||||
set(SDL_CMAKE_PLATFORM WINDOWS)
|
|
||||||
elseif(UNIX AND NOT APPLE)
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES ".*Linux")
|
|
||||||
set(SDL_CMAKE_PLATFORM LINUX)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "kFreeBSD.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM FREEBSD)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "kNetBSD.*|NetBSD.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM NETBSD)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "kOpenBSD.*|OpenBSD.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM OPENBSD)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*GNU.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM GNU)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*BSDI.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM BSDI)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "DragonFly.*|FreeBSD")
|
|
||||||
set(SDL_CMAKE_PLATFORM FREEBSD)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "SYSV5.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM SYSV5)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Solaris.*|SunOS.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM SOLARIS)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "HP-UX.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM HPUX)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "AIX.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM AIX)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Minix.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM MINIX)
|
|
||||||
endif()
|
|
||||||
elseif(APPLE)
|
|
||||||
if(CMAKE_SYSTEM_NAME MATCHES ".*Darwin.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM DARWIN)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*MacOS.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM MACOSX)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*tvOS.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM TVOS)
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES ".*iOS.*")
|
|
||||||
# !!! FIXME: remove the version check when we start requiring >= 3.14.0
|
|
||||||
if(CMAKE_VERSION VERSION_LESS 3.14)
|
|
||||||
set(SDL_CMAKE_PLATFORM IOS)
|
|
||||||
endif()
|
|
||||||
endif()
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "BeOS.*")
|
|
||||||
message_error("BeOS support has been removed as of SDL 2.0.2.")
|
|
||||||
elseif(CMAKE_SYSTEM_NAME MATCHES "Haiku.*")
|
|
||||||
set(SDL_CMAKE_PLATFORM HAIKU)
|
|
||||||
elseif(NINTENDO_3DS)
|
|
||||||
set(SDL_CMAKE_PLATFORM N3DS)
|
|
||||||
endif()
|
|
||||||
if(SDL_CMAKE_PLATFORM)
|
|
||||||
set(${SDL_CMAKE_PLATFORM} TRUE)
|
|
||||||
endif()
|
|
||||||
endmacro()
|
|
||||||
@@ -13,7 +13,7 @@ case "$machine" in
|
|||||||
*android* )
|
*android* )
|
||||||
EXEPREFIX="lib"
|
EXEPREFIX="lib"
|
||||||
EXESUFFIX=".so"
|
EXESUFFIX=".so"
|
||||||
LDFLAGS="$LDFLAGS -shared"
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
EXEPREFIX=""
|
EXEPREFIX=""
|
||||||
@@ -25,20 +25,20 @@ set -e
|
|||||||
|
|
||||||
# Get the canonical path of the folder containing this script
|
# Get the canonical path of the folder containing this script
|
||||||
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
|
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
|
||||||
SDL_CFLAGS="$( pkg-config sdl2 --cflags )"
|
CFLAGS="$( pkg-config sdl2 --cflags )"
|
||||||
SDL_LDFLAGS="$( pkg-config sdl2 --libs )"
|
LDFLAGS="$( pkg-config sdl2 --libs )"
|
||||||
SDL_STATIC_LDFLAGS="$( pkg-config sdl2 --libs --static )"
|
STATIC_LDFLAGS="$( pkg-config sdl2 --libs --static )"
|
||||||
|
|
||||||
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $SDL_CFLAGS $CFLAGS"
|
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_pkgconfig.c.o $CFLAGS $EXTRA_CFLAGS"
|
||||||
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
|
link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS"
|
||||||
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
|
static_link_cmd="$CC main_gui_pkgconfig.c.o -o ${EXEPREFIX}main_gui_pkgconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS"
|
||||||
|
|
||||||
echo "-- CC: $CC"
|
echo "-- CC: $CC"
|
||||||
echo "-- CFLAGS: $CFLAGS"
|
echo "-- CFLAGS: $CFLAGS"
|
||||||
|
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
|
||||||
echo "-- LDFLASG: $LDFLAGS"
|
echo "-- LDFLASG: $LDFLAGS"
|
||||||
echo "-- SDL_CFLAGS: $SDL_CFLAGS"
|
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS"
|
||||||
echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
|
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
|
||||||
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
|
|
||||||
|
|
||||||
echo "-- COMPILE: $compile_cmd"
|
echo "-- COMPILE: $compile_cmd"
|
||||||
echo "-- LINK: $link_cmd"
|
echo "-- LINK: $link_cmd"
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ case "$machine" in
|
|||||||
*android* )
|
*android* )
|
||||||
EXEPREFIX="lib"
|
EXEPREFIX="lib"
|
||||||
EXESUFFIX=".so"
|
EXESUFFIX=".so"
|
||||||
LDFLAGS="$LDFLAGS -shared"
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -shared"
|
||||||
;;
|
;;
|
||||||
* )
|
* )
|
||||||
EXEPREFIX=""
|
EXEPREFIX=""
|
||||||
@@ -25,20 +25,20 @@ set -e
|
|||||||
|
|
||||||
# Get the canonical path of the folder containing this script
|
# Get the canonical path of the folder containing this script
|
||||||
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
|
testdir=$(cd -P -- "$(dirname -- "$0")" && printf '%s\n' "$(pwd -P)")
|
||||||
SDL_CFLAGS="$( sdl2-config --cflags )"
|
CFLAGS="$( sdl2-config --cflags )"
|
||||||
SDL_LDFLAGS="$( sdl2-config --libs )"
|
LDFLAGS="$( sdl2-config --libs )"
|
||||||
SDL_STATIC_LDFLAGS="$( sdl2-config --static-libs )"
|
STATIC_LDFLAGS="$( sdl2-config --static-libs )"
|
||||||
|
|
||||||
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $SDL_CFLAGS"
|
compile_cmd="$CC -c "$testdir/main_gui.c" -o main_gui_sdlconfig.c.o $CFLAGS $EXTRA_CFLAGS"
|
||||||
link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $SDL_LDFLAGS $LDFLAGS"
|
link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig${EXESUFFIX} $LDFLAGS $EXTRA_LDFLAGS"
|
||||||
static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $SDL_STATIC_LDFLAGS $LDFLAGS"
|
static_link_cmd="$CC main_gui_sdlconfig.c.o -o ${EXEPREFIX}main_gui_sdlconfig_static${EXESUFFIX} $STATIC_LDFLAGS $EXTRA_LDFLAGS"
|
||||||
|
|
||||||
echo "-- CC: $CC"
|
echo "-- CC: $CC"
|
||||||
echo "-- CFLAGS: $CFLAGS"
|
echo "-- CFLAGS: $CFLAGS"
|
||||||
|
echo "-- EXTRA_CFLAGS: $EXTRA_CFLAGS"
|
||||||
echo "-- LDFLAGS: $LDFLAGS"
|
echo "-- LDFLAGS: $LDFLAGS"
|
||||||
echo "-- SDL_CFLAGS: $SDL_CFLAGS"
|
echo "-- STATIC_LDFLAGS: $STATIC_LDFLAGS"
|
||||||
echo "-- SDL_LDFLAGS: $SDL_LDFLAGS"
|
echo "-- EXTRA_LDFLAGS: $EXTRA_LDFLAGS"
|
||||||
echo "-- SDL_STATIC_LDFLAGS: $SDL_STATIC_LDFLAGS"
|
|
||||||
|
|
||||||
echo "-- COMPILE: $compile_cmd"
|
echo "-- COMPILE: $compile_cmd"
|
||||||
echo "-- LINK: $link_cmd"
|
echo "-- LINK: $link_cmd"
|
||||||
|
|||||||
@@ -677,7 +677,6 @@ ENABLE_STATIC_TRUE
|
|||||||
ENABLE_SHARED_FALSE
|
ENABLE_SHARED_FALSE
|
||||||
ENABLE_SHARED_TRUE
|
ENABLE_SHARED_TRUE
|
||||||
PKGCONFIG_LIBS_PRIV
|
PKGCONFIG_LIBS_PRIV
|
||||||
PKGCONFIG_DEPENDS
|
|
||||||
SDL_RLD_FLAGS
|
SDL_RLD_FLAGS
|
||||||
SDL_STATIC_LIBS
|
SDL_STATIC_LIBS
|
||||||
SDL_LIBS
|
SDL_LIBS
|
||||||
@@ -2449,58 +2448,6 @@ printf "%s\n" "$ac_res" >&6; }
|
|||||||
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
||||||
|
|
||||||
} # ac_fn_c_check_member
|
} # ac_fn_c_check_member
|
||||||
|
|
||||||
# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR
|
|
||||||
# ------------------------------------------------------------------
|
|
||||||
# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR
|
|
||||||
# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR.
|
|
||||||
ac_fn_check_decl ()
|
|
||||||
{
|
|
||||||
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
|
|
||||||
as_decl_name=`echo $2|sed 's/ *(.*//'`
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5
|
|
||||||
printf %s "checking whether $as_decl_name is declared... " >&6; }
|
|
||||||
if eval test \${$3+y}
|
|
||||||
then :
|
|
||||||
printf %s "(cached) " >&6
|
|
||||||
else $as_nop
|
|
||||||
as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`
|
|
||||||
eval ac_save_FLAGS=\$$6
|
|
||||||
as_fn_append $6 " $5"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
$4
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
#ifndef $as_decl_name
|
|
||||||
#ifdef __cplusplus
|
|
||||||
(void) $as_decl_use;
|
|
||||||
#else
|
|
||||||
(void) $as_decl_name;
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_compile "$LINENO"
|
|
||||||
then :
|
|
||||||
eval "$3=yes"
|
|
||||||
else $as_nop
|
|
||||||
eval "$3=no"
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
||||||
eval $6=\$ac_save_FLAGS
|
|
||||||
|
|
||||||
fi
|
|
||||||
eval ac_res=\$$3
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
|
|
||||||
printf "%s\n" "$ac_res" >&6; }
|
|
||||||
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
|
|
||||||
|
|
||||||
} # ac_fn_check_decl
|
|
||||||
ac_configure_args_raw=
|
ac_configure_args_raw=
|
||||||
for ac_arg
|
for ac_arg
|
||||||
do
|
do
|
||||||
@@ -3506,8 +3453,8 @@ orig_CFLAGS="$CFLAGS"
|
|||||||
|
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
SDL_MAJOR_VERSION=2
|
SDL_MAJOR_VERSION=2
|
||||||
SDL_MINOR_VERSION=27
|
SDL_MINOR_VERSION=26
|
||||||
SDL_MICRO_VERSION=1
|
SDL_MICRO_VERSION=5
|
||||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||||
|
|
||||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||||
@@ -17705,79 +17652,6 @@ printf "%s\n" "$ac_cv_path_EGREP" >&6; }
|
|||||||
EGREP="$ac_cv_path_EGREP"
|
EGREP="$ac_cv_path_EGREP"
|
||||||
|
|
||||||
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
|
|
||||||
printf %s "checking for fgrep... " >&6; }
|
|
||||||
if test ${ac_cv_path_FGREP+y}
|
|
||||||
then :
|
|
||||||
printf %s "(cached) " >&6
|
|
||||||
else $as_nop
|
|
||||||
if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
|
|
||||||
then ac_cv_path_FGREP="$GREP -F"
|
|
||||||
else
|
|
||||||
if test -z "$FGREP"; then
|
|
||||||
ac_path_FGREP_found=false
|
|
||||||
# Loop through the user's path and test for each of PROGNAME-LIST
|
|
||||||
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
|
|
||||||
for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
|
|
||||||
do
|
|
||||||
IFS=$as_save_IFS
|
|
||||||
case $as_dir in #(((
|
|
||||||
'') as_dir=./ ;;
|
|
||||||
*/) ;;
|
|
||||||
*) as_dir=$as_dir/ ;;
|
|
||||||
esac
|
|
||||||
for ac_prog in fgrep
|
|
||||||
do
|
|
||||||
for ac_exec_ext in '' $ac_executable_extensions; do
|
|
||||||
ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext"
|
|
||||||
as_fn_executable_p "$ac_path_FGREP" || continue
|
|
||||||
# Check for GNU ac_path_FGREP and select it if it is found.
|
|
||||||
# Check for GNU $ac_path_FGREP
|
|
||||||
case `"$ac_path_FGREP" --version 2>&1` in
|
|
||||||
*GNU*)
|
|
||||||
ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
|
|
||||||
*)
|
|
||||||
ac_count=0
|
|
||||||
printf %s 0123456789 >"conftest.in"
|
|
||||||
while :
|
|
||||||
do
|
|
||||||
cat "conftest.in" "conftest.in" >"conftest.tmp"
|
|
||||||
mv "conftest.tmp" "conftest.in"
|
|
||||||
cp "conftest.in" "conftest.nl"
|
|
||||||
printf "%s\n" 'FGREP' >> "conftest.nl"
|
|
||||||
"$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
|
|
||||||
diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
|
|
||||||
as_fn_arith $ac_count + 1 && ac_count=$as_val
|
|
||||||
if test $ac_count -gt ${ac_path_FGREP_max-0}; then
|
|
||||||
# Best one so far, save it but keep looking for a better one
|
|
||||||
ac_cv_path_FGREP="$ac_path_FGREP"
|
|
||||||
ac_path_FGREP_max=$ac_count
|
|
||||||
fi
|
|
||||||
# 10*(2^10) chars as input seems more than enough
|
|
||||||
test $ac_count -gt 10 && break
|
|
||||||
done
|
|
||||||
rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
$ac_path_FGREP_found && break 3
|
|
||||||
done
|
|
||||||
done
|
|
||||||
done
|
|
||||||
IFS=$as_save_IFS
|
|
||||||
if test -z "$ac_cv_path_FGREP"; then
|
|
||||||
as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
ac_cv_path_FGREP=$FGREP
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
|
|
||||||
printf "%s\n" "$ac_cv_path_FGREP" >&6; }
|
|
||||||
FGREP="$ac_cv_path_FGREP"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Find a good install program. We prefer a C program (faster),
|
# Find a good install program. We prefer a C program (faster),
|
||||||
# so one script is as good as another. But avoid the broken or
|
# so one script is as good as another. But avoid the broken or
|
||||||
@@ -18418,8 +18292,8 @@ base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
|
|||||||
|
|
||||||
find_lib()
|
find_lib()
|
||||||
{
|
{
|
||||||
gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | $FGREP programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
|
gcc_bin_path=`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
|
||||||
gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | $FGREP libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
|
gcc_lib_path=`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`
|
||||||
env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`
|
env_lib_path=`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`
|
||||||
if test "$cross_compiling" = yes; then
|
if test "$cross_compiling" = yes; then
|
||||||
host_lib_path=""
|
host_lib_path=""
|
||||||
@@ -23225,41 +23099,6 @@ printf "%s\n" "$need_gcc_Wno_multichar" >&6; }
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
CheckUnusedLocalTypedefs()
|
|
||||||
{
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GCC -Wunused-local-typedefs option" >&5
|
|
||||||
printf %s "checking for GCC -Wunused-local-typedefs option... " >&6; }
|
|
||||||
have_gcc_unused_local_typedefs=no
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
int x = 0;
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_compile "$LINENO"
|
|
||||||
then :
|
|
||||||
have_gcc_unused_local_typedefs=yes
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $have_gcc_unused_local_typedefs" >&5
|
|
||||||
printf "%s\n" "$have_gcc_unused_local_typedefs" >&6; }
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
|
|
||||||
if test x$have_gcc_unused_local_typedefs = xyes; then
|
|
||||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
CheckWayland()
|
CheckWayland()
|
||||||
{
|
{
|
||||||
# Check whether --enable-video-wayland was given.
|
# Check whether --enable-video-wayland was given.
|
||||||
@@ -23490,122 +23329,6 @@ printf "%s\n" "#define SDL_VIDEO_DRIVER_WAYLAND_DYNAMIC_LIBDECOR \"$decor_lib\""
|
|||||||
else
|
else
|
||||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
saved_cflags=$CFLAGS
|
|
||||||
CFLAGS="$CFLAGS $DECOR_CFLAGS"
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5
|
|
||||||
printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }
|
|
||||||
if test ${ac_cv_c_undeclared_builtin_options+y}
|
|
||||||
then :
|
|
||||||
printf %s "(cached) " >&6
|
|
||||||
else $as_nop
|
|
||||||
ac_save_CFLAGS=$CFLAGS
|
|
||||||
ac_cv_c_undeclared_builtin_options='cannot detect'
|
|
||||||
for ac_arg in '' -fno-builtin; do
|
|
||||||
CFLAGS="$ac_save_CFLAGS $ac_arg"
|
|
||||||
# This test program should *not* compile successfully.
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
(void) strchr;
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_compile "$LINENO"
|
|
||||||
then :
|
|
||||||
|
|
||||||
else $as_nop
|
|
||||||
# This test program should compile successfully.
|
|
||||||
# No library function is consistently available on
|
|
||||||
# freestanding implementations, so test against a dummy
|
|
||||||
# declaration. Include always-available headers on the
|
|
||||||
# off chance that they somehow elicit warnings.
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
#include <float.h>
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdarg.h>
|
|
||||||
#include <stddef.h>
|
|
||||||
extern void ac_decl (int, char *);
|
|
||||||
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
(void) ac_decl (0, (char *) 0);
|
|
||||||
(void) ac_decl;
|
|
||||||
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_compile "$LINENO"
|
|
||||||
then :
|
|
||||||
if test x"$ac_arg" = x
|
|
||||||
then :
|
|
||||||
ac_cv_c_undeclared_builtin_options='none needed'
|
|
||||||
else $as_nop
|
|
||||||
ac_cv_c_undeclared_builtin_options=$ac_arg
|
|
||||||
fi
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
|
|
||||||
done
|
|
||||||
CFLAGS=$ac_save_CFLAGS
|
|
||||||
|
|
||||||
fi
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5
|
|
||||||
printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; }
|
|
||||||
case $ac_cv_c_undeclared_builtin_options in #(
|
|
||||||
'cannot detect') :
|
|
||||||
{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
|
|
||||||
printf "%s\n" "$as_me: error: in \`$ac_pwd':" >&2;}
|
|
||||||
as_fn_error $? "cannot make $CC report undeclared builtins
|
|
||||||
See \`config.log' for more details" "$LINENO" 5; } ;; #(
|
|
||||||
'none needed') :
|
|
||||||
ac_c_undeclared_builtin_options='' ;; #(
|
|
||||||
*) :
|
|
||||||
ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
ac_fn_check_decl "$LINENO" "libdecor_frame_get_min_content_size" "ac_cv_have_decl_libdecor_frame_get_min_content_size" "#include <libdecor.h>
|
|
||||||
" "$ac_c_undeclared_builtin_options" "CFLAGS"
|
|
||||||
if test "x$ac_cv_have_decl_libdecor_frame_get_min_content_size" = xyes
|
|
||||||
then :
|
|
||||||
ac_have_decl=1
|
|
||||||
else $as_nop
|
|
||||||
ac_have_decl=0
|
|
||||||
fi
|
|
||||||
printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MIN_CONTENT_SIZE $ac_have_decl" >>confdefs.h
|
|
||||||
if test $ac_have_decl = 1
|
|
||||||
then :
|
|
||||||
libdecor_get_min_max=yes
|
|
||||||
fi
|
|
||||||
ac_fn_check_decl "$LINENO" "libdecor_frame_get_max_content_size" "ac_cv_have_decl_libdecor_frame_get_max_content_size" "#include <libdecor.h>
|
|
||||||
" "$ac_c_undeclared_builtin_options" "CFLAGS"
|
|
||||||
if test "x$ac_cv_have_decl_libdecor_frame_get_max_content_size" = xyes
|
|
||||||
then :
|
|
||||||
ac_have_decl=1
|
|
||||||
else $as_nop
|
|
||||||
ac_have_decl=0
|
|
||||||
fi
|
|
||||||
printf "%s\n" "#define HAVE_DECL_LIBDECOR_FRAME_GET_MAX_CONTENT_SIZE $ac_have_decl" >>confdefs.h
|
|
||||||
if test $ac_have_decl = 1
|
|
||||||
then :
|
|
||||||
libdecor_get_min_max=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x$libdecor_get_min_max = xyes; then
|
|
||||||
|
|
||||||
printf "%s\n" "#define SDL_HAVE_LIBDECOR_GET_MIN_MAX 1" >>confdefs.h
|
|
||||||
|
|
||||||
fi
|
|
||||||
CFLAGS="$saved_cflags"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -28439,6 +28162,52 @@ else $as_nop
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$enable_clock_gettime = xyes; then
|
if test x$enable_clock_gettime = xyes; then
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
|
||||||
|
printf %s "checking for clock_gettime in -lrt... " >&6; }
|
||||||
|
if test ${ac_cv_lib_rt_clock_gettime+y}
|
||||||
|
then :
|
||||||
|
printf %s "(cached) " >&6
|
||||||
|
else $as_nop
|
||||||
|
ac_check_lib_save_LIBS=$LIBS
|
||||||
|
LIBS="-lrt $LIBS"
|
||||||
|
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
||||||
|
/* end confdefs.h. */
|
||||||
|
|
||||||
|
/* Override any GCC internal prototype to avoid an error.
|
||||||
|
Use char because int might match the return type of a GCC
|
||||||
|
builtin and then its argument prototype would still apply. */
|
||||||
|
char clock_gettime ();
|
||||||
|
int
|
||||||
|
main (void)
|
||||||
|
{
|
||||||
|
return clock_gettime ();
|
||||||
|
;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
_ACEOF
|
||||||
|
if ac_fn_c_try_link "$LINENO"
|
||||||
|
then :
|
||||||
|
ac_cv_lib_rt_clock_gettime=yes
|
||||||
|
else $as_nop
|
||||||
|
ac_cv_lib_rt_clock_gettime=no
|
||||||
|
fi
|
||||||
|
rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
||||||
|
conftest$ac_exeext conftest.$ac_ext
|
||||||
|
LIBS=$ac_check_lib_save_LIBS
|
||||||
|
fi
|
||||||
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
|
||||||
|
printf "%s\n" "$ac_cv_lib_rt_clock_gettime" >&6; }
|
||||||
|
if test "x$ac_cv_lib_rt_clock_gettime" = xyes
|
||||||
|
then :
|
||||||
|
have_clock_gettime=yes
|
||||||
|
fi
|
||||||
|
|
||||||
|
if test x$have_clock_gettime = xyes; then
|
||||||
|
|
||||||
|
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
|
||||||
|
|
||||||
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
|
||||||
|
else
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5
|
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lc" >&5
|
||||||
printf %s "checking for clock_gettime in -lc... " >&6; }
|
printf %s "checking for clock_gettime in -lc... " >&6; }
|
||||||
if test ${ac_cv_lib_c_clock_gettime+y}
|
if test ${ac_cv_lib_c_clock_gettime+y}
|
||||||
@@ -28483,52 +28252,7 @@ fi
|
|||||||
|
|
||||||
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
|
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
|
||||||
|
|
||||||
else
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for clock_gettime in -lrt" >&5
|
|
||||||
printf %s "checking for clock_gettime in -lrt... " >&6; }
|
|
||||||
if test ${ac_cv_lib_rt_clock_gettime+y}
|
|
||||||
then :
|
|
||||||
printf %s "(cached) " >&6
|
|
||||||
else $as_nop
|
|
||||||
ac_check_lib_save_LIBS=$LIBS
|
|
||||||
LIBS="-lrt $LIBS"
|
|
||||||
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
|
|
||||||
/* end confdefs.h. */
|
|
||||||
|
|
||||||
/* Override any GCC internal prototype to avoid an error.
|
|
||||||
Use char because int might match the return type of a GCC
|
|
||||||
builtin and then its argument prototype would still apply. */
|
|
||||||
char clock_gettime ();
|
|
||||||
int
|
|
||||||
main (void)
|
|
||||||
{
|
|
||||||
return clock_gettime ();
|
|
||||||
;
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
_ACEOF
|
|
||||||
if ac_fn_c_try_link "$LINENO"
|
|
||||||
then :
|
|
||||||
ac_cv_lib_rt_clock_gettime=yes
|
|
||||||
else $as_nop
|
|
||||||
ac_cv_lib_rt_clock_gettime=no
|
|
||||||
fi
|
|
||||||
rm -f core conftest.err conftest.$ac_objext conftest.beam \
|
|
||||||
conftest$ac_exeext conftest.$ac_ext
|
|
||||||
LIBS=$ac_check_lib_save_LIBS
|
|
||||||
fi
|
|
||||||
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_clock_gettime" >&5
|
|
||||||
printf "%s\n" "$ac_cv_lib_rt_clock_gettime" >&6; }
|
|
||||||
if test "x$ac_cv_lib_rt_clock_gettime" = xyes
|
|
||||||
then :
|
|
||||||
have_clock_gettime=yes
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x$have_clock_gettime = xyes; then
|
|
||||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
|
|
||||||
|
|
||||||
printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -28606,7 +28330,6 @@ printf "%s\n" "#define SDL_JOYSTICK_VIRTUAL 1" >>confdefs.h
|
|||||||
}
|
}
|
||||||
|
|
||||||
CheckWarnAll
|
CheckWarnAll
|
||||||
CheckUnusedLocalTypedefs
|
|
||||||
CheckNoStrictAliasing
|
CheckNoStrictAliasing
|
||||||
|
|
||||||
CheckEventSignals
|
CheckEventSignals
|
||||||
@@ -30077,8 +29800,6 @@ done
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
PKGCONFIG_DEPENDS=""
|
|
||||||
|
|
||||||
if test x$enable_shared = xyes; then
|
if test x$enable_shared = xyes; then
|
||||||
PKGCONFIG_LIBS_PRIV="
|
PKGCONFIG_LIBS_PRIV="
|
||||||
Libs.private:"
|
Libs.private:"
|
||||||
|
|||||||
+10
-42
@@ -12,8 +12,8 @@ orig_CFLAGS="$CFLAGS"
|
|||||||
dnl Set various version strings - taken gratefully from the GTk sources
|
dnl Set various version strings - taken gratefully from the GTk sources
|
||||||
# See docs/release_checklist.md
|
# See docs/release_checklist.md
|
||||||
SDL_MAJOR_VERSION=2
|
SDL_MAJOR_VERSION=2
|
||||||
SDL_MINOR_VERSION=27
|
SDL_MINOR_VERSION=26
|
||||||
SDL_MICRO_VERSION=1
|
SDL_MICRO_VERSION=5
|
||||||
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
SDL_VERSION=$SDL_MAJOR_VERSION.$SDL_MINOR_VERSION.$SDL_MICRO_VERSION
|
||||||
|
|
||||||
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
SDL_BINARY_AGE=`expr $SDL_MINOR_VERSION \* 100 + $SDL_MICRO_VERSION`
|
||||||
@@ -62,7 +62,6 @@ AC_PROG_AWK
|
|||||||
AC_PROG_CC
|
AC_PROG_CC
|
||||||
AC_PROG_CXX
|
AC_PROG_CXX
|
||||||
AC_PROG_EGREP
|
AC_PROG_EGREP
|
||||||
AC_PROG_FGREP
|
|
||||||
AC_PROG_INSTALL
|
AC_PROG_INSTALL
|
||||||
AC_PROG_MAKE_SET
|
AC_PROG_MAKE_SET
|
||||||
PKG_PROG_PKG_CONFIG
|
PKG_PROG_PKG_CONFIG
|
||||||
@@ -181,8 +180,8 @@ base_libdir=`echo \${libdir} | sed 's/.*\/\(.*\)/\1/; q'`
|
|||||||
dnl Function to find a library in the compiler search path
|
dnl Function to find a library in the compiler search path
|
||||||
find_lib()
|
find_lib()
|
||||||
{
|
{
|
||||||
gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | $FGREP programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
|
gcc_bin_path=[`$CC -print-search-dirs 2>/dev/null | fgrep programs: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
|
||||||
gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | $FGREP libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
|
gcc_lib_path=[`$CC -print-search-dirs 2>/dev/null | fgrep libraries: | sed 's/[^=]*=\(.*\)/\1/' | sed 's/:/ /g'`]
|
||||||
env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
|
env_lib_path=[`echo $LIBS $LDFLAGS $* | sed 's/-L[ ]*//g'`]
|
||||||
if test "$cross_compiling" = yes; then
|
if test "$cross_compiling" = yes; then
|
||||||
host_lib_path=""
|
host_lib_path=""
|
||||||
@@ -1674,27 +1673,6 @@ dnl Haiku headers use multicharacter constants all over the place. Ignore these
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
dnl See if GCC's -Wunused-local-typedefs is supported and disable it
|
|
||||||
dnl because it triggers on gcc 4.8.4 for compile time asserts inside
|
|
||||||
dnl of functions.
|
|
||||||
CheckUnusedLocalTypedefs()
|
|
||||||
{
|
|
||||||
AC_MSG_CHECKING(for GCC -Wunused-local-typedefs option)
|
|
||||||
have_gcc_unused_local_typedefs=no
|
|
||||||
|
|
||||||
save_CFLAGS="$CFLAGS"
|
|
||||||
CFLAGS="$save_CFLAGS -Wunused-local-typedefs"
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
int x = 0;
|
|
||||||
]],[])], [have_gcc_unused_local_typedefs=yes],[])
|
|
||||||
AC_MSG_RESULT($have_gcc_unused_local_typedefs)
|
|
||||||
CFLAGS="$save_CFLAGS"
|
|
||||||
|
|
||||||
if test x$have_gcc_unused_local_typedefs = xyes; then
|
|
||||||
EXTRA_CFLAGS="$EXTRA_CFLAGS -Wno-unused-local-typedefs"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
dnl Check for Wayland
|
dnl Check for Wayland
|
||||||
CheckWayland()
|
CheckWayland()
|
||||||
{
|
{
|
||||||
@@ -1808,14 +1786,6 @@ dnl See if libdecor is available
|
|||||||
else
|
else
|
||||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS $DECOR_LIBS"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
saved_cflags=$CFLAGS
|
|
||||||
CFLAGS="$CFLAGS $DECOR_CFLAGS"
|
|
||||||
AC_CHECK_DECLS([libdecor_frame_get_min_content_size, libdecor_frame_get_max_content_size], [libdecor_get_min_max=yes], [ ], [[#include <libdecor.h>]])
|
|
||||||
if test x$libdecor_get_min_max = xyes; then
|
|
||||||
AC_DEFINE(SDL_HAVE_LIBDECOR_GET_MIN_MAX, 1, [ ])
|
|
||||||
fi
|
|
||||||
CFLAGS="$saved_cflags"
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -3702,14 +3672,15 @@ CheckClockGettime()
|
|||||||
[AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=yes]])],
|
[AS_HELP_STRING([--enable-clock_gettime], [use clock_gettime() instead of gettimeofday() on UNIX [default=yes]])],
|
||||||
, enable_clock_gettime=yes)
|
, enable_clock_gettime=yes)
|
||||||
if test x$enable_clock_gettime = xyes; then
|
if test x$enable_clock_gettime = xyes; then
|
||||||
|
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
|
||||||
|
if test x$have_clock_gettime = xyes; then
|
||||||
|
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
|
||||||
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
|
||||||
|
else
|
||||||
AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
|
AC_CHECK_LIB(c, clock_gettime, have_clock_gettime=yes)
|
||||||
if test x$have_clock_gettime = xyes; then
|
if test x$have_clock_gettime = xyes; then
|
||||||
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
|
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
|
||||||
else
|
EXTRA_LDFLAGS="$EXTRA_LDFLAGS"
|
||||||
AC_CHECK_LIB(rt, clock_gettime, have_clock_gettime=yes)
|
|
||||||
if test x$have_clock_gettime = xyes; then
|
|
||||||
EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lrt"
|
|
||||||
AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [ ])
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -3767,7 +3738,6 @@ CheckVirtualJoystick()
|
|||||||
|
|
||||||
dnl Do this on all platforms, before everything else (other things might want to override it).
|
dnl Do this on all platforms, before everything else (other things might want to override it).
|
||||||
CheckWarnAll
|
CheckWarnAll
|
||||||
CheckUnusedLocalTypedefs
|
|
||||||
CheckNoStrictAliasing
|
CheckNoStrictAliasing
|
||||||
|
|
||||||
dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.
|
dnl Do this for every platform, but for some it doesn't mean anything, but better to catch it here anyhow.
|
||||||
@@ -4890,8 +4860,6 @@ AC_SUBST(SDL_CFLAGS)
|
|||||||
AC_SUBST(SDL_LIBS)
|
AC_SUBST(SDL_LIBS)
|
||||||
AC_SUBST(SDL_STATIC_LIBS)
|
AC_SUBST(SDL_STATIC_LIBS)
|
||||||
AC_SUBST(SDL_RLD_FLAGS)
|
AC_SUBST(SDL_RLD_FLAGS)
|
||||||
PKGCONFIG_DEPENDS=""
|
|
||||||
AC_SUBST(PKGCONFIG_DEPENDS)
|
|
||||||
if test x$enable_shared = xyes; then
|
if test x$enable_shared = xyes; then
|
||||||
PKGCONFIG_LIBS_PRIV="
|
PKGCONFIG_LIBS_PRIV="
|
||||||
Libs.private:"
|
Libs.private:"
|
||||||
|
|||||||
+7
-15
@@ -68,22 +68,14 @@ Finally, a word of caution: re running androidbuild.sh wipes any changes you may
|
|||||||
done in the build directory for the app!
|
done in the build directory for the app!
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
For more complex projects, follow these instructions:
|
For more complex projects, follow these instructions:
|
||||||
|
|
||||||
1. Get the source code for SDL and copy the 'android-project' directory located at SDL/android-project to a suitable location. Also make sure to rename it to your project name (In these examples: YOURPROJECT).
|
1. Copy the android-project directory wherever you want to keep your projects
|
||||||
|
and rename it to the name of your project.
|
||||||
|
2. Move or symlink this SDL directory into the "<project>/app/jni" directory
|
||||||
|
3. Edit "<project>/app/jni/src/Android.mk" to include your source files
|
||||||
|
|
||||||
(The 'android-project' directory can basically be seen as a sort of starting point for the android-port of your project. It contains the glue code between the Android Java 'frontend' and the SDL code 'backend'. It also contains some standard behaviour, like how events should be handled, which you will be able to change.)
|
4a. If you want to use Android Studio, simply open your <project> directory and start building.
|
||||||
|
|
||||||
2. Move or [symlink](https://en.wikipedia.org/wiki/Symbolic_link) the SDL directory into the "YOURPROJECT/app/jni" directory
|
|
||||||
|
|
||||||
(This is needed as the source of SDL has to be compiled by the Android compiler)
|
|
||||||
|
|
||||||
3. Edit "YOURPROJECT/app/jni/src/Android.mk" to include your source files.
|
|
||||||
|
|
||||||
(They should be separated by spaces after the "LOCAL_SRC_FILES := " declaration)
|
|
||||||
|
|
||||||
4a. If you want to use Android Studio, simply open your 'YOURPROJECT' directory and start building.
|
|
||||||
|
|
||||||
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
4b. If you want to build manually, run './gradlew installDebug' in the project directory. This compiles the .java, creates an .apk with the native code embedded, and installs it on any connected Android device
|
||||||
|
|
||||||
@@ -91,9 +83,9 @@ For more complex projects, follow these instructions:
|
|||||||
If you already have a project that uses CMake, the instructions change somewhat:
|
If you already have a project that uses CMake, the instructions change somewhat:
|
||||||
|
|
||||||
1. Do points 1 and 2 from the instruction above.
|
1. Do points 1 and 2 from the instruction above.
|
||||||
2. Edit "YOURPROJECT/app/build.gradle" to comment out or remove sections containing ndk-build
|
2. Edit "<project>/app/build.gradle" to comment out or remove sections containing ndk-build
|
||||||
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
and uncomment the cmake sections. Add arguments to the CMake invocation as needed.
|
||||||
3. Edit "YOURPROJECT/app/jni/CMakeLists.txt" to include your project (it defaults to
|
3. Edit "<project>/app/jni/CMakeLists.txt" to include your project (it defaults to
|
||||||
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
adding the "src" subdirectory). Note that you'll have SDL2, SDL2main and SDL2-static
|
||||||
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
as targets in your project, so you should have "target_link_libraries(yourgame SDL2 SDL2main)"
|
||||||
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
in your CMakeLists.txt file. Also be aware that you should use add_library() instead of
|
||||||
|
|||||||
@@ -25,4 +25,3 @@ cmake --install build
|
|||||||
- SDL2main should be used to ensure ROMFS is enabled.
|
- SDL2main should be used to ensure ROMFS is enabled.
|
||||||
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
|
- By default, the extra L2 cache and higher clock speeds of the New 2/3DS lineup are enabled. If you wish to turn it off, use `osSetSpeedupEnable(false)` in your main function.
|
||||||
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
|
- `SDL_GetBasePath` returns the romfs root instead of the executable's directory.
|
||||||
- The Nintendo 3DS uses a cooperative threading model on a single core, meaning a thread will never yield unless done manually through the `SDL_Delay` functions, or blocking waits (`SDL_LockMutex`, `SDL_SemWait`, `SDL_CondWait`, `SDL_WaitThread`). To avoid starving other threads, `SDL_SemTryWait` and `SDL_SemWaitTimeout` will yield if they fail to acquire the semaphore, see https://github.com/libsdl-org/SDL/pull/6776 for more information.
|
|
||||||
@@ -249,8 +249,9 @@ typedef void (*SDL_KernelMemoryBarrierFunc)();
|
|||||||
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||||
#define SDL_CPUPauseInstruction() __yield()
|
#define SDL_CPUPauseInstruction() __yield()
|
||||||
#elif defined(__WATCOMC__) && defined(__386__)
|
#elif defined(__WATCOMC__) && defined(__386__)
|
||||||
|
/* watcom assembler rejects PAUSE if CPU < i686, and it refuses REP NOP as an invalid combination. Hardcode the bytes. */
|
||||||
extern __inline void SDL_CPUPauseInstruction(void);
|
extern __inline void SDL_CPUPauseInstruction(void);
|
||||||
#pragma aux SDL_CPUPauseInstruction = ".686p" ".xmm2" "pause"
|
#pragma aux SDL_CPUPauseInstruction = "db 0f3h,90h"
|
||||||
#else
|
#else
|
||||||
#define SDL_CPUPauseInstruction()
|
#define SDL_CPUPauseInstruction()
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ typedef enum
|
|||||||
dstA = dstA */
|
dstA = dstA */
|
||||||
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
|
SDL_BLENDMODE_MUL = 0x00000008, /**< color multiply
|
||||||
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
|
dstRGB = (srcRGB * dstRGB) + (dstRGB * (1-srcA))
|
||||||
dstA = dstA */
|
dstA = (srcA * dstA) + (dstA * (1-srcA)) */
|
||||||
SDL_BLENDMODE_INVALID = 0x7FFFFFFF
|
SDL_BLENDMODE_INVALID = 0x7FFFFFFF
|
||||||
|
|
||||||
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
|
/* Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode() */
|
||||||
|
|||||||
@@ -332,7 +332,6 @@
|
|||||||
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
|
#cmakedefine SDL_INPUT_LINUXEV @SDL_INPUT_LINUXEV@
|
||||||
#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@
|
#cmakedefine SDL_INPUT_LINUXKD @SDL_INPUT_LINUXKD@
|
||||||
#cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@
|
#cmakedefine SDL_INPUT_FBSDKBIO @SDL_INPUT_FBSDKBIO@
|
||||||
#cmakedefine SDL_INPUT_WSCONS @SDL_INPUT_WSCONS@
|
|
||||||
#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@
|
#cmakedefine SDL_JOYSTICK_ANDROID @SDL_JOYSTICK_ANDROID@
|
||||||
#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
|
#cmakedefine SDL_JOYSTICK_HAIKU @SDL_JOYSTICK_HAIKU@
|
||||||
#cmakedefine SDL_JOYSTICK_WGI @SDL_JOYSTICK_WGI@
|
#cmakedefine SDL_JOYSTICK_WGI @SDL_JOYSTICK_WGI@
|
||||||
@@ -360,7 +359,6 @@
|
|||||||
#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@
|
#cmakedefine SDL_HAPTIC_XINPUT @SDL_HAPTIC_XINPUT@
|
||||||
#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@
|
#cmakedefine SDL_HAPTIC_ANDROID @SDL_HAPTIC_ANDROID@
|
||||||
#cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@
|
#cmakedefine SDL_LIBUSB_DYNAMIC @SDL_LIBUSB_DYNAMIC@
|
||||||
#cmakedefine SDL_UDEV_DYNAMIC @SDL_UDEV_DYNAMIC@
|
|
||||||
|
|
||||||
/* Enable various sensor drivers */
|
/* Enable various sensor drivers */
|
||||||
#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
|
#cmakedefine SDL_SENSOR_ANDROID @SDL_SENSOR_ANDROID@
|
||||||
@@ -541,8 +539,6 @@
|
|||||||
#cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@
|
#cmakedefine SDL_VIDEO_VITA_PVR @SDL_VIDEO_VITA_PVR@
|
||||||
#cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@
|
#cmakedefine SDL_VIDEO_VITA_PVR_OGL @SDL_VIDEO_VITA_PVR_OGL@
|
||||||
|
|
||||||
#cmakedefine SDL_HAVE_LIBDECOR_GET_MIN_MAX @SDL_HAVE_LIBDECOR_GET_MIN_MAX@
|
|
||||||
|
|
||||||
#if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
|
#if !defined(HAVE_STDINT_H) && !defined(_STDINT_H_)
|
||||||
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
|
/* Most everything except Visual Studio 2008 and earlier has stdint.h now */
|
||||||
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
#if defined(_MSC_VER) && (_MSC_VER < 1600)
|
||||||
|
|||||||
@@ -491,7 +491,4 @@
|
|||||||
/* Enable dynamic libsamplerate support */
|
/* Enable dynamic libsamplerate support */
|
||||||
#undef SDL_LIBSAMPLERATE_DYNAMIC
|
#undef SDL_LIBSAMPLERATE_DYNAMIC
|
||||||
|
|
||||||
/* Libdecor get min/max content size functions */
|
|
||||||
#undef SDL_HAVE_LIBDECOR_GET_MIN_MAX
|
|
||||||
|
|
||||||
#endif /* SDL_config_h_ */
|
#endif /* SDL_config_h_ */
|
||||||
@@ -209,21 +209,16 @@
|
|||||||
#define SDL_VIDEO_DRIVER_DUMMY 1
|
#define SDL_VIDEO_DRIVER_DUMMY 1
|
||||||
#define SDL_VIDEO_DRIVER_WINDOWS 1
|
#define SDL_VIDEO_DRIVER_WINDOWS 1
|
||||||
|
|
||||||
|
/* #ifndef SDL_VIDEO_RENDER_D3D
|
||||||
|
#define SDL_VIDEO_RENDER_D3D 1
|
||||||
|
#endif*/
|
||||||
|
#if !defined(SDL_VIDEO_RENDER_D3D11) && defined(HAVE_D3D11_H)
|
||||||
|
#define SDL_VIDEO_RENDER_D3D11 1
|
||||||
|
#endif
|
||||||
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
|
#if !defined(SDL_VIDEO_RENDER_D3D12) && defined(HAVE_D3D12_H)
|
||||||
#define SDL_VIDEO_RENDER_D3D12 1
|
#define SDL_VIDEO_RENDER_D3D12 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Enable OpenGL support */
|
|
||||||
#ifndef SDL_VIDEO_OPENGL
|
|
||||||
#define SDL_VIDEO_OPENGL 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_OPENGL_WGL
|
|
||||||
#define SDL_VIDEO_OPENGL_WGL 1
|
|
||||||
#endif
|
|
||||||
#ifndef SDL_VIDEO_RENDER_OGL
|
|
||||||
#define SDL_VIDEO_RENDER_OGL 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Enable system power support */
|
/* Enable system power support */
|
||||||
/*#define SDL_POWER_WINDOWS 1*/
|
/*#define SDL_POWER_WINDOWS 1*/
|
||||||
#define SDL_POWER_HARDWIRED 1
|
#define SDL_POWER_HARDWIRED 1
|
||||||
|
|||||||
@@ -140,7 +140,7 @@ extern "C" {
|
|||||||
|
|
||||||
#if HAS_BUILTIN_BSWAP16
|
#if HAS_BUILTIN_BSWAP16
|
||||||
#define SDL_Swap16(x) __builtin_bswap16(x)
|
#define SDL_Swap16(x) __builtin_bswap16(x)
|
||||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
#pragma intrinsic(_byteswap_ushort)
|
#pragma intrinsic(_byteswap_ushort)
|
||||||
#define SDL_Swap16(x) _byteswap_ushort(x)
|
#define SDL_Swap16(x) _byteswap_ushort(x)
|
||||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||||
@@ -189,7 +189,7 @@ SDL_Swap16(Uint16 x)
|
|||||||
|
|
||||||
#if HAS_BUILTIN_BSWAP32
|
#if HAS_BUILTIN_BSWAP32
|
||||||
#define SDL_Swap32(x) __builtin_bswap32(x)
|
#define SDL_Swap32(x) __builtin_bswap32(x)
|
||||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
#pragma intrinsic(_byteswap_ulong)
|
#pragma intrinsic(_byteswap_ulong)
|
||||||
#define SDL_Swap32(x) _byteswap_ulong(x)
|
#define SDL_Swap32(x) _byteswap_ulong(x)
|
||||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||||
@@ -241,7 +241,7 @@ SDL_Swap32(Uint32 x)
|
|||||||
|
|
||||||
#if HAS_BUILTIN_BSWAP64
|
#if HAS_BUILTIN_BSWAP64
|
||||||
#define SDL_Swap64(x) __builtin_bswap64(x)
|
#define SDL_Swap64(x) __builtin_bswap64(x)
|
||||||
#elif (defined(_MSC_VER) && (_MSC_VER >= 1400)) && !defined(__ICL)
|
#elif defined(_MSC_VER) && (_MSC_VER >= 1400)
|
||||||
#pragma intrinsic(_byteswap_uint64)
|
#pragma intrinsic(_byteswap_uint64)
|
||||||
#define SDL_Swap64(x) _byteswap_uint64(x)
|
#define SDL_Swap64(x) _byteswap_uint64(x)
|
||||||
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
#elif defined(__i386__) && !HAS_BROKEN_BSWAP
|
||||||
|
|||||||
@@ -724,10 +724,10 @@ typedef enum
|
|||||||
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
SDL_CONTROLLER_BUTTON_DPAD_LEFT,
|
||||||
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
SDL_CONTROLLER_BUTTON_DPAD_RIGHT,
|
||||||
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
|
SDL_CONTROLLER_BUTTON_MISC1, /* Xbox Series X share button, PS5 microphone button, Nintendo Switch Pro capture button, Amazon Luna microphone button */
|
||||||
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 (upper left, facing the back) */
|
SDL_CONTROLLER_BUTTON_PADDLE1, /* Xbox Elite paddle P1 */
|
||||||
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 (upper right, facing the back) */
|
SDL_CONTROLLER_BUTTON_PADDLE2, /* Xbox Elite paddle P3 */
|
||||||
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 (lower left, facing the back) */
|
SDL_CONTROLLER_BUTTON_PADDLE3, /* Xbox Elite paddle P2 */
|
||||||
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 (lower right, facing the back) */
|
SDL_CONTROLLER_BUTTON_PADDLE4, /* Xbox Elite paddle P4 */
|
||||||
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
SDL_CONTROLLER_BUTTON_TOUCHPAD, /* PS4/PS5 touchpad button */
|
||||||
SDL_CONTROLLER_BUTTON_MAX
|
SDL_CONTROLLER_BUTTON_MAX
|
||||||
} SDL_GameControllerButton;
|
} SDL_GameControllerButton;
|
||||||
|
|||||||
@@ -377,17 +377,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
|
#define SDL_HINT_EMSCRIPTEN_KEYBOARD_ELEMENT "SDL_EMSCRIPTEN_KEYBOARD_ELEMENT"
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief A variable that controls whether the on-screen keyboard should be shown when text input is active
|
|
||||||
*
|
|
||||||
* The variable can be set to the following values:
|
|
||||||
* "0" - Do not show the on-screen keyboard
|
|
||||||
* "1" - Show the on-screen keyboard
|
|
||||||
*
|
|
||||||
* The default value is "1". This hint must be set before text input is activated.
|
|
||||||
*/
|
|
||||||
#define SDL_HINT_ENABLE_SCREEN_KEYBOARD "SDL_ENABLE_SCREEN_KEYBOARD"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
|
* \brief A variable that controls whether Steam Controllers should be exposed using the SDL joystick and game controller APIs
|
||||||
*
|
*
|
||||||
@@ -1321,8 +1310,6 @@ extern "C" {
|
|||||||
*
|
*
|
||||||
* This variable can be one of the following values:
|
* This variable can be one of the following values:
|
||||||
* "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape"
|
* "primary" (default), "portrait", "landscape", "inverted-portrait", "inverted-landscape"
|
||||||
*
|
|
||||||
* Since SDL 2.0.22 this variable accepts a comma-separated list of values above.
|
|
||||||
*/
|
*/
|
||||||
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION"
|
#define SDL_HINT_QTWAYLAND_CONTENT_ORIENTATION "SDL_QTWAYLAND_CONTENT_ORIENTATION"
|
||||||
|
|
||||||
@@ -1967,28 +1954,6 @@ extern "C" {
|
|||||||
*/
|
*/
|
||||||
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
|
#define SDL_HINT_WINDOWS_DISABLE_THREAD_NAMING "SDL_WINDOWS_DISABLE_THREAD_NAMING"
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Controls whether menus can be opened with their keyboard shortcut (Alt+mnemonic).
|
|
||||||
*
|
|
||||||
* If the mnemonics are enabled, then menus can be opened by pressing the Alt
|
|
||||||
* key and the corresponding mnemonic (for example, Alt+F opens the File menu).
|
|
||||||
* However, in case an invalid mnemonic is pressed, Windows makes an audible
|
|
||||||
* beep to convey that nothing happened. This is true even if the window has
|
|
||||||
* no menu at all!
|
|
||||||
*
|
|
||||||
* Because most SDL applications don't have menus, and some want to use the Alt
|
|
||||||
* key for other purposes, SDL disables mnemonics (and the beeping) by default.
|
|
||||||
*
|
|
||||||
* Note: This also affects keyboard events: with mnemonics enabled, when a
|
|
||||||
* menu is opened from the keyboard, you will not receive a KEYUP event for
|
|
||||||
* the mnemonic key, and *might* not receive one for Alt.
|
|
||||||
*
|
|
||||||
* This variable can be set to the following values:
|
|
||||||
* "0" - Alt+mnemonic does nothing, no beeping. (default)
|
|
||||||
* "1" - Alt+mnemonic opens menus, invalid mnemonics produce a beep.
|
|
||||||
*/
|
|
||||||
#define SDL_HINT_WINDOWS_ENABLE_MENU_MNEMONICS "SDL_WINDOWS_ENABLE_MENU_MNEMONICS"
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief A variable controlling whether the windows message loop is processed by SDL
|
* \brief A variable controlling whether the windows message loop is processed by SDL
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -44,7 +44,6 @@
|
|||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
#include "SDL_guid.h"
|
#include "SDL_guid.h"
|
||||||
#include "SDL_mutex.h"
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
#include "begin_code.h"
|
||||||
/* Set up for C function definitions, even when using C++ */
|
/* Set up for C function definitions, even when using C++ */
|
||||||
@@ -67,9 +66,6 @@ extern "C" {
|
|||||||
/**
|
/**
|
||||||
* The joystick structure used to identify an SDL joystick
|
* The joystick structure used to identify an SDL joystick
|
||||||
*/
|
*/
|
||||||
#ifdef SDL_THREAD_SAFETY_ANALYSIS
|
|
||||||
extern SDL_mutex *SDL_joystick_lock;
|
|
||||||
#endif
|
|
||||||
struct _SDL_Joystick;
|
struct _SDL_Joystick;
|
||||||
typedef struct _SDL_Joystick SDL_Joystick;
|
typedef struct _SDL_Joystick SDL_Joystick;
|
||||||
|
|
||||||
@@ -135,7 +131,7 @@ typedef enum
|
|||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.7.
|
* \since This function is available since SDL 2.0.7.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lock);
|
extern DECLSPEC void SDLCALL SDL_LockJoysticks(void);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -150,7 +146,7 @@ extern DECLSPEC void SDLCALL SDL_LockJoysticks(void) SDL_ACQUIRE(SDL_joystick_lo
|
|||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.7.
|
* \since This function is available since SDL 2.0.7.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void) SDL_RELEASE(SDL_joystick_lock);
|
extern DECLSPEC void SDLCALL SDL_UnlockJoysticks(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Count the number of joysticks attached to the system.
|
* Count the number of joysticks attached to the system.
|
||||||
@@ -288,12 +284,13 @@ extern DECLSPEC SDL_JoystickType SDLCALL SDL_JoystickGetDeviceType(int device_in
|
|||||||
/**
|
/**
|
||||||
* Get the instance ID of a joystick.
|
* Get the instance ID of a joystick.
|
||||||
*
|
*
|
||||||
* This can be called before any joysticks are opened.
|
* This can be called before any joysticks are opened. If the index is out of
|
||||||
|
* range, this function will return -1.
|
||||||
*
|
*
|
||||||
* \param device_index the index of the joystick to query (the N'th joystick
|
* \param device_index the index of the joystick to query (the N'th joystick
|
||||||
* on the system
|
* on the system
|
||||||
* \returns the instance id of the selected joystick. If called on an invalid
|
* \returns the instance id of the selected joystick. If called on an invalid
|
||||||
* index, this function returns -1.
|
* index, this function returns zero
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.6.
|
* \since This function is available since SDL 2.0.6.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
* an SDLK_* constant for those keys that do not generate characters.
|
* an SDLK_* constant for those keys that do not generate characters.
|
||||||
*
|
*
|
||||||
* A special exception is the number keys at the top of the keyboard which
|
* A special exception is the number keys at the top of the keyboard which
|
||||||
* map to SDLK_0...SDLK_9 on AZERTY layouts.
|
* always map to SDLK_0...SDLK_9, regardless of layout.
|
||||||
*/
|
*/
|
||||||
typedef Sint32 SDL_Keycode;
|
typedef Sint32 SDL_Keycode;
|
||||||
|
|
||||||
|
|||||||
@@ -263,13 +263,6 @@ extern DECLSPEC int SDLCALL SDL_UIKitRunApp(int argc, char *argv[], SDL_main_fun
|
|||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved);
|
extern DECLSPEC int SDLCALL SDL_GDKRunApp(SDL_main_func mainFunction, void *reserved);
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback from the application to let the suspend continue.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.28.0.
|
|
||||||
*/
|
|
||||||
extern DECLSPEC void SDLCALL SDL_GDKSuspendComplete(void);
|
|
||||||
|
|
||||||
#endif /* __GDK__ */
|
#endif /* __GDK__ */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+7
-6
@@ -198,9 +198,13 @@ extern DECLSPEC int SDLCALL SDL_WarpMouseGlobal(int x, int y);
|
|||||||
/**
|
/**
|
||||||
* Set relative mouse mode.
|
* Set relative mouse mode.
|
||||||
*
|
*
|
||||||
* While the mouse is in relative mode, the cursor is hidden, the mouse
|
* While the mouse is in relative mode, the cursor is hidden, and the driver
|
||||||
* position is constrained to the window, and SDL will report continuous
|
* will try to report continuous motion in the current window. Only relative
|
||||||
* relative mouse motion even if the mouse is at the edge of the window.
|
* motion events will be delivered, the mouse position will not change.
|
||||||
|
*
|
||||||
|
* Note that this function will not be able to provide continuous relative
|
||||||
|
* motion when used over Microsoft Remote Desktop, instead motion is limited
|
||||||
|
* to the bounds of the screen.
|
||||||
*
|
*
|
||||||
* This function will flush any pending mouse motion.
|
* This function will flush any pending mouse motion.
|
||||||
*
|
*
|
||||||
@@ -385,9 +389,6 @@ extern DECLSPEC SDL_Cursor *SDLCALL SDL_GetCursor(void);
|
|||||||
/**
|
/**
|
||||||
* Get the default cursor.
|
* Get the default cursor.
|
||||||
*
|
*
|
||||||
* You do not have to call SDL_FreeCursor() on the return value, but it is
|
|
||||||
* safe to do so.
|
|
||||||
*
|
|
||||||
* \returns the default cursor on success or NULL on failure.
|
* \returns the default cursor on success or NULL on failure.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
|
|||||||
+5
-79
@@ -31,80 +31,6 @@
|
|||||||
#include "SDL_stdinc.h"
|
#include "SDL_stdinc.h"
|
||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
/* Enable thread safety attributes only with clang.
|
|
||||||
* The attributes can be safely erased when compiling with other compilers.
|
|
||||||
*/
|
|
||||||
#if defined(SDL_THREAD_SAFETY_ANALYSIS) && \
|
|
||||||
defined(__clang__) && (!defined(SWIG))
|
|
||||||
#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
|
|
||||||
#else
|
|
||||||
#define SDL_THREAD_ANNOTATION_ATTRIBUTE__(x) /* no-op */
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SDL_CAPABILITY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(capability(x))
|
|
||||||
|
|
||||||
#define SDL_SCOPED_CAPABILITY \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(scoped_lockable)
|
|
||||||
|
|
||||||
#define SDL_GUARDED_BY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
|
|
||||||
|
|
||||||
#define SDL_PT_GUARDED_BY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(pt_guarded_by(x))
|
|
||||||
|
|
||||||
#define SDL_ACQUIRED_BEFORE(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_before(x))
|
|
||||||
|
|
||||||
#define SDL_ACQUIRED_AFTER(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquired_after(x))
|
|
||||||
|
|
||||||
#define SDL_REQUIRES(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_capability(x))
|
|
||||||
|
|
||||||
#define SDL_REQUIRES_SHARED(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(requires_shared_capability(x))
|
|
||||||
|
|
||||||
#define SDL_ACQUIRE(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_capability(x))
|
|
||||||
|
|
||||||
#define SDL_ACQUIRE_SHARED(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(acquire_shared_capability(x))
|
|
||||||
|
|
||||||
#define SDL_RELEASE(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_capability(x))
|
|
||||||
|
|
||||||
#define SDL_RELEASE_SHARED(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_shared_capability(x))
|
|
||||||
|
|
||||||
#define SDL_RELEASE_GENERIC(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(release_generic_capability(x))
|
|
||||||
|
|
||||||
#define SDL_TRY_ACQUIRE(x, y) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_capability(x, y))
|
|
||||||
|
|
||||||
#define SDL_TRY_ACQUIRE_SHARED(x, y) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(try_acquire_shared_capability(x, y))
|
|
||||||
|
|
||||||
#define SDL_EXCLUDES(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(locks_excluded(x))
|
|
||||||
|
|
||||||
#define SDL_ASSERT_CAPABILITY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_capability(x))
|
|
||||||
|
|
||||||
#define SDL_ASSERT_SHARED_CAPABILITY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(assert_shared_capability(x))
|
|
||||||
|
|
||||||
#define SDL_RETURN_CAPABILITY(x) \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(lock_returned(x))
|
|
||||||
|
|
||||||
#define SDL_NO_THREAD_SAFETY_ANALYSIS \
|
|
||||||
SDL_THREAD_ANNOTATION_ATTRIBUTE__(no_thread_safety_analysis)
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
|
|
||||||
#include "begin_code.h"
|
#include "begin_code.h"
|
||||||
/* Set up for C function definitions, even when using C++ */
|
/* Set up for C function definitions, even when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
@@ -170,7 +96,7 @@ extern DECLSPEC SDL_mutex *SDLCALL SDL_CreateMutex(void);
|
|||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex) SDL_ACQUIRE(mutex);
|
extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex);
|
||||||
#define SDL_mutexP(m) SDL_LockMutex(m)
|
#define SDL_mutexP(m) SDL_LockMutex(m)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -193,7 +119,7 @@ extern DECLSPEC int SDLCALL SDL_LockMutex(SDL_mutex * mutex) SDL_ACQUIRE(mutex);
|
|||||||
* \sa SDL_LockMutex
|
* \sa SDL_LockMutex
|
||||||
* \sa SDL_UnlockMutex
|
* \sa SDL_UnlockMutex
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex) SDL_TRY_ACQUIRE(0, mutex);
|
extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unlock the mutex.
|
* Unlock the mutex.
|
||||||
@@ -212,7 +138,7 @@ extern DECLSPEC int SDLCALL SDL_TryLockMutex(SDL_mutex * mutex) SDL_TRY_ACQUIRE(
|
|||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex) SDL_RELEASE(mutex);
|
extern DECLSPEC int SDLCALL SDL_UnlockMutex(SDL_mutex * mutex);
|
||||||
#define SDL_mutexV(m) SDL_UnlockMutex(m)
|
#define SDL_mutexV(m) SDL_UnlockMutex(m)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -350,7 +276,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
|||||||
* successful it will atomically decrement the semaphore value.
|
* successful it will atomically decrement the semaphore value.
|
||||||
*
|
*
|
||||||
* \param sem the semaphore to wait on
|
* \param sem the semaphore to wait on
|
||||||
* \param timeout the length of the timeout, in milliseconds
|
* \param ms the length of the timeout, in milliseconds
|
||||||
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
|
* \returns 0 if the wait succeeds, `SDL_MUTEX_TIMEDOUT` if the wait does not
|
||||||
* succeed in the allotted time, or a negative error code on failure;
|
* succeed in the allotted time, or a negative error code on failure;
|
||||||
* call SDL_GetError() for more information.
|
* call SDL_GetError() for more information.
|
||||||
@@ -364,7 +290,7 @@ extern DECLSPEC int SDLCALL SDL_SemTryWait(SDL_sem * sem);
|
|||||||
* \sa SDL_SemValue
|
* \sa SDL_SemValue
|
||||||
* \sa SDL_SemWait
|
* \sa SDL_SemWait
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem *sem, Uint32 timeout);
|
extern DECLSPEC int SDLCALL SDL_SemWaitTimeout(SDL_sem * sem, Uint32 ms);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Atomically increment a semaphore's value and wake waiting threads.
|
* Atomically increment a semaphore's value and wake waiting threads.
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
/* SDL modified the include guard to be compatible with Mesa and Apple include guards:
|
#ifndef __gl_glext_h_
|
||||||
* - Mesa uses: __gl_glext_h_
|
|
||||||
* - Apple uses: __glext_h_ */
|
|
||||||
#if !defined(__glext_h_) && !defined(__gl_glext_h_)
|
|
||||||
#define __glext_h_ 1
|
|
||||||
#define __gl_glext_h_ 1
|
#define __gl_glext_h_ 1
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
+8
-7
@@ -48,6 +48,7 @@ typedef enum
|
|||||||
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
SDL_POWERSTATE_CHARGED /**< Plugged in, battery charged */
|
||||||
} SDL_PowerState;
|
} SDL_PowerState;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current power supply details.
|
* Get the current power supply details.
|
||||||
*
|
*
|
||||||
@@ -64,17 +65,17 @@ typedef enum
|
|||||||
* It's possible a platform can only report battery percentage or time left
|
* It's possible a platform can only report battery percentage or time left
|
||||||
* but not both.
|
* but not both.
|
||||||
*
|
*
|
||||||
* \param seconds seconds of battery life left, you can pass a NULL here if
|
* \param secs seconds of battery life left, you can pass a NULL here if you
|
||||||
* you don't care, will return -1 if we can't determine a
|
* don't care, will return -1 if we can't determine a value, or
|
||||||
* value, or we're not running on a battery
|
* we're not running on a battery
|
||||||
* \param percent percentage of battery life left, between 0 and 100, you can
|
* \param pct percentage of battery life left, between 0 and 100, you can pass
|
||||||
* pass a NULL here if you don't care, will return -1 if we
|
* a NULL here if you don't care, will return -1 if we can't
|
||||||
* can't determine a value, or we're not running on a battery
|
* determine a value, or we're not running on a battery
|
||||||
* \returns an SDL_PowerState enum representing the current battery state.
|
* \returns an SDL_PowerState enum representing the current battery state.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
*/
|
*/
|
||||||
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *seconds, int *percent);
|
extern DECLSPEC SDL_PowerState SDLCALL SDL_GetPowerInfo(int *secs, int *pct);
|
||||||
|
|
||||||
/* Ends C function definitions when using C++ */
|
/* Ends C function definitions when using C++ */
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|||||||
@@ -1731,11 +1731,6 @@ extern DECLSPEC int SDLCALL SDL_RenderReadPixels(SDL_Renderer * renderer,
|
|||||||
*
|
*
|
||||||
* \param renderer the rendering context
|
* \param renderer the rendering context
|
||||||
*
|
*
|
||||||
* \threadsafety You may only call this function on the main thread. If this
|
|
||||||
* happens to work on a background thread on any given platform
|
|
||||||
* or backend, it's purely by luck and you should not rely on it
|
|
||||||
* to work next time.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_RenderClear
|
* \sa SDL_RenderClear
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ typedef enum
|
|||||||
* The accelerometer returns the current acceleration in SI meters per
|
* The accelerometer returns the current acceleration in SI meters per
|
||||||
* second squared. This measurement includes the force of gravity, so
|
* second squared. This measurement includes the force of gravity, so
|
||||||
* a device at rest will have an value of SDL_STANDARD_GRAVITY away
|
* a device at rest will have an value of SDL_STANDARD_GRAVITY away
|
||||||
* from the center of the earth, which is a positive Y value.
|
* from the center of the earth.
|
||||||
*
|
*
|
||||||
* values[0]: Acceleration on the x axis
|
* values[0]: Acceleration on the x axis
|
||||||
* values[1]: Acceleration on the y axis
|
* values[1]: Acceleration on the y axis
|
||||||
|
|||||||
+10
-18
@@ -30,6 +30,12 @@
|
|||||||
|
|
||||||
#include "SDL_config.h"
|
#include "SDL_config.h"
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#ifndef _DARWIN_C_SOURCE
|
||||||
|
#define _DARWIN_C_SOURCE 1 /* for memset_pattern4() */
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_SYS_TYPES_H
|
#ifdef HAVE_SYS_TYPES_H
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#endif
|
#endif
|
||||||
@@ -79,10 +85,8 @@
|
|||||||
Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
|
Visual Studio. See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
|
||||||
for more information.
|
for more information.
|
||||||
*/
|
*/
|
||||||
# ifndef _USE_MATH_DEFINES
|
|
||||||
# define _USE_MATH_DEFINES
|
# define _USE_MATH_DEFINES
|
||||||
# endif
|
# endif
|
||||||
# endif
|
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
#endif
|
#endif
|
||||||
#ifdef HAVE_FLOAT_H
|
#ifdef HAVE_FLOAT_H
|
||||||
@@ -524,7 +528,9 @@ extern DECLSPEC void *SDLCALL SDL_memset(SDL_OUT_BYTECAP(len) void *dst, int c,
|
|||||||
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
/* Note that memset() is a byte assignment and this is a 32-bit assignment, so they're not directly equivalent. */
|
||||||
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
SDL_FORCE_INLINE void SDL_memset4(void *dst, Uint32 val, size_t dwords)
|
||||||
{
|
{
|
||||||
#if defined(__GNUC__) && defined(__i386__)
|
#ifdef __APPLE__
|
||||||
|
memset_pattern4(dst, &val, dwords * 4);
|
||||||
|
#elif defined(__GNUC__) && defined(__i386__)
|
||||||
int u0, u1, u2;
|
int u0, u1, u2;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"cld \n\t"
|
"cld \n\t"
|
||||||
@@ -688,7 +694,7 @@ extern DECLSPEC size_t SDLCALL SDL_iconv(SDL_iconv_t cd, const char **inbuf,
|
|||||||
size_t * outbytesleft);
|
size_t * outbytesleft);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function converts a buffer or string between encodings in one pass, returning a
|
* This function converts a string between encodings in one pass, returning a
|
||||||
* string that must be freed with SDL_free() or NULL on error.
|
* string that must be freed with SDL_free() or NULL on error.
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
@@ -716,20 +722,6 @@ size_t strlcpy(char* dst, const char* src, size_t size);
|
|||||||
size_t strlcat(char* dst, const char* src, size_t size);
|
size_t strlcat(char* dst, const char* src, size_t size);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef HAVE_WCSLCPY
|
|
||||||
size_t wcslcpy(wchar_t *dst, const wchar_t *src, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef HAVE_WCSLCAT
|
|
||||||
size_t wcslcat(wchar_t *dst, const wchar_t *src, size_t size);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* Starting LLVM 16, the analyser errors out if these functions do not have
|
|
||||||
their prototype defined (clang-diagnostic-implicit-function-declaration) */
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define SDL_malloc malloc
|
#define SDL_malloc malloc
|
||||||
#define SDL_calloc calloc
|
#define SDL_calloc calloc
|
||||||
#define SDL_realloc realloc
|
#define SDL_realloc realloc
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
#include "SDL_atomic.h"
|
#include "SDL_atomic.h"
|
||||||
#include "SDL_mutex.h"
|
#include "SDL_mutex.h"
|
||||||
|
|
||||||
#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__)
|
#if defined(__WIN32__) || defined(__GDK__)
|
||||||
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
#include <process.h> /* _beginthreadex() and _endthreadex() */
|
||||||
#endif
|
#endif
|
||||||
#if defined(__OS2__) /* for _beginthread() and _endthread() */
|
#if defined(__OS2__) /* for _beginthread() and _endthread() */
|
||||||
@@ -88,7 +88,7 @@ typedef enum {
|
|||||||
typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
|
||||||
|
|
||||||
|
|
||||||
#if (defined(__WIN32__) || defined(__GDK__)) && !defined(__WINRT__)
|
#if defined(__WIN32__) || defined(__GDK__)
|
||||||
/**
|
/**
|
||||||
* \file SDL_thread.h
|
* \file SDL_thread.h
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ typedef struct SDL_version
|
|||||||
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
/* Printable format: "%d.%d.%d", MAJOR, MINOR, PATCHLEVEL
|
||||||
*/
|
*/
|
||||||
#define SDL_MAJOR_VERSION 2
|
#define SDL_MAJOR_VERSION 2
|
||||||
#define SDL_MINOR_VERSION 27
|
#define SDL_MINOR_VERSION 26
|
||||||
#define SDL_PATCHLEVEL 1
|
#define SDL_PATCHLEVEL 5
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Macro to determine SDL version program was compiled against.
|
* Macro to determine SDL version program was compiled against.
|
||||||
|
|||||||
+1
-29
@@ -187,8 +187,7 @@ typedef enum
|
|||||||
SDL_DISPLAYEVENT_NONE, /**< Never used */
|
SDL_DISPLAYEVENT_NONE, /**< Never used */
|
||||||
SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */
|
SDL_DISPLAYEVENT_ORIENTATION, /**< Display orientation has changed to data1 */
|
||||||
SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */
|
SDL_DISPLAYEVENT_CONNECTED, /**< Display has been added to the system */
|
||||||
SDL_DISPLAYEVENT_DISCONNECTED, /**< Display has been removed from the system */
|
SDL_DISPLAYEVENT_DISCONNECTED /**< Display has been removed from the system */
|
||||||
SDL_DISPLAYEVENT_MOVED /**< Display has changed position */
|
|
||||||
} SDL_DisplayEventID;
|
} SDL_DisplayEventID;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1275,17 +1274,6 @@ extern DECLSPEC void SDLCALL SDL_RestoreWindow(SDL_Window * window);
|
|||||||
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
|
extern DECLSPEC int SDLCALL SDL_SetWindowFullscreen(SDL_Window * window,
|
||||||
Uint32 flags);
|
Uint32 flags);
|
||||||
|
|
||||||
/**
|
|
||||||
* Return whether the window has a surface associated with it.
|
|
||||||
*
|
|
||||||
* \returns SDL_TRUE if there is a surface associated with the window, or SDL_FALSE otherwise.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.28.0.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetWindowSurface
|
|
||||||
*/
|
|
||||||
extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the SDL surface associated with the window.
|
* Get the SDL surface associated with the window.
|
||||||
*
|
*
|
||||||
@@ -1306,8 +1294,6 @@ extern DECLSPEC SDL_bool SDLCALL SDL_HasWindowSurface(SDL_Window *window);
|
|||||||
*
|
*
|
||||||
* \since This function is available since SDL 2.0.0.
|
* \since This function is available since SDL 2.0.0.
|
||||||
*
|
*
|
||||||
* \sa SDL_DestroyWindowSurface
|
|
||||||
* \sa SDL_HasWindowSurface
|
|
||||||
* \sa SDL_UpdateWindowSurface
|
* \sa SDL_UpdateWindowSurface
|
||||||
* \sa SDL_UpdateWindowSurfaceRects
|
* \sa SDL_UpdateWindowSurfaceRects
|
||||||
*/
|
*/
|
||||||
@@ -1356,20 +1342,6 @@ extern DECLSPEC int SDLCALL SDL_UpdateWindowSurfaceRects(SDL_Window * window,
|
|||||||
const SDL_Rect * rects,
|
const SDL_Rect * rects,
|
||||||
int numrects);
|
int numrects);
|
||||||
|
|
||||||
/**
|
|
||||||
* Destroy the surface associated with the window.
|
|
||||||
*
|
|
||||||
* \param window the window to update
|
|
||||||
* \returns 0 on success or a negative error code on failure; call
|
|
||||||
* SDL_GetError() for more information.
|
|
||||||
*
|
|
||||||
* \since This function is available since SDL 2.28.0.
|
|
||||||
*
|
|
||||||
* \sa SDL_GetWindowSurface
|
|
||||||
* \sa SDL_HasWindowSurface
|
|
||||||
*/
|
|
||||||
extern DECLSPEC int SDLCALL SDL_DestroyWindowSurface(SDL_Window *window);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a window's input grab mode.
|
* Set a window's input grab mode.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -28,10 +28,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* This shouldn't be nested -- included it around code only. */
|
/* This shouldn't be nested -- included it around code only. */
|
||||||
#ifdef SDL_begin_code_h
|
#ifdef _begin_code_h
|
||||||
#error Nested inclusion of begin_code.h
|
#error Nested inclusion of begin_code.h
|
||||||
#endif
|
#endif
|
||||||
#define SDL_begin_code_h
|
#define _begin_code_h
|
||||||
|
|
||||||
#ifndef SDL_DEPRECATED
|
#ifndef SDL_DEPRECATED
|
||||||
# if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
|
# if defined(__GNUC__) && (__GNUC__ >= 4) /* technically, this arrived in gcc 3.1, but oh well. */
|
||||||
@@ -171,17 +171,17 @@
|
|||||||
#define SDL_FALLTHROUGH [[fallthrough]]
|
#define SDL_FALLTHROUGH [[fallthrough]]
|
||||||
#else
|
#else
|
||||||
#if defined(__has_attribute)
|
#if defined(__has_attribute)
|
||||||
#define SDL_HAS_FALLTHROUGH __has_attribute(__fallthrough__)
|
#define _HAS_FALLTHROUGH __has_attribute(__fallthrough__)
|
||||||
#else
|
#else
|
||||||
#define SDL_HAS_FALLTHROUGH 0
|
#define _HAS_FALLTHROUGH 0
|
||||||
#endif /* __has_attribute */
|
#endif /* __has_attribute */
|
||||||
#if SDL_HAS_FALLTHROUGH && \
|
#if _HAS_FALLTHROUGH && \
|
||||||
((defined(__GNUC__) && __GNUC__ >= 7) || \
|
((defined(__GNUC__) && __GNUC__ >= 7) || \
|
||||||
(defined(__clang_major__) && __clang_major__ >= 10))
|
(defined(__clang_major__) && __clang_major__ >= 10))
|
||||||
#define SDL_FALLTHROUGH __attribute__((__fallthrough__))
|
#define SDL_FALLTHROUGH __attribute__((__fallthrough__))
|
||||||
#else
|
#else
|
||||||
#define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
|
#define SDL_FALLTHROUGH do {} while (0) /* fallthrough */
|
||||||
#endif /* SDL_HAS_FALLTHROUGH */
|
#endif /* _HAS_FALLTHROUGH */
|
||||||
#undef SDL_HAS_FALLTHROUGH
|
#undef _HAS_FALLTHROUGH
|
||||||
#endif /* C++17 or C2x */
|
#endif /* C++17 or C2x */
|
||||||
#endif /* SDL_FALLTHROUGH not defined */
|
#endif /* SDL_FALLTHROUGH not defined */
|
||||||
@@ -26,10 +26,10 @@
|
|||||||
* after you finish any function and structure declarations in your headers
|
* after you finish any function and structure declarations in your headers
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef SDL_begin_code_h
|
#ifndef _begin_code_h
|
||||||
#error close_code.h included without matching begin_code.h
|
#error close_code.h included without matching begin_code.h
|
||||||
#endif
|
#endif
|
||||||
#undef SDL_begin_code_h
|
#undef _begin_code_h
|
||||||
|
|
||||||
/* Reset structure packing at previous byte alignment */
|
/* Reset structure packing at previous byte alignment */
|
||||||
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
#if defined(_MSC_VER) || defined(__MWERKS__) || defined(__BORLANDC__)
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ macro(set_and_check _var _file)
|
|||||||
endif()
|
endif()
|
||||||
endmacro()
|
endmacro()
|
||||||
|
|
||||||
get_filename_component(CMAKE_CURRENT_LIST_DIR ${CMAKE_CURRENT_LIST_DIR} REALPATH)
|
|
||||||
get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/@cmake_prefix_relpath@" ABSOLUTE)
|
get_filename_component(prefix "${CMAKE_CURRENT_LIST_DIR}/@cmake_prefix_relpath@" ABSOLUTE)
|
||||||
|
|
||||||
set(exec_prefix "@exec_prefix@")
|
set(exec_prefix "@exec_prefix@")
|
||||||
@@ -60,11 +59,6 @@ string(REGEX MATCHALL "-L([-a-zA-Z0-9._/]+)" _sdl2_static_private_libdirs "${_sd
|
|||||||
string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
|
string(REGEX REPLACE "^-L" "" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
|
||||||
string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
|
string(REGEX REPLACE ";-L" ";" _sdl2_static_private_libdirs "${_sdl2_static_private_libdirs}")
|
||||||
|
|
||||||
# Set SDL2_NO_MWINDOWS to a true-ish value to not add the -mwindows link option
|
|
||||||
if(SDL2_NO_MWINDOWS)
|
|
||||||
list(REMOVE_ITEM _sdl2_libraries "-mwindows")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(_sdl2_libraries MATCHES ".*SDL2main.*")
|
if(_sdl2_libraries MATCHES ".*SDL2main.*")
|
||||||
list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
|
list(INSERT SDL2_LIBRARIES 0 SDL2::SDL2main)
|
||||||
list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
|
list(INSERT SDL2_STATIC_LIBRARIES 0 SDL2::SDL2main)
|
||||||
@@ -78,8 +72,6 @@ if(EXISTS "${_sdl2main_library}")
|
|||||||
set_target_properties(SDL2::SDL2main
|
set_target_properties(SDL2::SDL2main
|
||||||
PROPERTIES
|
PROPERTIES
|
||||||
IMPORTED_LOCATION "${_sdl2main_library}"
|
IMPORTED_LOCATION "${_sdl2main_library}"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
# INTERFACE_LINK_OPTIONS needs CMake 3.13
|
# INTERFACE_LINK_OPTIONS needs CMake 3.13
|
||||||
@@ -123,8 +115,6 @@ if(WIN32)
|
|||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_IMPLIB "${_sdl2_implib}"
|
IMPORTED_IMPLIB "${_sdl2_implib}"
|
||||||
IMPORTED_LOCATION "${_sdl2_dll}"
|
IMPORTED_LOCATION "${_sdl2_dll}"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2_FOUND TRUE)
|
set(SDL2_SDL2_FOUND TRUE)
|
||||||
@@ -144,8 +134,6 @@ else()
|
|||||||
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
|
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
IMPORTED_LOCATION "${_sdl2_shared}"
|
IMPORTED_LOCATION "${_sdl2_shared}"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2_FOUND TRUE)
|
set(SDL2_SDL2_FOUND TRUE)
|
||||||
@@ -166,8 +154,6 @@ if(EXISTS "${_sdl2_static}")
|
|||||||
INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries};${_sdl2_static_private_libs}"
|
INTERFACE_LINK_LIBRARIES "${_sdl2_link_libraries};${_sdl2_static_private_libs}"
|
||||||
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs};${_sdl2_static_private_libdirs}"
|
INTERFACE_LINK_DIRECTORIES "${_sdl2_libdirs};${_sdl2_static_private_libdirs}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2-static_FOUND TRUE)
|
set(SDL2_SDL2-static_FOUND TRUE)
|
||||||
@@ -187,8 +173,6 @@ if(EXISTS "${_sdl2test_library}")
|
|||||||
IMPORTED_LOCATION "${_sdl2test_library}"
|
IMPORTED_LOCATION "${_sdl2test_library}"
|
||||||
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
INTERFACE_INCLUDE_DIRECTORIES "${SDL2_INCLUDE_DIR}"
|
||||||
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
IMPORTED_LINK_INTERFACE_LANGUAGES "C"
|
||||||
COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
|
|
||||||
INTERFACE_SDL_VERSION "SDL2"
|
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
set(SDL2_SDL2test_FOUND TRUE)
|
set(SDL2_SDL2test_FOUND TRUE)
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ includedir=@includedir@
|
|||||||
Name: sdl2
|
Name: sdl2
|
||||||
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
|
Description: Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer.
|
||||||
Version: @SDL_VERSION@
|
Version: @SDL_VERSION@
|
||||||
Requires.private: @PKGCONFIG_DEPENDS@
|
Requires:
|
||||||
Conflicts:
|
Conflicts:
|
||||||
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKGCONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@
|
Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKGCONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@
|
||||||
Cflags: -I${includedir} -I${includedir}/SDL2 @SDL_CFLAGS@
|
Cflags: -I${includedir} -I${includedir}/SDL2 @SDL_CFLAGS@
|
||||||
@@ -110,6 +110,7 @@ SDL_NORETURN void SDL_ExitProcess(int exitcode)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The initialized subsystems */
|
/* The initialized subsystems */
|
||||||
#ifdef SDL_MAIN_NEEDED
|
#ifdef SDL_MAIN_NEEDED
|
||||||
static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
static SDL_bool SDL_MainIsReady = SDL_FALSE;
|
||||||
@@ -120,7 +121,8 @@ static SDL_bool SDL_bInMainQuit = SDL_FALSE;
|
|||||||
static Uint8 SDL_SubsystemRefCount[ 32 ];
|
static Uint8 SDL_SubsystemRefCount[ 32 ];
|
||||||
|
|
||||||
/* Private helper to increment a subsystem's ref counter. */
|
/* Private helper to increment a subsystem's ref counter. */
|
||||||
static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
static void
|
||||||
|
SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
@@ -130,7 +132,8 @@ static void SDL_PrivateSubsystemRefCountIncr(Uint32 subsystem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Private helper to decrement a subsystem's ref counter. */
|
/* Private helper to decrement a subsystem's ref counter. */
|
||||||
static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
static void
|
||||||
|
SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] > 0)) {
|
||||||
@@ -139,7 +142,8 @@ static void SDL_PrivateSubsystemRefCountDecr(Uint32 subsystem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Private helper to check if a system needs init. */
|
/* Private helper to check if a system needs init. */
|
||||||
static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
static SDL_bool
|
||||||
|
SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
||||||
{
|
{
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
SDL_assert((subsystem_index < 0) || (SDL_SubsystemRefCount[subsystem_index] < 255));
|
||||||
@@ -147,8 +151,8 @@ static SDL_bool SDL_PrivateShouldInitSubsystem(Uint32 subsystem)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Private helper to check if a system needs to be quit. */
|
/* Private helper to check if a system needs to be quit. */
|
||||||
static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
|
static SDL_bool
|
||||||
{
|
SDL_PrivateShouldQuitSubsystem(Uint32 subsystem) {
|
||||||
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
const int subsystem_index = SDL_MostSignificantBitIndex32(subsystem);
|
||||||
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
if ((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 0)) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
@@ -160,12 +164,14 @@ static SDL_bool SDL_PrivateShouldQuitSubsystem(Uint32 subsystem)
|
|||||||
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
|
return (((subsystem_index >= 0) && (SDL_SubsystemRefCount[subsystem_index] == 1)) || SDL_bInMainQuit) ? SDL_TRUE : SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_SetMainReady(void)
|
void
|
||||||
|
SDL_SetMainReady(void)
|
||||||
{
|
{
|
||||||
SDL_MainIsReady = SDL_TRUE;
|
SDL_MainIsReady = SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_InitSubSystem(Uint32 flags)
|
int
|
||||||
|
SDL_InitSubSystem(Uint32 flags)
|
||||||
{
|
{
|
||||||
Uint32 flags_initialized = 0;
|
Uint32 flags_initialized = 0;
|
||||||
|
|
||||||
@@ -182,12 +188,12 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
SDL_DBus_Init();
|
SDL_DBus_Init();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (flags & SDL_INIT_GAMECONTROLLER) {
|
if ((flags & SDL_INIT_GAMECONTROLLER)) {
|
||||||
/* game controller implies joystick */
|
/* game controller implies joystick */
|
||||||
flags |= SDL_INIT_JOYSTICK;
|
flags |= SDL_INIT_JOYSTICK;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & (SDL_INIT_VIDEO | SDL_INIT_JOYSTICK | SDL_INIT_AUDIO)) {
|
if ((flags & (SDL_INIT_VIDEO|SDL_INIT_JOYSTICK|SDL_INIT_AUDIO))) {
|
||||||
/* video or joystick or audio implies events */
|
/* video or joystick or audio implies events */
|
||||||
flags |= SDL_INIT_EVENTS;
|
flags |= SDL_INIT_EVENTS;
|
||||||
}
|
}
|
||||||
@@ -197,7 +203,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SDL_VIDEO_DRIVER_WINDOWS
|
#if SDL_VIDEO_DRIVER_WINDOWS
|
||||||
if (flags & (SDL_INIT_HAPTIC | SDL_INIT_JOYSTICK)) {
|
if ((flags & (SDL_INIT_HAPTIC|SDL_INIT_JOYSTICK))) {
|
||||||
if (SDL_HelperWindowCreate() < 0) {
|
if (SDL_HelperWindowCreate() < 0) {
|
||||||
goto quit_and_error;
|
goto quit_and_error;
|
||||||
}
|
}
|
||||||
@@ -209,7 +215,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Initialize the event subsystem */
|
/* Initialize the event subsystem */
|
||||||
if (flags & SDL_INIT_EVENTS) {
|
if ((flags & SDL_INIT_EVENTS)) {
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_EVENTS)) {
|
||||||
if (SDL_EventsInit() < 0) {
|
if (SDL_EventsInit() < 0) {
|
||||||
@@ -225,7 +231,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the timer subsystem */
|
/* Initialize the timer subsystem */
|
||||||
if (flags & SDL_INIT_TIMER) {
|
if ((flags & SDL_INIT_TIMER)){
|
||||||
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_TIMER)) {
|
||||||
if (SDL_TimerInit() < 0) {
|
if (SDL_TimerInit() < 0) {
|
||||||
@@ -241,7 +247,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the video subsystem */
|
/* Initialize the video subsystem */
|
||||||
if (flags & SDL_INIT_VIDEO) {
|
if ((flags & SDL_INIT_VIDEO)){
|
||||||
#if !SDL_VIDEO_DISABLED
|
#if !SDL_VIDEO_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_VIDEO)) {
|
||||||
if (SDL_VideoInit(NULL) < 0) {
|
if (SDL_VideoInit(NULL) < 0) {
|
||||||
@@ -257,7 +263,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the audio subsystem */
|
/* Initialize the audio subsystem */
|
||||||
if (flags & SDL_INIT_AUDIO) {
|
if ((flags & SDL_INIT_AUDIO)){
|
||||||
#if !SDL_AUDIO_DISABLED
|
#if !SDL_AUDIO_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_AUDIO)) {
|
||||||
if (SDL_AudioInit(NULL) < 0) {
|
if (SDL_AudioInit(NULL) < 0) {
|
||||||
@@ -273,7 +279,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the joystick subsystem */
|
/* Initialize the joystick subsystem */
|
||||||
if (flags & SDL_INIT_JOYSTICK) {
|
if ((flags & SDL_INIT_JOYSTICK)){
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_JOYSTICK)) {
|
||||||
if (SDL_JoystickInit() < 0) {
|
if (SDL_JoystickInit() < 0) {
|
||||||
@@ -288,7 +294,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & SDL_INIT_GAMECONTROLLER) {
|
if ((flags & SDL_INIT_GAMECONTROLLER)){
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_GAMECONTROLLER)) {
|
||||||
if (SDL_GameControllerInit() < 0) {
|
if (SDL_GameControllerInit() < 0) {
|
||||||
@@ -304,7 +310,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the haptic subsystem */
|
/* Initialize the haptic subsystem */
|
||||||
if (flags & SDL_INIT_HAPTIC) {
|
if ((flags & SDL_INIT_HAPTIC)){
|
||||||
#if !SDL_HAPTIC_DISABLED
|
#if !SDL_HAPTIC_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_HAPTIC)) {
|
||||||
if (SDL_HapticInit() < 0) {
|
if (SDL_HapticInit() < 0) {
|
||||||
@@ -320,7 +326,7 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize the sensor subsystem */
|
/* Initialize the sensor subsystem */
|
||||||
if (flags & SDL_INIT_SENSOR) {
|
if ((flags & SDL_INIT_SENSOR)){
|
||||||
#if !SDL_SENSOR_DISABLED
|
#if !SDL_SENSOR_DISABLED
|
||||||
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
if (SDL_PrivateShouldInitSubsystem(SDL_INIT_SENSOR)) {
|
||||||
if (SDL_SensorInit() < 0) {
|
if (SDL_SensorInit() < 0) {
|
||||||
@@ -337,19 +343,21 @@ int SDL_InitSubSystem(Uint32 flags)
|
|||||||
|
|
||||||
(void) flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
(void) flags_initialized; /* make static analysis happy, since this only gets used in error cases. */
|
||||||
|
|
||||||
return 0;
|
return (0);
|
||||||
|
|
||||||
quit_and_error:
|
quit_and_error:
|
||||||
SDL_QuitSubSystem(flags_initialized);
|
SDL_QuitSubSystem(flags_initialized);
|
||||||
return -1;
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_Init(Uint32 flags)
|
int
|
||||||
|
SDL_Init(Uint32 flags)
|
||||||
{
|
{
|
||||||
return SDL_InitSubSystem(flags);
|
return SDL_InitSubSystem(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_QuitSubSystem(Uint32 flags)
|
void
|
||||||
|
SDL_QuitSubSystem(Uint32 flags)
|
||||||
{
|
{
|
||||||
#if defined(__OS2__)
|
#if defined(__OS2__)
|
||||||
#if SDL_THREAD_OS2
|
#if SDL_THREAD_OS2
|
||||||
@@ -360,7 +368,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
|
|
||||||
/* Shut down requested initialized subsystems */
|
/* Shut down requested initialized subsystems */
|
||||||
#if !SDL_SENSOR_DISABLED
|
#if !SDL_SENSOR_DISABLED
|
||||||
if (flags & SDL_INIT_SENSOR) {
|
if ((flags & SDL_INIT_SENSOR)) {
|
||||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_SENSOR)) {
|
||||||
SDL_SensorQuit();
|
SDL_SensorQuit();
|
||||||
}
|
}
|
||||||
@@ -369,7 +377,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_JOYSTICK_DISABLED
|
#if !SDL_JOYSTICK_DISABLED
|
||||||
if (flags & SDL_INIT_GAMECONTROLLER) {
|
if ((flags & SDL_INIT_GAMECONTROLLER)) {
|
||||||
/* game controller implies joystick */
|
/* game controller implies joystick */
|
||||||
flags |= SDL_INIT_JOYSTICK;
|
flags |= SDL_INIT_JOYSTICK;
|
||||||
|
|
||||||
@@ -379,7 +387,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
|
SDL_PrivateSubsystemRefCountDecr(SDL_INIT_GAMECONTROLLER);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & SDL_INIT_JOYSTICK) {
|
if ((flags & SDL_INIT_JOYSTICK)) {
|
||||||
/* joystick implies events */
|
/* joystick implies events */
|
||||||
flags |= SDL_INIT_EVENTS;
|
flags |= SDL_INIT_EVENTS;
|
||||||
|
|
||||||
@@ -391,7 +399,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_HAPTIC_DISABLED
|
#if !SDL_HAPTIC_DISABLED
|
||||||
if (flags & SDL_INIT_HAPTIC) {
|
if ((flags & SDL_INIT_HAPTIC)) {
|
||||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_HAPTIC)) {
|
||||||
SDL_HapticQuit();
|
SDL_HapticQuit();
|
||||||
}
|
}
|
||||||
@@ -400,7 +408,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_AUDIO_DISABLED
|
#if !SDL_AUDIO_DISABLED
|
||||||
if (flags & SDL_INIT_AUDIO) {
|
if ((flags & SDL_INIT_AUDIO)) {
|
||||||
/* audio implies events */
|
/* audio implies events */
|
||||||
flags |= SDL_INIT_EVENTS;
|
flags |= SDL_INIT_EVENTS;
|
||||||
|
|
||||||
@@ -412,7 +420,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_VIDEO_DISABLED
|
#if !SDL_VIDEO_DISABLED
|
||||||
if (flags & SDL_INIT_VIDEO) {
|
if ((flags & SDL_INIT_VIDEO)) {
|
||||||
/* video implies events */
|
/* video implies events */
|
||||||
flags |= SDL_INIT_EVENTS;
|
flags |= SDL_INIT_EVENTS;
|
||||||
|
|
||||||
@@ -424,7 +432,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
#if !SDL_TIMERS_DISABLED && !SDL_TIMER_DUMMY
|
||||||
if (flags & SDL_INIT_TIMER) {
|
if ((flags & SDL_INIT_TIMER)) {
|
||||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_TIMER)) {
|
||||||
SDL_TimerQuit();
|
SDL_TimerQuit();
|
||||||
}
|
}
|
||||||
@@ -433,7 +441,7 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !SDL_EVENTS_DISABLED
|
#if !SDL_EVENTS_DISABLED
|
||||||
if (flags & SDL_INIT_EVENTS) {
|
if ((flags & SDL_INIT_EVENTS)) {
|
||||||
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
if (SDL_PrivateShouldQuitSubsystem(SDL_INIT_EVENTS)) {
|
||||||
SDL_EventsQuit();
|
SDL_EventsQuit();
|
||||||
}
|
}
|
||||||
@@ -442,7 +450,8 @@ void SDL_QuitSubSystem(Uint32 flags)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 SDL_WasInit(Uint32 flags)
|
Uint32
|
||||||
|
SDL_WasInit(Uint32 flags)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
|
int num_subsystems = SDL_arraysize(SDL_SubsystemRefCount);
|
||||||
@@ -472,7 +481,8 @@ Uint32 SDL_WasInit(Uint32 flags)
|
|||||||
return initialized;
|
return initialized;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_Quit(void)
|
void
|
||||||
|
SDL_Quit(void)
|
||||||
{
|
{
|
||||||
SDL_bInMainQuit = SDL_TRUE;
|
SDL_bInMainQuit = SDL_TRUE;
|
||||||
|
|
||||||
@@ -506,12 +516,13 @@ void SDL_Quit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the library version number */
|
/* Get the library version number */
|
||||||
void SDL_GetVersion(SDL_version *ver)
|
void
|
||||||
|
SDL_GetVersion(SDL_version * ver)
|
||||||
{
|
{
|
||||||
static SDL_bool check_hint = SDL_TRUE;
|
static SDL_bool check_hint = SDL_TRUE;
|
||||||
static SDL_bool legacy_version = SDL_FALSE;
|
static SDL_bool legacy_version = SDL_FALSE;
|
||||||
|
|
||||||
if (ver == NULL) {
|
if (!ver) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -530,19 +541,22 @@ void SDL_GetVersion(SDL_version *ver)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the library source revision */
|
/* Get the library source revision */
|
||||||
const char *SDL_GetRevision(void)
|
const char *
|
||||||
|
SDL_GetRevision(void)
|
||||||
{
|
{
|
||||||
return SDL_REVISION;
|
return SDL_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the library source revision number */
|
/* Get the library source revision number */
|
||||||
int SDL_GetRevisionNumber(void)
|
int
|
||||||
|
SDL_GetRevisionNumber(void)
|
||||||
{
|
{
|
||||||
return 0; /* doesn't make sense without Mercurial. */
|
return 0; /* doesn't make sense without Mercurial. */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the name of the platform */
|
/* Get the name of the platform */
|
||||||
const char *SDL_GetPlatform(void)
|
const char *
|
||||||
|
SDL_GetPlatform(void)
|
||||||
{
|
{
|
||||||
#if __AIX__
|
#if __AIX__
|
||||||
return "AIX";
|
return "AIX";
|
||||||
@@ -615,7 +629,8 @@ const char *SDL_GetPlatform(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_IsTablet(void)
|
SDL_bool
|
||||||
|
SDL_IsTablet(void)
|
||||||
{
|
{
|
||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
extern SDL_bool SDL_IsAndroidTablet(void);
|
extern SDL_bool SDL_IsAndroidTablet(void);
|
||||||
@@ -633,7 +648,9 @@ SDL_bool SDL_IsTablet(void)
|
|||||||
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
#if (!defined(HAVE_LIBC) || defined(__WATCOMC__)) && !defined(SDL_STATIC_LIB)
|
||||||
/* Need to include DllMain() on Watcom C for some reason.. */
|
/* Need to include DllMain() on Watcom C for some reason.. */
|
||||||
|
|
||||||
BOOL APIENTRY _DllMainCRTStartup(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
|
BOOL APIENTRY
|
||||||
|
_DllMainCRTStartup(HANDLE hModule,
|
||||||
|
DWORD ul_reason_for_call, LPVOID lpReserved)
|
||||||
{
|
{
|
||||||
switch (ul_reason_for_call) {
|
switch (ul_reason_for_call) {
|
||||||
case DLL_PROCESS_ATTACH:
|
case DLL_PROCESS_ATTACH:
|
||||||
|
|||||||
+34
-21
@@ -48,7 +48,8 @@
|
|||||||
/* The size of the stack buffer to use for rendering assert messages. */
|
/* The size of the stack buffer to use for rendering assert messages. */
|
||||||
#define SDL_MAX_ASSERT_MESSAGE_STACK 256
|
#define SDL_MAX_ASSERT_MESSAGE_STACK 256
|
||||||
|
|
||||||
static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
|
static SDL_assert_state SDLCALL
|
||||||
|
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We keep all triggered assertions in a singly-linked list so we can
|
* We keep all triggered assertions in a singly-linked list so we can
|
||||||
@@ -64,10 +65,12 @@ static SDL_AssertionHandler assertion_handler = SDL_PromptAssertion;
|
|||||||
static void *assertion_userdata = NULL;
|
static void *assertion_userdata = NULL;
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
static void debug_print(const char *fmt, ...) __attribute__((format(printf, 1, 2)));
|
static void
|
||||||
|
debug_print(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void debug_print(const char *fmt, ...)
|
static void
|
||||||
|
debug_print(const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
@@ -75,6 +78,7 @@ static void debug_print(const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
||||||
{
|
{
|
||||||
/* (data) is always a static struct defined with the assert macros, so
|
/* (data) is always a static struct defined with the assert macros, so
|
||||||
@@ -92,13 +96,13 @@ static void SDL_AddAssertionToReport(SDL_assert_data *data)
|
|||||||
#define ENDLINE "\n"
|
#define ENDLINE "\n"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data)
|
static int SDL_RenderAssertMessage(char *buf, size_t buf_len, const SDL_assert_data *data) {
|
||||||
{
|
|
||||||
return SDL_snprintf(buf, buf_len,
|
return SDL_snprintf(buf, buf_len,
|
||||||
"Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'",
|
"Assertion failure at %s (%s:%d), triggered %u %s:" ENDLINE " '%s'",
|
||||||
data->function, data->filename, data->linenum,
|
data->function, data->filename, data->linenum,
|
||||||
data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
|
data->trigger_count, (data->trigger_count == 1) ? "time" : "times",
|
||||||
data->condition);
|
data->condition
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_GenerateAssertionReport(void)
|
static void SDL_GenerateAssertionReport(void)
|
||||||
@@ -128,6 +132,7 @@ static void SDL_GenerateAssertionReport(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* This is not declared in any header, although it is shared between some
|
/* This is not declared in any header, although it is shared between some
|
||||||
parts of SDL, because we don't want anything calling it without an
|
parts of SDL, because we don't want anything calling it without an
|
||||||
extremely good reason. */
|
extremely good reason. */
|
||||||
@@ -137,6 +142,7 @@ extern void SDL_ExitProcess(int exitcode);
|
|||||||
#endif
|
#endif
|
||||||
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
|
||||||
|
|
||||||
|
|
||||||
#if defined(__WATCOMC__)
|
#if defined(__WATCOMC__)
|
||||||
static void SDL_AbortAssertion (void);
|
static void SDL_AbortAssertion (void);
|
||||||
#pragma aux SDL_AbortAssertion aborts;
|
#pragma aux SDL_AbortAssertion aborts;
|
||||||
@@ -147,7 +153,8 @@ static SDL_NORETURN void SDL_AbortAssertion(void)
|
|||||||
SDL_ExitProcess(42);
|
SDL_ExitProcess(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
|
static SDL_assert_state SDLCALL
|
||||||
|
SDL_PromptAssertion(const SDL_assert_data *data, void *userdata)
|
||||||
{
|
{
|
||||||
const char *envr;
|
const char *envr;
|
||||||
SDL_assert_state state = SDL_ASSERTION_ABORT;
|
SDL_assert_state state = SDL_ASSERTION_ABORT;
|
||||||
@@ -245,12 +252,14 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
|||||||
} else {
|
} else {
|
||||||
state = (SDL_assert_state)selected;
|
state = (SDL_assert_state)selected;
|
||||||
}
|
}
|
||||||
} else {
|
}
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
#if defined(__EMSCRIPTEN__)
|
#if defined(__EMSCRIPTEN__)
|
||||||
/* This is nasty, but we can't block on a custom UI. */
|
/* This is nasty, but we can't block on a custom UI. */
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
SDL_bool okay = SDL_TRUE;
|
SDL_bool okay = SDL_TRUE;
|
||||||
/* *INDENT-OFF* */ /* clang-format off */
|
|
||||||
char *buf = (char *) EM_ASM_INT({
|
char *buf = (char *) EM_ASM_INT({
|
||||||
var str =
|
var str =
|
||||||
UTF8ToString($0) + '\n\n' +
|
UTF8ToString($0) + '\n\n' +
|
||||||
@@ -261,14 +270,12 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
|||||||
}
|
}
|
||||||
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
|
return allocate(intArrayFromString(reply), 'i8', ALLOC_NORMAL);
|
||||||
}, message);
|
}, message);
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
|
||||||
|
|
||||||
if (SDL_strcmp(buf, "a") == 0) {
|
if (SDL_strcmp(buf, "a") == 0) {
|
||||||
state = SDL_ASSERTION_ABORT;
|
state = SDL_ASSERTION_ABORT;
|
||||||
#if 0 /* (currently) no break functionality on Emscripten */
|
/* (currently) no break functionality on Emscripten
|
||||||
} else if (SDL_strcmp(buf, "b") == 0) {
|
} else if (SDL_strcmp(buf, "b") == 0) {
|
||||||
state = SDL_ASSERTION_BREAK;
|
state = SDL_ASSERTION_BREAK; */
|
||||||
#endif
|
|
||||||
} else if (SDL_strcmp(buf, "r") == 0) {
|
} else if (SDL_strcmp(buf, "r") == 0) {
|
||||||
state = SDL_ASSERTION_RETRY;
|
state = SDL_ASSERTION_RETRY;
|
||||||
} else if (SDL_strcmp(buf, "i") == 0) {
|
} else if (SDL_strcmp(buf, "i") == 0) {
|
||||||
@@ -288,8 +295,8 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
|||||||
/* this is a little hacky. */
|
/* this is a little hacky. */
|
||||||
for ( ; ; ) {
|
for ( ; ; ) {
|
||||||
char buf[32];
|
char buf[32];
|
||||||
(void)fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
fprintf(stderr, "Abort/Break/Retry/Ignore/AlwaysIgnore? [abriA] : ");
|
||||||
(void)fflush(stderr);
|
fflush(stderr);
|
||||||
if (fgets(buf, sizeof (buf), stdin) == NULL) {
|
if (fgets(buf, sizeof (buf), stdin) == NULL) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -326,7 +333,10 @@ static SDL_assert_state SDLCALL SDL_PromptAssertion(const SDL_assert_data *data,
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file, int line)
|
|
||||||
|
SDL_assert_state
|
||||||
|
SDL_ReportAssertion(SDL_assert_data *data, const char *func, const char *file,
|
||||||
|
int line)
|
||||||
{
|
{
|
||||||
SDL_assert_state state = SDL_ASSERTION_IGNORE;
|
SDL_assert_state state = SDL_ASSERTION_IGNORE;
|
||||||
static int assertion_running = 0;
|
static int assertion_running = 0;
|
||||||
@@ -343,8 +353,10 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
|
|||||||
}
|
}
|
||||||
SDL_AtomicUnlock(&spinlock);
|
SDL_AtomicUnlock(&spinlock);
|
||||||
|
|
||||||
SDL_LockMutex(assertion_mutex);
|
if (SDL_LockMutex(assertion_mutex) < 0) {
|
||||||
#endif /* !SDL_THREADS_DISABLED */
|
return SDL_ASSERTION_IGNORE; /* oh well, I guess. */
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* doing this because Visual C is upset over assigning in the macro. */
|
/* doing this because Visual C is upset over assigning in the macro. */
|
||||||
if (data->trigger_count == 0) {
|
if (data->trigger_count == 0) {
|
||||||
@@ -362,8 +374,7 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
|
|||||||
} else if (assertion_running == 3) { /* Abort asserted! */
|
} else if (assertion_running == 3) { /* Abort asserted! */
|
||||||
SDL_ExitProcess(42);
|
SDL_ExitProcess(42);
|
||||||
} else {
|
} else {
|
||||||
while (1) { /* do nothing but spin; what else can you do?! */
|
while (1) { /* do nothing but spin; what else can you do?! */ }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -371,7 +382,8 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
|
|||||||
state = assertion_handler(data, assertion_userdata);
|
state = assertion_handler(data, assertion_userdata);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (state) {
|
switch (state)
|
||||||
|
{
|
||||||
case SDL_ASSERTION_ALWAYS_IGNORE:
|
case SDL_ASSERTION_ALWAYS_IGNORE:
|
||||||
state = SDL_ASSERTION_IGNORE;
|
state = SDL_ASSERTION_IGNORE;
|
||||||
data->always_ignore = 1;
|
data->always_ignore = 1;
|
||||||
@@ -396,6 +408,7 @@ SDL_assert_state SDL_ReportAssertion(SDL_assert_data *data, const char *func, co
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void SDL_AssertionsQuit(void)
|
void SDL_AssertionsQuit(void)
|
||||||
{
|
{
|
||||||
#if SDL_ASSERT_LEVEL > 0
|
#if SDL_ASSERT_LEVEL > 0
|
||||||
|
|||||||
+67
-52
@@ -33,7 +33,6 @@ typedef struct SDL_DataQueuePacket
|
|||||||
|
|
||||||
struct SDL_DataQueue
|
struct SDL_DataQueue
|
||||||
{
|
{
|
||||||
SDL_mutex *lock;
|
|
||||||
SDL_DataQueuePacket *head; /* device fed from here. */
|
SDL_DataQueuePacket *head; /* device fed from here. */
|
||||||
SDL_DataQueuePacket *tail; /* queue fills to here. */
|
SDL_DataQueuePacket *tail; /* queue fills to here. */
|
||||||
SDL_DataQueuePacket *pool; /* these are unused packets. */
|
SDL_DataQueuePacket *pool; /* these are unused packets. */
|
||||||
@@ -41,7 +40,8 @@ struct SDL_DataQueue
|
|||||||
size_t queued_bytes; /* number of bytes of data in the queue. */
|
size_t queued_bytes; /* number of bytes of data in the queue. */
|
||||||
};
|
};
|
||||||
|
|
||||||
static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
|
static void
|
||||||
|
SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
|
||||||
{
|
{
|
||||||
while (packet) {
|
while (packet) {
|
||||||
SDL_DataQueuePacket *next = packet->next;
|
SDL_DataQueuePacket *next = packet->next;
|
||||||
@@ -50,25 +50,25 @@ static void SDL_FreeDataQueueList(SDL_DataQueuePacket *packet)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
|
|
||||||
{
|
|
||||||
SDL_DataQueue *queue = (SDL_DataQueue *)SDL_calloc(1, sizeof(SDL_DataQueue));
|
|
||||||
|
|
||||||
if (queue == NULL) {
|
/* this all expects that you managed thread safety elsewhere. */
|
||||||
|
|
||||||
|
SDL_DataQueue *
|
||||||
|
SDL_NewDataQueue(const size_t _packetlen, const size_t initialslack)
|
||||||
|
{
|
||||||
|
SDL_DataQueue *queue = (SDL_DataQueue *) SDL_malloc(sizeof (SDL_DataQueue));
|
||||||
|
|
||||||
|
if (!queue) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
const size_t packetlen = _packetlen ? _packetlen : 1024;
|
const size_t packetlen = _packetlen ? _packetlen : 1024;
|
||||||
const size_t wantpackets = (initialslack + (packetlen - 1)) / packetlen;
|
const size_t wantpackets = (initialslack + (packetlen - 1)) / packetlen;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
|
SDL_zerop(queue);
|
||||||
queue->packet_size = packetlen;
|
queue->packet_size = packetlen;
|
||||||
|
|
||||||
queue->lock = SDL_CreateMutex();
|
|
||||||
if (!queue->lock) {
|
|
||||||
SDL_free(queue);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0; i < wantpackets; i++) {
|
for (i = 0; i < wantpackets; i++) {
|
||||||
SDL_DataQueuePacket *packet = (SDL_DataQueuePacket *) SDL_malloc(sizeof (SDL_DataQueuePacket) + packetlen);
|
SDL_DataQueuePacket *packet = (SDL_DataQueuePacket *) SDL_malloc(sizeof (SDL_DataQueuePacket) + packetlen);
|
||||||
if (packet) { /* don't care if this fails, we'll deal later. */
|
if (packet) { /* don't care if this fails, we'll deal later. */
|
||||||
@@ -83,17 +83,18 @@ SDL_DataQueue *SDL_NewDataQueue(const size_t _packetlen, const size_t initialsla
|
|||||||
return queue;
|
return queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_FreeDataQueue(SDL_DataQueue *queue)
|
void
|
||||||
|
SDL_FreeDataQueue(SDL_DataQueue *queue)
|
||||||
{
|
{
|
||||||
if (queue) {
|
if (queue) {
|
||||||
SDL_FreeDataQueueList(queue->head);
|
SDL_FreeDataQueueList(queue->head);
|
||||||
SDL_FreeDataQueueList(queue->pool);
|
SDL_FreeDataQueueList(queue->pool);
|
||||||
SDL_DestroyMutex(queue->lock);
|
|
||||||
SDL_free(queue);
|
SDL_free(queue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
|
void
|
||||||
|
SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
|
||||||
{
|
{
|
||||||
const size_t packet_size = queue ? queue->packet_size : 1;
|
const size_t packet_size = queue ? queue->packet_size : 1;
|
||||||
const size_t slackpackets = (slack + (packet_size-1)) / packet_size;
|
const size_t slackpackets = (slack + (packet_size-1)) / packet_size;
|
||||||
@@ -101,12 +102,10 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
|
|||||||
SDL_DataQueuePacket *prev = NULL;
|
SDL_DataQueuePacket *prev = NULL;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
|
||||||
if (queue == NULL) {
|
if (!queue) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(queue->lock);
|
|
||||||
|
|
||||||
packet = queue->head;
|
packet = queue->head;
|
||||||
|
|
||||||
/* merge the available pool and the current queue into one list. */
|
/* merge the available pool and the current queue into one list. */
|
||||||
@@ -134,13 +133,11 @@ void SDL_ClearDataQueue(SDL_DataQueue *queue, const size_t slack)
|
|||||||
queue->pool = NULL;
|
queue->pool = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
|
|
||||||
SDL_FreeDataQueueList(packet); /* free extra packets */
|
SDL_FreeDataQueueList(packet); /* free extra packets */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* You must hold queue->lock before calling this! */
|
static SDL_DataQueuePacket *
|
||||||
static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
|
AllocateDataQueuePacket(SDL_DataQueue *queue)
|
||||||
{
|
{
|
||||||
SDL_DataQueuePacket *packet;
|
SDL_DataQueuePacket *packet;
|
||||||
|
|
||||||
@@ -172,7 +169,9 @@ static SDL_DataQueuePacket *AllocateDataQueuePacket(SDL_DataQueue *queue)
|
|||||||
return packet;
|
return packet;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
|
|
||||||
|
int
|
||||||
|
SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _len)
|
||||||
{
|
{
|
||||||
size_t len = _len;
|
size_t len = _len;
|
||||||
const Uint8 *data = (const Uint8 *) _data;
|
const Uint8 *data = (const Uint8 *) _data;
|
||||||
@@ -182,25 +181,23 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
|
|||||||
size_t origlen;
|
size_t origlen;
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
|
|
||||||
if (queue == NULL) {
|
if (!queue) {
|
||||||
return SDL_InvalidParamError("queue");
|
return SDL_InvalidParamError("queue");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(queue->lock);
|
|
||||||
|
|
||||||
orighead = queue->head;
|
orighead = queue->head;
|
||||||
origtail = queue->tail;
|
origtail = queue->tail;
|
||||||
origlen = origtail ? origtail->datalen : 0;
|
origlen = origtail ? origtail->datalen : 0;
|
||||||
|
|
||||||
while (len > 0) {
|
while (len > 0) {
|
||||||
SDL_DataQueuePacket *packet = queue->tail;
|
SDL_DataQueuePacket *packet = queue->tail;
|
||||||
SDL_assert(packet == NULL || (packet->datalen <= packet_size));
|
SDL_assert(!packet || (packet->datalen <= packet_size));
|
||||||
if (packet == NULL || (packet->datalen >= packet_size)) {
|
if (!packet || (packet->datalen >= packet_size)) {
|
||||||
/* tail packet missing or completely full; we need a new packet. */
|
/* tail packet missing or completely full; we need a new packet. */
|
||||||
packet = AllocateDataQueuePacket(queue);
|
packet = AllocateDataQueuePacket(queue);
|
||||||
if (packet == NULL) {
|
if (!packet) {
|
||||||
/* uhoh, reset so we've queued nothing new, free what we can. */
|
/* uhoh, reset so we've queued nothing new, free what we can. */
|
||||||
if (origtail == NULL) {
|
if (!origtail) {
|
||||||
packet = queue->head; /* whole queue. */
|
packet = queue->head; /* whole queue. */
|
||||||
} else {
|
} else {
|
||||||
packet = origtail->next; /* what we added to existing queue. */
|
packet = origtail->next; /* what we added to existing queue. */
|
||||||
@@ -211,7 +208,6 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
|
|||||||
queue->tail = origtail;
|
queue->tail = origtail;
|
||||||
queue->pool = NULL;
|
queue->pool = NULL;
|
||||||
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
SDL_FreeDataQueueList(packet); /* give back what we can. */
|
SDL_FreeDataQueueList(packet); /* give back what we can. */
|
||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
@@ -225,8 +221,6 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *_data, const size_t _
|
|||||||
queue->queued_bytes += datalen;
|
queue->queued_bytes += datalen;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -238,12 +232,10 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
|
|||||||
Uint8 *ptr = buf;
|
Uint8 *ptr = buf;
|
||||||
SDL_DataQueuePacket *packet;
|
SDL_DataQueuePacket *packet;
|
||||||
|
|
||||||
if (queue == NULL) {
|
if (!queue) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(queue->lock);
|
|
||||||
|
|
||||||
for (packet = queue->head; len && packet; packet = packet->next) {
|
for (packet = queue->head; len && packet; packet = packet->next) {
|
||||||
const size_t avail = packet->datalen - packet->startpos;
|
const size_t avail = packet->datalen - packet->startpos;
|
||||||
const size_t cpy = SDL_min(len, avail);
|
const size_t cpy = SDL_min(len, avail);
|
||||||
@@ -254,8 +246,6 @@ SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
|
|||||||
len -= cpy;
|
len -= cpy;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
|
|
||||||
return (size_t) (ptr - buf);
|
return (size_t) (ptr - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -267,12 +257,10 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
|
|||||||
Uint8 *ptr = buf;
|
Uint8 *ptr = buf;
|
||||||
SDL_DataQueuePacket *packet;
|
SDL_DataQueuePacket *packet;
|
||||||
|
|
||||||
if (queue == NULL) {
|
if (!queue) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LockMutex(queue->lock);
|
|
||||||
|
|
||||||
while ((len > 0) && ((packet = queue->head) != NULL)) {
|
while ((len > 0) && ((packet = queue->head) != NULL)) {
|
||||||
const size_t avail = packet->datalen - packet->startpos;
|
const size_t avail = packet->datalen - packet->startpos;
|
||||||
const size_t cpy = SDL_min(len, avail);
|
const size_t cpy = SDL_min(len, avail);
|
||||||
@@ -298,26 +286,53 @@ SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *_buf, const size_t _len)
|
|||||||
queue->tail = NULL; /* in case we drained the queue entirely. */
|
queue->tail = NULL; /* in case we drained the queue entirely. */
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
|
|
||||||
return (size_t) (ptr - buf);
|
return (size_t) (ptr - buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
SDL_CountDataQueue(SDL_DataQueue *queue)
|
SDL_CountDataQueue(SDL_DataQueue *queue)
|
||||||
{
|
{
|
||||||
size_t retval = 0;
|
return queue ? queue->queued_bytes : 0;
|
||||||
if (queue) {
|
|
||||||
SDL_LockMutex(queue->lock);
|
|
||||||
retval = queue->queued_bytes;
|
|
||||||
SDL_UnlockMutex(queue->lock);
|
|
||||||
}
|
|
||||||
return retval;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_mutex *SDL_GetDataQueueMutex(SDL_DataQueue *queue)
|
void *
|
||||||
|
SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len)
|
||||||
{
|
{
|
||||||
return queue ? queue->lock : NULL;
|
SDL_DataQueuePacket *packet;
|
||||||
|
|
||||||
|
if (!queue) {
|
||||||
|
SDL_InvalidParamError("queue");
|
||||||
|
return NULL;
|
||||||
|
} else if (len == 0) {
|
||||||
|
SDL_InvalidParamError("len");
|
||||||
|
return NULL;
|
||||||
|
} else if (len > queue->packet_size) {
|
||||||
|
SDL_SetError("len is larger than packet size");
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
packet = queue->head;
|
||||||
|
if (packet) {
|
||||||
|
const size_t avail = queue->packet_size - packet->datalen;
|
||||||
|
if (len <= avail) { /* we can use the space at end of this packet. */
|
||||||
|
void *retval = packet->data + packet->datalen;
|
||||||
|
packet->datalen += len;
|
||||||
|
queue->queued_bytes += len;
|
||||||
|
return retval;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Need a fresh packet. */
|
||||||
|
packet = AllocateDataQueuePacket(queue);
|
||||||
|
if (!packet) {
|
||||||
|
SDL_OutOfMemory();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
packet->datalen = len;
|
||||||
|
queue->queued_bytes += len;
|
||||||
|
return packet->data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
||||||
+16
-1
@@ -33,8 +33,23 @@ int SDL_WriteToDataQueue(SDL_DataQueue *queue, const void *data, const size_t le
|
|||||||
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
size_t SDL_ReadFromDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
||||||
size_t SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
size_t SDL_PeekIntoDataQueue(SDL_DataQueue *queue, void *buf, const size_t len);
|
||||||
size_t SDL_CountDataQueue(SDL_DataQueue *queue);
|
size_t SDL_CountDataQueue(SDL_DataQueue *queue);
|
||||||
SDL_mutex *SDL_GetDataQueueMutex(SDL_DataQueue *queue); /* don't destroy this, obviously. */
|
|
||||||
|
/* this sets a section of the data queue aside (possibly allocating memory for it)
|
||||||
|
as if it's been written to, but returns a pointer to that space. You may write
|
||||||
|
to this space until a read would consume it. Writes (and other calls to this
|
||||||
|
function) will safely append their data after this reserved space and can
|
||||||
|
be in flight at the same time. There is no thread safety.
|
||||||
|
If there isn't an existing block of memory that can contain the reserved
|
||||||
|
space, one will be allocated for it. You can not (currently) allocate
|
||||||
|
a space larger than the packetlen requested in SDL_NewDataQueue.
|
||||||
|
Returned buffer is uninitialized.
|
||||||
|
This lets you avoid an extra copy in some cases, but it's safer to use
|
||||||
|
SDL_WriteToDataQueue() unless you know what you're doing.
|
||||||
|
Returns pointer to buffer of at least (len) bytes, NULL on error.
|
||||||
|
*/
|
||||||
|
void *SDL_ReserveSpaceInDataQueue(SDL_DataQueue *queue, const size_t len);
|
||||||
|
|
||||||
#endif /* SDL_dataqueue_h_ */
|
#endif /* SDL_dataqueue_h_ */
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
||||||
+15
-7
@@ -25,7 +25,8 @@
|
|||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
#include "SDL_error_c.h"
|
#include "SDL_error_c.h"
|
||||||
|
|
||||||
int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
int
|
||||||
|
SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
/* Ignore call if invalid format pointer was passed */
|
/* Ignore call if invalid format pointer was passed */
|
||||||
if (fmt != NULL) {
|
if (fmt != NULL) {
|
||||||
@@ -46,11 +47,12 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
error->str = str;
|
error->str = str;
|
||||||
error->len = len;
|
error->len = len;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
(void)SDL_vsnprintf(error->str, error->len, fmt, ap);
|
SDL_vsnprintf(error->str, error->len, fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
|
if (SDL_LogGetPriority(SDL_LOG_CATEGORY_ERROR) <= SDL_LOG_PRIORITY_DEBUG) {
|
||||||
/* If we are in debug mode, print out the error message */
|
/* If we are in debug mode, print out the error message */
|
||||||
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
|
SDL_LogDebug(SDL_LOG_CATEGORY_ERROR, "%s", error->str);
|
||||||
@@ -61,19 +63,22 @@ int SDL_SetError(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Available for backwards compatibility */
|
/* Available for backwards compatibility */
|
||||||
const char *SDL_GetError(void)
|
const char *
|
||||||
|
SDL_GetError(void)
|
||||||
{
|
{
|
||||||
const SDL_error *error = SDL_GetErrBuf();
|
const SDL_error *error = SDL_GetErrBuf();
|
||||||
return error->error ? error->str : "";
|
return error->error ? error->str : "";
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ClearError(void)
|
void
|
||||||
|
SDL_ClearError(void)
|
||||||
{
|
{
|
||||||
SDL_GetErrBuf()->error = 0;
|
SDL_GetErrBuf()->error = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Very common errors go here */
|
/* Very common errors go here */
|
||||||
int SDL_Error(SDL_errorcode code)
|
int
|
||||||
|
SDL_Error(SDL_errorcode code)
|
||||||
{
|
{
|
||||||
switch (code) {
|
switch (code) {
|
||||||
case SDL_ENOMEM:
|
case SDL_ENOMEM:
|
||||||
@@ -92,7 +97,8 @@ int SDL_Error(SDL_errorcode code)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TEST_ERROR
|
#ifdef TEST_ERROR
|
||||||
int main(int argc, char *argv[])
|
int
|
||||||
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char buffer[BUFSIZ + 1];
|
char buffer[BUFSIZ + 1];
|
||||||
|
|
||||||
@@ -107,7 +113,9 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char *SDL_GetErrorMsg(char *errstr, int maxlen)
|
|
||||||
|
char *
|
||||||
|
SDL_GetErrorMsg(char *errstr, int maxlen)
|
||||||
{
|
{
|
||||||
const SDL_error *error = SDL_GetErrBuf();
|
const SDL_error *error = SDL_GetErrBuf();
|
||||||
|
|
||||||
|
|||||||
+3
-3
@@ -52,15 +52,15 @@ void SDL_GUIDToString(SDL_GUID guid, char *pszGUID, int cbGUID)
|
|||||||
static unsigned char nibble(unsigned char c)
|
static unsigned char nibble(unsigned char c)
|
||||||
{
|
{
|
||||||
if ((c >= '0') && (c <= '9')) {
|
if ((c >= '0') && (c <= '9')) {
|
||||||
return c - '0';
|
return (c - '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c >= 'A') && (c <= 'F')) {
|
if ((c >= 'A') && (c <= 'F')) {
|
||||||
return c - 'A' + 0x0a;
|
return (c - 'A' + 0x0a);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((c >= 'a') && (c <= 'f')) {
|
if ((c >= 'a') && (c <= 'f')) {
|
||||||
return c - 'a' + 0x0a;
|
return (c - 'a' + 0x0a);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* received an invalid character, and no real way to return an error */
|
/* received an invalid character, and no real way to return an error */
|
||||||
|
|||||||
+31
-22
@@ -24,18 +24,17 @@
|
|||||||
#include "SDL_error.h"
|
#include "SDL_error.h"
|
||||||
#include "SDL_hints_c.h"
|
#include "SDL_hints_c.h"
|
||||||
|
|
||||||
|
|
||||||
/* Assuming there aren't many hints set and they aren't being queried in
|
/* Assuming there aren't many hints set and they aren't being queried in
|
||||||
critical performance paths, we'll just use linked lists here.
|
critical performance paths, we'll just use linked lists here.
|
||||||
*/
|
*/
|
||||||
typedef struct SDL_HintWatch
|
typedef struct SDL_HintWatch {
|
||||||
{
|
|
||||||
SDL_HintCallback callback;
|
SDL_HintCallback callback;
|
||||||
void *userdata;
|
void *userdata;
|
||||||
struct SDL_HintWatch *next;
|
struct SDL_HintWatch *next;
|
||||||
} SDL_HintWatch;
|
} SDL_HintWatch;
|
||||||
|
|
||||||
typedef struct SDL_Hint
|
typedef struct SDL_Hint {
|
||||||
{
|
|
||||||
char *name;
|
char *name;
|
||||||
char *value;
|
char *value;
|
||||||
SDL_HintPriority priority;
|
SDL_HintPriority priority;
|
||||||
@@ -45,13 +44,15 @@ typedef struct SDL_Hint
|
|||||||
|
|
||||||
static SDL_Hint *SDL_hints;
|
static SDL_Hint *SDL_hints;
|
||||||
|
|
||||||
SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPriority priority)
|
SDL_bool
|
||||||
|
SDL_SetHintWithPriority(const char *name, const char *value,
|
||||||
|
SDL_HintPriority priority)
|
||||||
{
|
{
|
||||||
const char *env;
|
const char *env;
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
SDL_HintWatch *entry;
|
SDL_HintWatch *entry;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (!name) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
if (hint->value != value &&
|
if (hint->value != value &&
|
||||||
(value == NULL || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
|
(!value || !hint->value || SDL_strcmp(hint->value, value) != 0)) {
|
||||||
for (entry = hint->callbacks; entry; ) {
|
for (entry = hint->callbacks; entry; ) {
|
||||||
/* Save the next entry in case this one is deleted */
|
/* Save the next entry in case this one is deleted */
|
||||||
SDL_HintWatch *next = entry->next;
|
SDL_HintWatch *next = entry->next;
|
||||||
@@ -83,7 +84,7 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
|
|||||||
|
|
||||||
/* Couldn't find the hint, add a new one */
|
/* Couldn't find the hint, add a new one */
|
||||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||||
if (hint == NULL) {
|
if (!hint) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
hint->name = SDL_strdup(name);
|
hint->name = SDL_strdup(name);
|
||||||
@@ -95,13 +96,14 @@ SDL_bool SDL_SetHintWithPriority(const char *name, const char *value, SDL_HintPr
|
|||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_ResetHint(const char *name)
|
SDL_bool
|
||||||
|
SDL_ResetHint(const char *name)
|
||||||
{
|
{
|
||||||
const char *env;
|
const char *env;
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
SDL_HintWatch *entry;
|
SDL_HintWatch *entry;
|
||||||
|
|
||||||
if (name == NULL) {
|
if (!name) {
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -127,7 +129,8 @@ SDL_bool SDL_ResetHint(const char *name)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ResetHints(void)
|
void
|
||||||
|
SDL_ResetHints(void)
|
||||||
{
|
{
|
||||||
const char *env;
|
const char *env;
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
@@ -151,12 +154,14 @@ void SDL_ResetHints(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_SetHint(const char *name, const char *value)
|
SDL_bool
|
||||||
|
SDL_SetHint(const char *name, const char *value)
|
||||||
{
|
{
|
||||||
return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL);
|
return SDL_SetHintWithPriority(name, value, SDL_HINT_NORMAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SDL_GetHint(const char *name)
|
const char *
|
||||||
|
SDL_GetHint(const char *name)
|
||||||
{
|
{
|
||||||
const char *env;
|
const char *env;
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
@@ -173,9 +178,10 @@ const char *SDL_GetHint(const char *name)
|
|||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value)
|
SDL_bool
|
||||||
|
SDL_GetStringBoolean(const char *value, SDL_bool default_value)
|
||||||
{
|
{
|
||||||
if (value == NULL || !*value) {
|
if (!value || !*value) {
|
||||||
return default_value;
|
return default_value;
|
||||||
}
|
}
|
||||||
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
|
if (*value == '0' || SDL_strcasecmp(value, "false") == 0) {
|
||||||
@@ -184,19 +190,21 @@ SDL_bool SDL_GetStringBoolean(const char *value, SDL_bool default_value)
|
|||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
SDL_bool
|
||||||
|
SDL_GetHintBoolean(const char *name, SDL_bool default_value)
|
||||||
{
|
{
|
||||||
const char *hint = SDL_GetHint(name);
|
const char *hint = SDL_GetHint(name);
|
||||||
return SDL_GetStringBoolean(hint, default_value);
|
return SDL_GetStringBoolean(hint, default_value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
void
|
||||||
|
SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
SDL_HintWatch *entry;
|
SDL_HintWatch *entry;
|
||||||
const char *value;
|
const char *value;
|
||||||
|
|
||||||
if (name == NULL || !*name) {
|
if (!name || !*name) {
|
||||||
SDL_InvalidParamError("name");
|
SDL_InvalidParamError("name");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -208,7 +216,7 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
|
|||||||
SDL_DelHintCallback(name, callback, userdata);
|
SDL_DelHintCallback(name, callback, userdata);
|
||||||
|
|
||||||
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
entry = (SDL_HintWatch *)SDL_malloc(sizeof(*entry));
|
||||||
if (entry == NULL) {
|
if (!entry) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -220,10 +228,10 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hint == NULL) {
|
if (!hint) {
|
||||||
/* Need to add a hint entry for this watcher */
|
/* Need to add a hint entry for this watcher */
|
||||||
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
hint = (SDL_Hint *)SDL_malloc(sizeof(*hint));
|
||||||
if (hint == NULL) {
|
if (!hint) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
SDL_free(entry);
|
SDL_free(entry);
|
||||||
return;
|
return;
|
||||||
@@ -251,7 +259,8 @@ void SDL_AddHintCallback(const char *name, SDL_HintCallback callback, void *user
|
|||||||
callback(userdata, name, value, value);
|
callback(userdata, name, value, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
void
|
||||||
|
SDL_DelHintCallback(const char *name, SDL_HintCallback callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_Hint *hint;
|
SDL_Hint *hint;
|
||||||
SDL_HintWatch *entry, *prev;
|
SDL_HintWatch *entry, *prev;
|
||||||
|
|||||||
+1
-6
@@ -37,12 +37,7 @@
|
|||||||
|
|
||||||
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
|
#define SDL_MAX_SMALL_ALLOC_STACKSIZE 128
|
||||||
#define SDL_small_alloc(type, count, pisstack) ( (*(pisstack) = ((sizeof(type)*(count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type*)SDL_malloc(sizeof(type)*(count))) )
|
#define SDL_small_alloc(type, count, pisstack) ( (*(pisstack) = ((sizeof(type)*(count)) < SDL_MAX_SMALL_ALLOC_STACKSIZE)), (*(pisstack) ? SDL_stack_alloc(type, count) : (type*)SDL_malloc(sizeof(type)*(count))) )
|
||||||
#define SDL_small_free(ptr, isstack) \
|
#define SDL_small_free(ptr, isstack) if ((isstack)) { SDL_stack_free(ptr); } else { SDL_free(ptr); }
|
||||||
if ((isstack)) { \
|
|
||||||
SDL_stack_free(ptr); \
|
|
||||||
} else { \
|
|
||||||
SDL_free(ptr); \
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "dynapi/SDL_dynapi.h"
|
#include "dynapi/SDL_dynapi.h"
|
||||||
|
|
||||||
|
|||||||
+8
-4
@@ -24,7 +24,8 @@
|
|||||||
#include "./SDL_list.h"
|
#include "./SDL_list.h"
|
||||||
|
|
||||||
/* Push */
|
/* Push */
|
||||||
int SDL_ListAdd(SDL_ListNode **head, void *ent)
|
int
|
||||||
|
SDL_ListAdd(SDL_ListNode **head, void *ent)
|
||||||
{
|
{
|
||||||
SDL_ListNode *node = SDL_malloc(sizeof (*node));
|
SDL_ListNode *node = SDL_malloc(sizeof (*node));
|
||||||
|
|
||||||
@@ -39,7 +40,8 @@ int SDL_ListAdd(SDL_ListNode **head, void *ent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Pop from end as a FIFO (if add with SDL_ListAdd) */
|
/* Pop from end as a FIFO (if add with SDL_ListAdd) */
|
||||||
void SDL_ListPop(SDL_ListNode **head, void **ent)
|
void
|
||||||
|
SDL_ListPop(SDL_ListNode **head, void **ent)
|
||||||
{
|
{
|
||||||
SDL_ListNode **ptr = head;
|
SDL_ListNode **ptr = head;
|
||||||
|
|
||||||
@@ -60,7 +62,8 @@ void SDL_ListPop(SDL_ListNode **head, void **ent)
|
|||||||
*ptr = NULL;
|
*ptr = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ListRemove(SDL_ListNode **head, void *ent)
|
void
|
||||||
|
SDL_ListRemove(SDL_ListNode **head, void *ent)
|
||||||
{
|
{
|
||||||
SDL_ListNode **ptr = head;
|
SDL_ListNode **ptr = head;
|
||||||
|
|
||||||
@@ -75,7 +78,8 @@ void SDL_ListRemove(SDL_ListNode **head, void *ent)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ListClear(SDL_ListNode **head)
|
void
|
||||||
|
SDL_ListClear(SDL_ListNode **head)
|
||||||
{
|
{
|
||||||
SDL_ListNode *l = *head;
|
SDL_ListNode *l = *head;
|
||||||
*head = NULL;
|
*head = NULL;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ typedef struct SDL_ListNode
|
|||||||
struct SDL_ListNode *next;
|
struct SDL_ListNode *next;
|
||||||
} SDL_ListNode;
|
} SDL_ListNode;
|
||||||
|
|
||||||
|
|
||||||
int SDL_ListAdd(SDL_ListNode **head, void *ent);
|
int SDL_ListAdd(SDL_ListNode **head, void *ent);
|
||||||
void SDL_ListPop(SDL_ListNode **head, void **ent);
|
void SDL_ListPop(SDL_ListNode **head, void **ent);
|
||||||
void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
void SDL_ListRemove(SDL_ListNode **head, void *ent);
|
||||||
|
|||||||
+56
-38
@@ -41,6 +41,7 @@
|
|||||||
|
|
||||||
#include "stdlib/SDL_vacopy.h"
|
#include "stdlib/SDL_vacopy.h"
|
||||||
|
|
||||||
|
|
||||||
/* The size of the stack buffer to use for rendering log messages. */
|
/* The size of the stack buffer to use for rendering log messages. */
|
||||||
#define SDL_MAX_LOG_MESSAGE_STACK 256
|
#define SDL_MAX_LOG_MESSAGE_STACK 256
|
||||||
|
|
||||||
@@ -104,15 +105,17 @@ static int SDL_android_priority[SDL_NUM_LOG_PRIORITIES] = {
|
|||||||
};
|
};
|
||||||
#endif /* __ANDROID__ */
|
#endif /* __ANDROID__ */
|
||||||
|
|
||||||
void SDL_LogInit(void)
|
void
|
||||||
|
SDL_LogInit(void)
|
||||||
{
|
{
|
||||||
if (log_function_mutex == NULL) {
|
if (!log_function_mutex) {
|
||||||
/* if this fails we'll try to continue without it. */
|
/* if this fails we'll try to continue without it. */
|
||||||
log_function_mutex = SDL_CreateMutex();
|
log_function_mutex = SDL_CreateMutex();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogQuit(void)
|
void
|
||||||
|
SDL_LogQuit(void)
|
||||||
{
|
{
|
||||||
SDL_LogResetPriorities();
|
SDL_LogResetPriorities();
|
||||||
if (log_function_mutex) {
|
if (log_function_mutex) {
|
||||||
@@ -121,7 +124,8 @@ void SDL_LogQuit(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogSetAllPriority(SDL_LogPriority priority)
|
void
|
||||||
|
SDL_LogSetAllPriority(SDL_LogPriority priority)
|
||||||
{
|
{
|
||||||
SDL_LogLevel *entry;
|
SDL_LogLevel *entry;
|
||||||
|
|
||||||
@@ -133,7 +137,8 @@ void SDL_LogSetAllPriority(SDL_LogPriority priority)
|
|||||||
SDL_application_priority = priority;
|
SDL_application_priority = priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogSetPriority(int category, SDL_LogPriority priority)
|
void
|
||||||
|
SDL_LogSetPriority(int category, SDL_LogPriority priority)
|
||||||
{
|
{
|
||||||
SDL_LogLevel *entry;
|
SDL_LogLevel *entry;
|
||||||
|
|
||||||
@@ -154,7 +159,8 @@ void SDL_LogSetPriority(int category, SDL_LogPriority priority)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_LogPriority SDL_LogGetPriority(int category)
|
SDL_LogPriority
|
||||||
|
SDL_LogGetPriority(int category)
|
||||||
{
|
{
|
||||||
SDL_LogLevel *entry;
|
SDL_LogLevel *entry;
|
||||||
|
|
||||||
@@ -175,7 +181,8 @@ SDL_LogPriority SDL_LogGetPriority(int category)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogResetPriorities(void)
|
void
|
||||||
|
SDL_LogResetPriorities(void)
|
||||||
{
|
{
|
||||||
SDL_LogLevel *entry;
|
SDL_LogLevel *entry;
|
||||||
|
|
||||||
@@ -191,7 +198,8 @@ void SDL_LogResetPriorities(void)
|
|||||||
SDL_test_priority = DEFAULT_TEST_PRIORITY;
|
SDL_test_priority = DEFAULT_TEST_PRIORITY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -200,7 +208,8 @@ void SDL_Log(SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -209,7 +218,8 @@ void SDL_LogVerbose(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -218,7 +228,8 @@ void SDL_LogDebug(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -227,7 +238,8 @@ void SDL_LogInfo(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -236,7 +248,8 @@ void SDL_LogWarn(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -245,7 +258,8 @@ void SDL_LogError(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -254,7 +268,8 @@ void SDL_LogCritical(int category, SDL_PRINTF_FORMAT_STRING const char *fmt, ...
|
|||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
void
|
||||||
|
SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_STRING const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list ap;
|
va_list ap;
|
||||||
|
|
||||||
@@ -264,7 +279,8 @@ void SDL_LogMessage(int category, SDL_LogPriority priority, SDL_PRINTF_FORMAT_ST
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __ANDROID__
|
#ifdef __ANDROID__
|
||||||
static const char *GetCategoryPrefix(int category)
|
static const char *
|
||||||
|
GetCategoryPrefix(int category)
|
||||||
{
|
{
|
||||||
if (category < SDL_LOG_CATEGORY_RESERVED1) {
|
if (category < SDL_LOG_CATEGORY_RESERVED1) {
|
||||||
return SDL_category_prefixes[category];
|
return SDL_category_prefixes[category];
|
||||||
@@ -276,7 +292,8 @@ static const char *GetCategoryPrefix(int category)
|
|||||||
}
|
}
|
||||||
#endif /* __ANDROID__ */
|
#endif /* __ANDROID__ */
|
||||||
|
|
||||||
void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
|
void
|
||||||
|
SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va_list ap)
|
||||||
{
|
{
|
||||||
char *message = NULL;
|
char *message = NULL;
|
||||||
char stack_buf[SDL_MAX_LOG_MESSAGE_STACK];
|
char stack_buf[SDL_MAX_LOG_MESSAGE_STACK];
|
||||||
@@ -299,7 +316,7 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (log_function_mutex == NULL) {
|
if (!log_function_mutex) {
|
||||||
/* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */
|
/* this mutex creation can race if you log from two threads at startup. You should have called SDL_Init first! */
|
||||||
log_function_mutex = SDL_CreateMutex();
|
log_function_mutex = SDL_CreateMutex();
|
||||||
}
|
}
|
||||||
@@ -309,17 +326,15 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
|
|||||||
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
|
len = SDL_vsnprintf(stack_buf, sizeof(stack_buf), fmt, aq);
|
||||||
va_end(aq);
|
va_end(aq);
|
||||||
|
|
||||||
if (len < 0) {
|
if (len < 0)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
/* If message truncated, allocate and re-render */
|
/* If message truncated, allocate and re-render */
|
||||||
if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) {
|
if (len >= sizeof(stack_buf) && SDL_size_add_overflow(len, 1, &len_plus_term) == 0) {
|
||||||
/* Allocate exactly what we need, including the zero-terminator */
|
/* Allocate exactly what we need, including the zero-terminator */
|
||||||
message = (char *)SDL_malloc(len_plus_term);
|
message = (char *)SDL_malloc(len_plus_term);
|
||||||
if (message == NULL) {
|
if (!message)
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
va_copy(aq, ap);
|
va_copy(aq, ap);
|
||||||
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
|
len = SDL_vsnprintf(message, len_plus_term, fmt, aq);
|
||||||
va_end(aq);
|
va_end(aq);
|
||||||
@@ -335,9 +350,15 @@ void SDL_LogMessageV(int category, SDL_LogPriority priority, const char *fmt, va
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (log_function_mutex) {
|
||||||
SDL_LockMutex(log_function_mutex);
|
SDL_LockMutex(log_function_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
SDL_log_function(SDL_log_userdata, category, priority, message);
|
SDL_log_function(SDL_log_userdata, category, priority, message);
|
||||||
|
|
||||||
|
if (log_function_mutex) {
|
||||||
SDL_UnlockMutex(log_function_mutex);
|
SDL_UnlockMutex(log_function_mutex);
|
||||||
|
}
|
||||||
|
|
||||||
/* Free only if dynamically allocated */
|
/* Free only if dynamically allocated */
|
||||||
if (message != stack_buf) {
|
if (message != stack_buf) {
|
||||||
@@ -353,7 +374,8 @@ static int consoleAttached = 0;
|
|||||||
static HANDLE stderrHandle = NULL;
|
static HANDLE stderrHandle = NULL;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
static void SDLCALL
|
||||||
|
SDL_LogOutput(void *userdata, int category, SDL_LogPriority priority,
|
||||||
const char *message)
|
const char *message)
|
||||||
{
|
{
|
||||||
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
|
#if defined(__WIN32__) || defined(__WINRT__) || defined(__GDK__)
|
||||||
@@ -408,7 +430,7 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
|||||||
|
|
||||||
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
|
length = SDL_strlen(SDL_priority_prefixes[priority]) + 2 + SDL_strlen(message) + 1 + 1 + 1;
|
||||||
output = SDL_small_alloc(char, length, &isstack);
|
output = SDL_small_alloc(char, length, &isstack);
|
||||||
(void)SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message);
|
SDL_snprintf(output, length, "%s: %s\r\n", SDL_priority_prefixes[priority], message);
|
||||||
tstr = WIN_UTF8ToString(output);
|
tstr = WIN_UTF8ToString(output);
|
||||||
|
|
||||||
/* Output to debugger */
|
/* Output to debugger */
|
||||||
@@ -453,28 +475,22 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
|||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
pFile = fopen ("SDL_Log.txt", "a");
|
pFile = fopen ("SDL_Log.txt", "a");
|
||||||
if (pFile != NULL) {
|
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
fclose (pFile);
|
||||||
(void)fclose(pFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#elif defined(__VITA__)
|
#elif defined(__VITA__)
|
||||||
{
|
{
|
||||||
FILE* pFile;
|
FILE* pFile;
|
||||||
pFile = fopen ("ux0:/data/SDL_Log.txt", "a");
|
pFile = fopen ("ux0:/data/SDL_Log.txt", "a");
|
||||||
if (pFile != NULL) {
|
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
fclose (pFile);
|
||||||
(void)fclose(pFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#elif defined(__3DS__)
|
#elif defined(__3DS__)
|
||||||
{
|
{
|
||||||
FILE *pFile;
|
FILE *pFile;
|
||||||
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
|
pFile = fopen("sdmc:/3ds/SDL_Log.txt", "a");
|
||||||
if (pFile != NULL) {
|
fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
||||||
(void)fprintf(pFile, "%s: %s\n", SDL_priority_prefixes[priority], message);
|
fclose(pFile);
|
||||||
(void)fclose(pFile);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if HAVE_STDIO_H && \
|
#if HAVE_STDIO_H && \
|
||||||
@@ -486,7 +502,8 @@ static void SDLCALL SDL_LogOutput(void *userdata, int category, SDL_LogPriority
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
|
void
|
||||||
|
SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
|
||||||
{
|
{
|
||||||
if (callback) {
|
if (callback) {
|
||||||
*callback = SDL_log_function;
|
*callback = SDL_log_function;
|
||||||
@@ -496,7 +513,8 @@ void SDL_LogGetOutputFunction(SDL_LogOutputFunction *callback, void **userdata)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
|
void
|
||||||
|
SDL_LogSetOutputFunction(SDL_LogOutputFunction callback, void *userdata)
|
||||||
{
|
{
|
||||||
SDL_log_function = callback;
|
SDL_log_function = callback;
|
||||||
SDL_log_userdata = userdata;
|
SDL_log_userdata = userdata;
|
||||||
|
|||||||
+1
-1
@@ -25,7 +25,7 @@
|
|||||||
/* Common utility functions that aren't in the public API */
|
/* Common utility functions that aren't in the public API */
|
||||||
|
|
||||||
/* Return the smallest power of 2 greater than or equal to 'x' */
|
/* Return the smallest power of 2 greater than or equal to 'x' */
|
||||||
extern int SDL_powerof2(int x);
|
int SDL_powerof2(int x);
|
||||||
|
|
||||||
#endif /* SDL_utils_h_ */
|
#endif /* SDL_utils_h_ */
|
||||||
|
|
||||||
|
|||||||
+25
-16
@@ -50,7 +50,6 @@
|
|||||||
# endif
|
# endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *INDENT-OFF* */ /* clang-format off */
|
|
||||||
#if defined(__WATCOMC__) && defined(__386__)
|
#if defined(__WATCOMC__) && defined(__386__)
|
||||||
SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int));
|
SDL_COMPILE_TIME_ASSERT(intsize, 4==sizeof(int));
|
||||||
#define HAVE_WATCOM_ATOMICS
|
#define HAVE_WATCOM_ATOMICS
|
||||||
@@ -75,9 +74,7 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
|
|||||||
parm [ecx] [eax] \
|
parm [ecx] [eax] \
|
||||||
value [eax] \
|
value [eax] \
|
||||||
modify exact [eax];
|
modify exact [eax];
|
||||||
|
|
||||||
#endif /* __WATCOMC__ && __386__ */
|
#endif /* __WATCOMC__ && __386__ */
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
If any of the operations are not provided then we must emulate some
|
If any of the operations are not provided then we must emulate some
|
||||||
@@ -109,14 +106,16 @@ extern __inline int _SDL_xadd_watcom(volatile int *a, int v);
|
|||||||
#if EMULATE_CAS
|
#if EMULATE_CAS
|
||||||
static SDL_SpinLock locks[32];
|
static SDL_SpinLock locks[32];
|
||||||
|
|
||||||
static SDL_INLINE void enterLock(void *a)
|
static SDL_INLINE void
|
||||||
|
enterLock(void *a)
|
||||||
{
|
{
|
||||||
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
||||||
|
|
||||||
SDL_AtomicLock(&locks[index]);
|
SDL_AtomicLock(&locks[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_INLINE void leaveLock(void *a)
|
static SDL_INLINE void
|
||||||
|
leaveLock(void *a)
|
||||||
{
|
{
|
||||||
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
uintptr_t index = ((((uintptr_t)a) >> 3) & 0x1f);
|
||||||
|
|
||||||
@@ -124,11 +123,13 @@ static SDL_INLINE void leaveLock(void *a)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_bool SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
|
|
||||||
|
SDL_bool
|
||||||
|
SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MSC_ATOMICS
|
#ifdef HAVE_MSC_ATOMICS
|
||||||
SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(long) == sizeof(a->value));
|
SDL_COMPILE_TIME_ASSERT(atomic_cas, sizeof(long) == sizeof(a->value));
|
||||||
return _InterlockedCompareExchange((long *)&a->value, (long)newval, (long)oldval) == (long)oldval;
|
return (_InterlockedCompareExchange((long*)&a->value, (long)newval, (long)oldval) == (long)oldval);
|
||||||
#elif defined(HAVE_WATCOM_ATOMICS)
|
#elif defined(HAVE_WATCOM_ATOMICS)
|
||||||
return (SDL_bool) _SDL_cmpxchg_watcom(&a->value, newval, oldval);
|
return (SDL_bool) _SDL_cmpxchg_watcom(&a->value, newval, oldval);
|
||||||
#elif defined(HAVE_GCC_ATOMICS)
|
#elif defined(HAVE_GCC_ATOMICS)
|
||||||
@@ -153,10 +154,11 @@ SDL_bool SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_bool SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
|
SDL_bool
|
||||||
|
SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_MSC_ATOMICS)
|
#if defined(HAVE_MSC_ATOMICS)
|
||||||
return _InterlockedCompareExchangePointer(a, newval, oldval) == oldval;
|
return (_InterlockedCompareExchangePointer(a, newval, oldval) == oldval);
|
||||||
#elif defined(HAVE_WATCOM_ATOMICS)
|
#elif defined(HAVE_WATCOM_ATOMICS)
|
||||||
return (SDL_bool) _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
|
return (SDL_bool) _SDL_cmpxchg_watcom((int *)a, (long)newval, (long)oldval);
|
||||||
#elif defined(HAVE_GCC_ATOMICS)
|
#elif defined(HAVE_GCC_ATOMICS)
|
||||||
@@ -183,7 +185,8 @@ SDL_bool SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AtomicSet(SDL_atomic_t *a, int v)
|
int
|
||||||
|
SDL_AtomicSet(SDL_atomic_t *a, int v)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MSC_ATOMICS
|
#ifdef HAVE_MSC_ATOMICS
|
||||||
SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value));
|
SDL_COMPILE_TIME_ASSERT(atomic_set, sizeof(long) == sizeof(a->value));
|
||||||
@@ -203,7 +206,8 @@ int SDL_AtomicSet(SDL_atomic_t *a, int v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SDL_AtomicSetPtr(void **a, void *v)
|
void*
|
||||||
|
SDL_AtomicSetPtr(void **a, void *v)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_MSC_ATOMICS)
|
#if defined(HAVE_MSC_ATOMICS)
|
||||||
return _InterlockedExchangePointer(a, v);
|
return _InterlockedExchangePointer(a, v);
|
||||||
@@ -222,7 +226,8 @@ void *SDL_AtomicSetPtr(void **a, void *v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AtomicAdd(SDL_atomic_t *a, int v)
|
int
|
||||||
|
SDL_AtomicAdd(SDL_atomic_t *a, int v)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_MSC_ATOMICS
|
#ifdef HAVE_MSC_ATOMICS
|
||||||
SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value));
|
SDL_COMPILE_TIME_ASSERT(atomic_add, sizeof(long) == sizeof(a->value));
|
||||||
@@ -245,7 +250,8 @@ int SDL_AtomicAdd(SDL_atomic_t *a, int v)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AtomicGet(SDL_atomic_t *a)
|
int
|
||||||
|
SDL_AtomicGet(SDL_atomic_t *a)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ATOMIC_LOAD_N
|
#ifdef HAVE_ATOMIC_LOAD_N
|
||||||
return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST);
|
return __atomic_load_n(&a->value, __ATOMIC_SEQ_CST);
|
||||||
@@ -269,7 +275,8 @@ int SDL_AtomicGet(SDL_atomic_t *a)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *SDL_AtomicGetPtr(void **a)
|
void *
|
||||||
|
SDL_AtomicGetPtr(void **a)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_ATOMIC_LOAD_N
|
#ifdef HAVE_ATOMIC_LOAD_N
|
||||||
return __atomic_load_n(a, __ATOMIC_SEQ_CST);
|
return __atomic_load_n(a, __ATOMIC_SEQ_CST);
|
||||||
@@ -292,12 +299,14 @@ void *SDL_AtomicGetPtr(void **a)
|
|||||||
#error This file should be built in arm mode so the mcr instruction is available for memory barriers
|
#error This file should be built in arm mode so the mcr instruction is available for memory barriers
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void SDL_MemoryBarrierReleaseFunction(void)
|
void
|
||||||
|
SDL_MemoryBarrierReleaseFunction(void)
|
||||||
{
|
{
|
||||||
SDL_MemoryBarrierRelease();
|
SDL_MemoryBarrierRelease();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_MemoryBarrierAcquireFunction(void)
|
void
|
||||||
|
SDL_MemoryBarrierAcquireFunction(void)
|
||||||
{
|
{
|
||||||
SDL_MemoryBarrierAcquire();
|
SDL_MemoryBarrierAcquire();
|
||||||
}
|
}
|
||||||
|
|||||||
+19
-28
@@ -48,7 +48,6 @@
|
|||||||
#include <libkern/OSAtomic.h>
|
#include <libkern/OSAtomic.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* *INDENT-OFF* */ /* clang-format off */
|
|
||||||
#if defined(__WATCOMC__) && defined(__386__)
|
#if defined(__WATCOMC__) && defined(__386__)
|
||||||
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
|
SDL_COMPILE_TIME_ASSERT(locksize, 4==sizeof(SDL_SpinLock));
|
||||||
extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
||||||
@@ -58,16 +57,16 @@ extern __inline int _SDL_xchg_watcom(volatile int *a, int v);
|
|||||||
value [eax] \
|
value [eax] \
|
||||||
modify exact [eax];
|
modify exact [eax];
|
||||||
#endif /* __WATCOMC__ && __386__ */
|
#endif /* __WATCOMC__ && __386__ */
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
|
||||||
|
|
||||||
/* This function is where all the magic happens... */
|
/* This function is where all the magic happens... */
|
||||||
SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
SDL_bool
|
||||||
|
SDL_AtomicTryLock(SDL_SpinLock *lock)
|
||||||
{
|
{
|
||||||
#if SDL_ATOMIC_DISABLED
|
#if SDL_ATOMIC_DISABLED
|
||||||
/* Terrible terrible damage */
|
/* Terrible terrible damage */
|
||||||
static SDL_mutex *_spinlock_mutex;
|
static SDL_mutex *_spinlock_mutex;
|
||||||
|
|
||||||
if (_spinlock_mutex == NULL) {
|
if (!_spinlock_mutex) {
|
||||||
/* Race condition on first lock... */
|
/* Race condition on first lock... */
|
||||||
_spinlock_mutex = SDL_CreateMutex();
|
_spinlock_mutex = SDL_CreateMutex();
|
||||||
}
|
}
|
||||||
@@ -82,14 +81,14 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||||
return __sync_lock_test_and_set(lock, 1) == 0;
|
return (__sync_lock_test_and_set(lock, 1) == 0);
|
||||||
|
|
||||||
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
#elif defined(_MSC_VER) && (defined(_M_ARM) || defined(_M_ARM64))
|
||||||
return _InterlockedExchange_acq(lock, 1) == 0;
|
return (_InterlockedExchange_acq(lock, 1) == 0);
|
||||||
|
|
||||||
#elif defined(_MSC_VER)
|
#elif defined(_MSC_VER)
|
||||||
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
|
SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
|
||||||
return InterlockedExchange((long *)lock, 1) == 0;
|
return (InterlockedExchange((long*)lock, 1) == 0);
|
||||||
|
|
||||||
#elif defined(__WATCOMC__) && defined(__386__)
|
#elif defined(__WATCOMC__) && defined(__386__)
|
||||||
return _SDL_xchg_watcom(lock, 1) == 0;
|
return _SDL_xchg_watcom(lock, 1) == 0;
|
||||||
@@ -105,37 +104,29 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
if (__cpucap_have_rex()) {
|
if (__cpucap_have_rex()) {
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
|
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
|
||||||
: "=&r"(result)
|
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
|
||||||
: "r"(1), "r"(lock)
|
return (result == 0);
|
||||||
: "cc", "memory");
|
|
||||||
return result == 0;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"swp %0, %1, [%2]\n"
|
"swp %0, %1, [%2]\n"
|
||||||
: "=&r,&r"(result)
|
: "=&r,&r" (result) : "r,0" (1), "r,r" (lock) : "memory");
|
||||||
: "r,0"(1), "r,r"(lock)
|
return (result == 0);
|
||||||
: "memory");
|
|
||||||
return result == 0;
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) && defined(__arm__)
|
#elif defined(__GNUC__) && defined(__arm__)
|
||||||
int result;
|
int result;
|
||||||
__asm__ __volatile__ (
|
__asm__ __volatile__ (
|
||||||
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
|
"ldrex %0, [%2]\nteq %0, #0\nstrexeq %0, %1, [%2]"
|
||||||
: "=&r"(result)
|
: "=&r" (result) : "r" (1), "r" (lock) : "cc", "memory");
|
||||||
: "r"(1), "r"(lock)
|
return (result == 0);
|
||||||
: "cc", "memory");
|
|
||||||
return result == 0;
|
|
||||||
|
|
||||||
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))
|
||||||
int result;
|
int result;
|
||||||
__asm__ __volatile__(
|
__asm__ __volatile__(
|
||||||
"lock ; xchgl %0, (%1)\n"
|
"lock ; xchgl %0, (%1)\n"
|
||||||
: "=r"(result)
|
: "=r" (result) : "r" (lock), "0" (1) : "cc", "memory");
|
||||||
: "r"(lock), "0"(1)
|
return (result == 0);
|
||||||
: "cc", "memory");
|
|
||||||
return result == 0;
|
|
||||||
|
|
||||||
#elif defined(__MACOSX__) || defined(__IPHONEOS__)
|
#elif defined(__MACOSX__) || defined(__IPHONEOS__)
|
||||||
/* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */
|
/* Maybe used for PowerPC, but the Intel asm or gcc atomics are favored. */
|
||||||
@@ -159,9 +150,7 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
res = SDL_TRUE;
|
res = SDL_TRUE;
|
||||||
}
|
}
|
||||||
// enable interuption
|
// enable interuption
|
||||||
if (oldintr) {
|
if(oldintr) { EIntr(); }
|
||||||
EIntr();
|
|
||||||
}
|
|
||||||
return res;
|
return res;
|
||||||
#else
|
#else
|
||||||
#error Please implement for your platform.
|
#error Please implement for your platform.
|
||||||
@@ -169,7 +158,8 @@ SDL_bool SDL_AtomicTryLock(SDL_SpinLock *lock)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AtomicLock(SDL_SpinLock *lock)
|
void
|
||||||
|
SDL_AtomicLock(SDL_SpinLock *lock)
|
||||||
{
|
{
|
||||||
int iterations = 0;
|
int iterations = 0;
|
||||||
/* FIXME: Should we have an eventual timeout? */
|
/* FIXME: Should we have an eventual timeout? */
|
||||||
@@ -184,7 +174,8 @@ void SDL_AtomicLock(SDL_SpinLock *lock)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AtomicUnlock(SDL_SpinLock *lock)
|
void
|
||||||
|
SDL_AtomicUnlock(SDL_SpinLock *lock)
|
||||||
{
|
{
|
||||||
#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
#if HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
|
||||||
__sync_lock_release(lock);
|
__sync_lock_release(lock);
|
||||||
|
|||||||
+175
-114
@@ -132,6 +132,7 @@ static const AudioBootStrap *const bootstrap[] = {
|
|||||||
NULL
|
NULL
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#ifdef HAVE_LIBSAMPLERATE_H
|
#ifdef HAVE_LIBSAMPLERATE_H
|
||||||
#ifdef SDL_LIBSAMPLERATE_DYNAMIC
|
#ifdef SDL_LIBSAMPLERATE_DYNAMIC
|
||||||
static void *SRC_lib = NULL;
|
static void *SRC_lib = NULL;
|
||||||
@@ -145,7 +146,8 @@ SRC_STATE *(*SRC_src_delete)(SRC_STATE *state) = NULL;
|
|||||||
const char* (*SRC_src_strerror)(int error) = NULL;
|
const char* (*SRC_src_strerror)(int error) = NULL;
|
||||||
int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels) = NULL;
|
int (*SRC_src_simple)(SRC_DATA *data, int converter_type, int channels) = NULL;
|
||||||
|
|
||||||
static SDL_bool LoadLibSampleRate(void)
|
static SDL_bool
|
||||||
|
LoadLibSampleRate(void)
|
||||||
{
|
{
|
||||||
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE);
|
const char *hint = SDL_GetHint(SDL_HINT_AUDIO_RESAMPLING_MODE);
|
||||||
|
|
||||||
@@ -160,8 +162,6 @@ static SDL_bool LoadLibSampleRate(void)
|
|||||||
SRC_converter = SRC_SINC_MEDIUM_QUALITY;
|
SRC_converter = SRC_SINC_MEDIUM_QUALITY;
|
||||||
} else if (*hint == '3' || SDL_strcasecmp(hint, "best") == 0) {
|
} else if (*hint == '3' || SDL_strcasecmp(hint, "best") == 0) {
|
||||||
SRC_converter = SRC_SINC_BEST_QUALITY;
|
SRC_converter = SRC_SINC_BEST_QUALITY;
|
||||||
} else if (*hint == '4' || SDL_strcasecmp(hint, "linear") == 0) {
|
|
||||||
SRC_converter = SRC_LINEAR;
|
|
||||||
} else {
|
} else {
|
||||||
return SDL_FALSE; /* treat it like "default", don't load anything. */
|
return SDL_FALSE; /* treat it like "default", don't load anything. */
|
||||||
}
|
}
|
||||||
@@ -174,14 +174,12 @@ static SDL_bool LoadLibSampleRate(void)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* *INDENT-OFF* */ /* clang-format off */
|
|
||||||
SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new");
|
SRC_src_new = (SRC_STATE* (*)(int converter_type, int channels, int *error))SDL_LoadFunction(SRC_lib, "src_new");
|
||||||
SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process");
|
SRC_src_process = (int (*)(SRC_STATE *state, SRC_DATA *data))SDL_LoadFunction(SRC_lib, "src_process");
|
||||||
SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset");
|
SRC_src_reset = (int(*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_reset");
|
||||||
SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete");
|
SRC_src_delete = (SRC_STATE* (*)(SRC_STATE *state))SDL_LoadFunction(SRC_lib, "src_delete");
|
||||||
SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror");
|
SRC_src_strerror = (const char* (*)(int error))SDL_LoadFunction(SRC_lib, "src_strerror");
|
||||||
SRC_src_simple = (int(*)(SRC_DATA *data, int converter_type, int channels))SDL_LoadFunction(SRC_lib, "src_simple");
|
SRC_src_simple = (int(*)(SRC_DATA *data, int converter_type, int channels))SDL_LoadFunction(SRC_lib, "src_simple");
|
||||||
/* *INDENT-ON* */ /* clang-format on */
|
|
||||||
|
|
||||||
if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror || !SRC_src_simple) {
|
if (!SRC_src_new || !SRC_src_process || !SRC_src_reset || !SRC_src_delete || !SRC_src_strerror || !SRC_src_simple) {
|
||||||
SDL_UnloadObject(SRC_lib);
|
SDL_UnloadObject(SRC_lib);
|
||||||
@@ -201,7 +199,8 @@ static SDL_bool LoadLibSampleRate(void)
|
|||||||
return SDL_TRUE;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void UnloadLibSampleRate(void)
|
static void
|
||||||
|
UnloadLibSampleRate(void)
|
||||||
{
|
{
|
||||||
#ifdef SDL_LIBSAMPLERATE_DYNAMIC
|
#ifdef SDL_LIBSAMPLERATE_DYNAMIC
|
||||||
if (SRC_lib != NULL) {
|
if (SRC_lib != NULL) {
|
||||||
@@ -219,7 +218,8 @@ static void UnloadLibSampleRate(void)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id)
|
static SDL_AudioDevice *
|
||||||
|
get_audio_device(SDL_AudioDeviceID id)
|
||||||
{
|
{
|
||||||
id--;
|
id--;
|
||||||
if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
|
if ((id >= SDL_arraysize(open_devices)) || (open_devices[id] == NULL)) {
|
||||||
@@ -230,8 +230,10 @@ static SDL_AudioDevice *get_audio_device(SDL_AudioDeviceID id)
|
|||||||
return open_devices[id];
|
return open_devices[id];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* stubs for audio drivers that don't need a specific entry point... */
|
/* stubs for audio drivers that don't need a specific entry point... */
|
||||||
static void SDL_AudioDetectDevices_Default(void)
|
static void
|
||||||
|
SDL_AudioDetectDevices_Default(void)
|
||||||
{
|
{
|
||||||
/* you have to write your own implementation if these assertions fail. */
|
/* you have to write your own implementation if these assertions fail. */
|
||||||
SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice);
|
SDL_assert(current_audio.impl.OnlyHasDefaultOutputDevice);
|
||||||
@@ -243,54 +245,67 @@ static void SDL_AudioDetectDevices_Default(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioThreadInit_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioThreadInit_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioThreadDeinit_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioThreadDeinit_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioWaitDevice_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioWaitDevice_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioPlayDevice_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioPlayDevice_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint8 *SDL_AudioGetDeviceBuf_Default(_THIS)
|
static Uint8 *
|
||||||
|
SDL_AudioGetDeviceBuf_Default(_THIS)
|
||||||
{
|
{
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen)
|
static int
|
||||||
|
SDL_AudioCaptureFromDevice_Default(_THIS, void *buffer, int buflen)
|
||||||
{
|
{
|
||||||
return -1; /* just fail immediately. */
|
return -1; /* just fail immediately. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioFlushCapture_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioFlushCapture_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioCloseDevice_Default(_THIS)
|
static void
|
||||||
|
SDL_AudioCloseDevice_Default(_THIS)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioDeinitialize_Default(void)
|
static void
|
||||||
|
SDL_AudioDeinitialize_Default(void)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioFreeDeviceHandle_Default(void *handle)
|
static void
|
||||||
|
SDL_AudioFreeDeviceHandle_Default(void *handle)
|
||||||
{ /* no-op. */
|
{ /* no-op. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_AudioOpenDevice_Default(_THIS, const char *devname)
|
|
||||||
|
static int
|
||||||
|
SDL_AudioOpenDevice_Default(_THIS, const char *devname)
|
||||||
{
|
{
|
||||||
return SDL_Unsupported();
|
return SDL_Unsupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_INLINE SDL_bool is_in_audio_device_thread(SDL_AudioDevice *device)
|
static SDL_INLINE SDL_bool
|
||||||
|
is_in_audio_device_thread(SDL_AudioDevice * device)
|
||||||
{
|
{
|
||||||
/* The device thread locks the same mutex, but not through the public API.
|
/* The device thread locks the same mutex, but not through the public API.
|
||||||
This check is in case the application, in the audio callback,
|
This check is in case the application, in the audio callback,
|
||||||
@@ -303,27 +318,31 @@ static SDL_INLINE SDL_bool is_in_audio_device_thread(SDL_AudioDevice *device)
|
|||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioLockDevice_Default(SDL_AudioDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang assumes recursive locks */
|
static void
|
||||||
|
SDL_AudioLockDevice_Default(SDL_AudioDevice * device)
|
||||||
{
|
{
|
||||||
if (!is_in_audio_device_thread(device)) {
|
if (!is_in_audio_device_thread(device)) {
|
||||||
SDL_LockMutex(device->mixer_lock);
|
SDL_LockMutex(device->mixer_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_AudioUnlockDevice_Default(SDL_AudioDevice *device) SDL_NO_THREAD_SAFETY_ANALYSIS /* clang assumes recursive locks */
|
static void
|
||||||
|
SDL_AudioUnlockDevice_Default(SDL_AudioDevice * device)
|
||||||
{
|
{
|
||||||
if (!is_in_audio_device_thread(device)) {
|
if (!is_in_audio_device_thread(device)) {
|
||||||
SDL_UnlockMutex(device->mixer_lock);
|
SDL_UnlockMutex(device->mixer_lock);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void finish_audio_entry_points_init(void)
|
static void
|
||||||
|
finish_audio_entry_points_init(void)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Fill in stub functions for unused driver entry points. This lets us
|
* Fill in stub functions for unused driver entry points. This lets us
|
||||||
* blindly call them without having to check for validity first.
|
* blindly call them without having to check for validity first.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#define FILL_STUB(x) \
|
#define FILL_STUB(x) \
|
||||||
if (current_audio.impl.x == NULL) { \
|
if (current_audio.impl.x == NULL) { \
|
||||||
current_audio.impl.x = SDL_Audio##x##_Default; \
|
current_audio.impl.x = SDL_Audio##x##_Default; \
|
||||||
@@ -345,9 +364,11 @@ static void finish_audio_entry_points_init(void)
|
|||||||
#undef FILL_STUB
|
#undef FILL_STUB
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* device hotplug support... */
|
/* device hotplug support... */
|
||||||
|
|
||||||
static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount)
|
static int
|
||||||
|
add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle, SDL_AudioDeviceItem **devices, int *devCount)
|
||||||
{
|
{
|
||||||
int retval = -1;
|
int retval = -1;
|
||||||
SDL_AudioDeviceItem *item;
|
SDL_AudioDeviceItem *item;
|
||||||
@@ -396,7 +417,7 @@ static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle,
|
|||||||
return SDL_OutOfMemory();
|
return SDL_OutOfMemory();
|
||||||
}
|
}
|
||||||
|
|
||||||
(void)SDL_snprintf(replacement, len, "%s (%d)", name, dupenum + 1);
|
SDL_snprintf(replacement, len, "%s (%d)", name, dupenum + 1);
|
||||||
item->dupenum = dupenum;
|
item->dupenum = dupenum;
|
||||||
item->name = replacement;
|
item->name = replacement;
|
||||||
}
|
}
|
||||||
@@ -410,18 +431,21 @@ static int add_audio_device(const char *name, SDL_AudioSpec *spec, void *handle,
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_INLINE int add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle)
|
static SDL_INLINE int
|
||||||
|
add_capture_device(const char *name, SDL_AudioSpec *spec, void *handle)
|
||||||
{
|
{
|
||||||
SDL_assert(current_audio.impl.HasCaptureSupport);
|
SDL_assert(current_audio.impl.HasCaptureSupport);
|
||||||
return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount);
|
return add_audio_device(name, spec, handle, ¤t_audio.inputDevices, ¤t_audio.inputDeviceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_INLINE int add_output_device(const char *name, SDL_AudioSpec *spec, void *handle)
|
static SDL_INLINE int
|
||||||
|
add_output_device(const char *name, SDL_AudioSpec *spec, void *handle)
|
||||||
{
|
{
|
||||||
return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount);
|
return add_audio_device(name, spec, handle, ¤t_audio.outputDevices, ¤t_audio.outputDeviceCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
|
static void
|
||||||
|
free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceItem *item, *next;
|
SDL_AudioDeviceItem *item, *next;
|
||||||
for (item = *devices; item != NULL; item = next) {
|
for (item = *devices; item != NULL; item = next) {
|
||||||
@@ -440,8 +464,10 @@ static void free_device_list(SDL_AudioDeviceItem **devices, int *devCount)
|
|||||||
*devCount = 0;
|
*devCount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* The audio backends call this when a new device is plugged in. */
|
/* The audio backends call this when a new device is plugged in. */
|
||||||
void SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle)
|
void
|
||||||
|
SDL_AddAudioDevice(const SDL_bool iscapture, const char *name, SDL_AudioSpec *spec, void *handle)
|
||||||
{
|
{
|
||||||
const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle);
|
const int device_index = iscapture ? add_capture_device(name, spec, handle) : add_output_device(name, spec, handle);
|
||||||
if (device_index != -1) {
|
if (device_index != -1) {
|
||||||
@@ -487,7 +513,8 @@ void SDL_OpenedAudioDeviceDisconnected(SDL_AudioDevice *device)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
|
static void
|
||||||
|
mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_bool *removedFlag)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceItem *item;
|
SDL_AudioDeviceItem *item;
|
||||||
SDL_assert(handle != NULL);
|
SDL_assert(handle != NULL);
|
||||||
@@ -501,7 +528,8 @@ static void mark_device_removed(void *handle, SDL_AudioDeviceItem *devices, SDL_
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* The audio backends call this when a device is removed from the system. */
|
/* The audio backends call this when a device is removed from the system. */
|
||||||
void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
|
void
|
||||||
|
SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
|
||||||
{
|
{
|
||||||
int device_index;
|
int device_index;
|
||||||
SDL_AudioDevice *device = NULL;
|
SDL_AudioDevice *device = NULL;
|
||||||
@@ -513,9 +541,11 @@ void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
|
|||||||
} else {
|
} else {
|
||||||
mark_device_removed(handle, current_audio.outputDevices, ¤t_audio.outputDevicesRemoved);
|
mark_device_removed(handle, current_audio.outputDevices, ¤t_audio.outputDevicesRemoved);
|
||||||
}
|
}
|
||||||
for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++) {
|
for (device_index = 0; device_index < SDL_arraysize(open_devices); device_index++)
|
||||||
|
{
|
||||||
device = open_devices[device_index];
|
device = open_devices[device_index];
|
||||||
if (device != NULL && device->handle == handle) {
|
if (device != NULL && device->handle == handle)
|
||||||
|
{
|
||||||
device_was_opened = SDL_TRUE;
|
device_was_opened = SDL_TRUE;
|
||||||
SDL_OpenedAudioDeviceDisconnected(device);
|
SDL_OpenedAudioDeviceDisconnected(device);
|
||||||
break;
|
break;
|
||||||
@@ -544,9 +574,12 @@ void SDL_RemoveAudioDevice(const SDL_bool iscapture, void *handle)
|
|||||||
current_audio.impl.FreeDeviceHandle(handle);
|
current_audio.impl.FreeDeviceHandle(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* buffer queueing support... */
|
/* buffer queueing support... */
|
||||||
|
|
||||||
static void SDLCALL SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len)
|
static void SDLCALL
|
||||||
|
SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream, int len)
|
||||||
{
|
{
|
||||||
/* this function always holds the mixer lock before being called. */
|
/* this function always holds the mixer lock before being called. */
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
|
||||||
@@ -566,7 +599,8 @@ static void SDLCALL SDL_BufferQueueDrainCallback(void *userdata, Uint8 *stream,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len)
|
static void SDLCALL
|
||||||
|
SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, int len)
|
||||||
{
|
{
|
||||||
/* this function always holds the mixer lock before being called. */
|
/* this function always holds the mixer lock before being called. */
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) userdata;
|
||||||
@@ -581,7 +615,8 @@ static void SDLCALL SDL_BufferQueueFillCallback(void *userdata, Uint8 *stream, i
|
|||||||
SDL_WriteToDataQueue(device->buffer_queue, stream, len);
|
SDL_WriteToDataQueue(device->buffer_queue, stream, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len)
|
int
|
||||||
|
SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
@@ -603,7 +638,8 @@ int SDL_QueueAudio(SDL_AudioDeviceID devid, const void *data, Uint32 len)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 SDL_DequeueAudio(SDL_AudioDeviceID devid, void *data, Uint32 len)
|
Uint32
|
||||||
|
SDL_DequeueAudio(SDL_AudioDeviceID devid, void *data, Uint32 len)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
Uint32 rc;
|
Uint32 rc;
|
||||||
@@ -621,7 +657,8 @@ Uint32 SDL_DequeueAudio(SDL_AudioDeviceID devid, void *data, Uint32 len)
|
|||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
|
Uint32
|
||||||
|
SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
Uint32 retval = 0;
|
Uint32 retval = 0;
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
@@ -632,7 +669,8 @@ Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
|
|||||||
|
|
||||||
/* Nothing to do unless we're set up for queueing. */
|
/* Nothing to do unless we're set up for queueing. */
|
||||||
if (device->callbackspec.callback == SDL_BufferQueueDrainCallback ||
|
if (device->callbackspec.callback == SDL_BufferQueueDrainCallback ||
|
||||||
device->callbackspec.callback == SDL_BufferQueueFillCallback) {
|
device->callbackspec.callback == SDL_BufferQueueFillCallback)
|
||||||
|
{
|
||||||
current_audio.impl.LockDevice(device);
|
current_audio.impl.LockDevice(device);
|
||||||
retval = (Uint32) SDL_CountDataQueue(device->buffer_queue);
|
retval = (Uint32) SDL_CountDataQueue(device->buffer_queue);
|
||||||
current_audio.impl.UnlockDevice(device);
|
current_audio.impl.UnlockDevice(device);
|
||||||
@@ -641,7 +679,8 @@ Uint32 SDL_GetQueuedAudioSize(SDL_AudioDeviceID devid)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
|
void
|
||||||
|
SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
|
|
||||||
@@ -658,12 +697,10 @@ void SDL_ClearQueuedAudio(SDL_AudioDeviceID devid)
|
|||||||
current_audio.impl.UnlockDevice(device);
|
current_audio.impl.UnlockDevice(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if SDL_AUDIO_DRIVER_ANDROID
|
|
||||||
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* The general mixing thread function */
|
/* The general mixing thread function */
|
||||||
static int SDLCALL SDL_RunAudio(void *devicep)
|
static int SDLCALL
|
||||||
|
SDL_RunAudio(void *devicep)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
|
||||||
void *udata = device->callbackspec.userdata;
|
void *udata = device->callbackspec.userdata;
|
||||||
@@ -676,6 +713,7 @@ static int SDLCALL SDL_RunAudio(void *devicep)
|
|||||||
#if SDL_AUDIO_DRIVER_ANDROID
|
#if SDL_AUDIO_DRIVER_ANDROID
|
||||||
{
|
{
|
||||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||||
|
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -761,7 +799,8 @@ static int SDLCALL SDL_RunAudio(void *devicep)
|
|||||||
|
|
||||||
/* !!! FIXME: this needs to deal with device spec changes. */
|
/* !!! FIXME: this needs to deal with device spec changes. */
|
||||||
/* The general capture thread function */
|
/* The general capture thread function */
|
||||||
static int SDLCALL SDL_CaptureAudio(void *devicep)
|
static int SDLCALL
|
||||||
|
SDL_CaptureAudio(void *devicep)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
|
SDL_AudioDevice *device = (SDL_AudioDevice *) devicep;
|
||||||
const int silence = (int) device->spec.silence;
|
const int silence = (int) device->spec.silence;
|
||||||
@@ -776,6 +815,7 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
|
|||||||
#if SDL_AUDIO_DRIVER_ANDROID
|
#if SDL_AUDIO_DRIVER_ANDROID
|
||||||
{
|
{
|
||||||
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
/* Set thread priority to THREAD_PRIORITY_AUDIO */
|
||||||
|
extern void Android_JNI_AudioSetThreadPriority(int, int);
|
||||||
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
Android_JNI_AudioSetThreadPriority(device->iscapture, device->id);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
@@ -870,11 +910,11 @@ static int SDLCALL SDL_CaptureAudio(void *devicep)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioFormat SDL_ParseAudioFormat(const char *string)
|
|
||||||
|
static SDL_AudioFormat
|
||||||
|
SDL_ParseAudioFormat(const char *string)
|
||||||
{
|
{
|
||||||
#define CHECK_FMT_STRING(x) \
|
#define CHECK_FMT_STRING(x) if (SDL_strcmp(string, #x) == 0) return AUDIO_##x
|
||||||
if (SDL_strcmp(string, #x) == 0) \
|
|
||||||
return AUDIO_##x
|
|
||||||
CHECK_FMT_STRING(U8);
|
CHECK_FMT_STRING(U8);
|
||||||
CHECK_FMT_STRING(S8);
|
CHECK_FMT_STRING(S8);
|
||||||
CHECK_FMT_STRING(U16LSB);
|
CHECK_FMT_STRING(U16LSB);
|
||||||
@@ -897,12 +937,14 @@ static SDL_AudioFormat SDL_ParseAudioFormat(const char *string)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_GetNumAudioDrivers(void)
|
int
|
||||||
|
SDL_GetNumAudioDrivers(void)
|
||||||
{
|
{
|
||||||
return SDL_arraysize(bootstrap) - 1;
|
return SDL_arraysize(bootstrap) - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SDL_GetAudioDriver(int index)
|
const char *
|
||||||
|
SDL_GetAudioDriver(int index)
|
||||||
{
|
{
|
||||||
if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
|
if (index >= 0 && index < SDL_GetNumAudioDrivers()) {
|
||||||
return bootstrap[index]->name;
|
return bootstrap[index]->name;
|
||||||
@@ -910,7 +952,8 @@ const char *SDL_GetAudioDriver(int index)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AudioInit(const char *driver_name)
|
int
|
||||||
|
SDL_AudioInit(const char *driver_name)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE;
|
SDL_bool initialized = SDL_FALSE, tried_to_init = SDL_FALSE;
|
||||||
@@ -1009,13 +1052,15 @@ int SDL_AudioInit(const char *driver_name)
|
|||||||
/*
|
/*
|
||||||
* Get the current audio driver name
|
* Get the current audio driver name
|
||||||
*/
|
*/
|
||||||
const char *SDL_GetCurrentAudioDriver()
|
const char *
|
||||||
|
SDL_GetCurrentAudioDriver()
|
||||||
{
|
{
|
||||||
return current_audio.name;
|
return current_audio.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Clean out devices that we've removed but had to keep around for stability. */
|
/* Clean out devices that we've removed but had to keep around for stability. */
|
||||||
static void clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag)
|
static void
|
||||||
|
clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount, SDL_bool *removedFlag)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceItem *item = *devices;
|
SDL_AudioDeviceItem *item = *devices;
|
||||||
SDL_AudioDeviceItem *prev = NULL;
|
SDL_AudioDeviceItem *prev = NULL;
|
||||||
@@ -1046,7 +1091,9 @@ static void clean_out_device_list(SDL_AudioDeviceItem **devices, int *devCount,
|
|||||||
*removedFlag = SDL_FALSE;
|
*removedFlag = SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_GetNumAudioDevices(int iscapture)
|
|
||||||
|
int
|
||||||
|
SDL_GetNumAudioDevices(int iscapture)
|
||||||
{
|
{
|
||||||
int retval = 0;
|
int retval = 0;
|
||||||
|
|
||||||
@@ -1069,7 +1116,9 @@ int SDL_GetNumAudioDevices(int iscapture)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *SDL_GetAudioDeviceName(int index, int iscapture)
|
|
||||||
|
const char *
|
||||||
|
SDL_GetAudioDeviceName(int index, int iscapture)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceItem *item;
|
SDL_AudioDeviceItem *item;
|
||||||
int i;
|
int i;
|
||||||
@@ -1098,7 +1147,9 @@ const char *SDL_GetAudioDeviceName(int index, int iscapture)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec)
|
|
||||||
|
int
|
||||||
|
SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceItem *item;
|
SDL_AudioDeviceItem *item;
|
||||||
int i, retval;
|
int i, retval;
|
||||||
@@ -1129,7 +1180,9 @@ int SDL_GetAudioDeviceSpec(int index, int iscapture, SDL_AudioSpec *spec)
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
|
|
||||||
|
int
|
||||||
|
SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
|
||||||
{
|
{
|
||||||
if (spec == NULL) {
|
if (spec == NULL) {
|
||||||
return SDL_InvalidParamError("spec");
|
return SDL_InvalidParamError("spec");
|
||||||
@@ -1145,7 +1198,9 @@ int SDL_GetDefaultAudioInfo(char **name, SDL_AudioSpec *spec, int iscapture)
|
|||||||
return current_audio.impl.GetDefaultAudioInfo(name, spec, iscapture);
|
return current_audio.impl.GetDefaultAudioInfo(name, spec, iscapture);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void close_audio_device(SDL_AudioDevice *device)
|
|
||||||
|
static void
|
||||||
|
close_audio_device(SDL_AudioDevice * device)
|
||||||
{
|
{
|
||||||
if (!device) {
|
if (!device) {
|
||||||
return;
|
return;
|
||||||
@@ -1186,55 +1241,35 @@ static void close_audio_device(SDL_AudioDevice *device)
|
|||||||
SDL_free(device);
|
SDL_free(device);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Uint16 GetDefaultSamplesFromFreq(int freq)
|
|
||||||
{
|
|
||||||
/* Pick a default of ~46 ms at desired frequency */
|
|
||||||
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
|
|
||||||
const Uint16 max_sample = (freq / 1000) * 46;
|
|
||||||
Uint16 current_sample = 1;
|
|
||||||
while (current_sample < max_sample) {
|
|
||||||
current_sample *= 2;
|
|
||||||
}
|
|
||||||
return current_sample;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
|
* Sanity check desired AudioSpec for SDL_OpenAudio() in (orig).
|
||||||
* Fills in a sanitized copy in (prepared).
|
* Fills in a sanitized copy in (prepared).
|
||||||
* Returns non-zero if okay, zero on fatal parameters in (orig).
|
* Returns non-zero if okay, zero on fatal parameters in (orig).
|
||||||
*/
|
*/
|
||||||
static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
static int
|
||||||
|
prepare_audiospec(const SDL_AudioSpec * orig, SDL_AudioSpec * prepared)
|
||||||
{
|
{
|
||||||
SDL_copyp(prepared, orig);
|
SDL_copyp(prepared, orig);
|
||||||
|
|
||||||
if (orig->freq == 0) {
|
if (orig->freq == 0) {
|
||||||
static const int DEFAULT_FREQ = 22050;
|
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
|
const char *env = SDL_getenv("SDL_AUDIO_FREQUENCY");
|
||||||
if (env != NULL) {
|
if ((!env) || ((prepared->freq = SDL_atoi(env)) == 0)) {
|
||||||
int freq = SDL_atoi(env);
|
prepared->freq = 22050; /* a reasonable default */
|
||||||
prepared->freq = freq != 0 ? freq : DEFAULT_FREQ;
|
|
||||||
} else {
|
|
||||||
prepared->freq = DEFAULT_FREQ;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orig->format == 0) {
|
if (orig->format == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
|
const char *env = SDL_getenv("SDL_AUDIO_FORMAT");
|
||||||
if (env != NULL) {
|
if ((!env) || ((prepared->format = SDL_ParseAudioFormat(env)) == 0)) {
|
||||||
const SDL_AudioFormat format = SDL_ParseAudioFormat(env);
|
prepared->format = AUDIO_S16; /* a reasonable default */
|
||||||
prepared->format = format != 0 ? format : AUDIO_S16;
|
|
||||||
} else {
|
|
||||||
prepared->format = AUDIO_S16;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (orig->channels == 0) {
|
if (orig->channels == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
const char *env = SDL_getenv("SDL_AUDIO_CHANNELS");
|
||||||
if (env != NULL) {
|
if ((!env) || ((prepared->channels = (Uint8) SDL_atoi(env)) == 0)) {
|
||||||
Uint8 channels = (Uint8)SDL_atoi(env);
|
prepared->channels = 2; /* a reasonable default */
|
||||||
prepared->channels = channels != 0 ? channels : 2;
|
|
||||||
} else {
|
|
||||||
prepared->channels = 2;
|
|
||||||
}
|
}
|
||||||
} else if (orig->channels > 8) {
|
} else if (orig->channels > 8) {
|
||||||
SDL_SetError("Unsupported number of audio channels.");
|
SDL_SetError("Unsupported number of audio channels.");
|
||||||
@@ -1243,11 +1278,15 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
|||||||
|
|
||||||
if (orig->samples == 0) {
|
if (orig->samples == 0) {
|
||||||
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
|
const char *env = SDL_getenv("SDL_AUDIO_SAMPLES");
|
||||||
if (env != NULL) {
|
if ((!env) || ((prepared->samples = (Uint16) SDL_atoi(env)) == 0)) {
|
||||||
Uint16 samples = (Uint16)SDL_atoi(env);
|
/* Pick a default of ~46 ms at desired frequency */
|
||||||
prepared->samples = samples != 0 ? samples : GetDefaultSamplesFromFreq(prepared->freq);
|
/* !!! FIXME: remove this when the non-Po2 resampling is in. */
|
||||||
} else {
|
const int samples = (prepared->freq / 1000) * 46;
|
||||||
prepared->samples = GetDefaultSamplesFromFreq(prepared->freq);
|
int power2 = 1;
|
||||||
|
while (power2 < samples) {
|
||||||
|
power2 *= 2;
|
||||||
|
}
|
||||||
|
prepared->samples = power2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1257,7 +1296,8 @@ static int prepare_audiospec(const SDL_AudioSpec *orig, SDL_AudioSpec *prepared)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
static SDL_AudioDeviceID
|
||||||
|
open_audio_device(const char *devname, int iscapture,
|
||||||
const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
|
const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
|
||||||
int allowed_changes, int min_id)
|
int allowed_changes, int min_id)
|
||||||
{
|
{
|
||||||
@@ -1505,7 +1545,7 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
|||||||
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
|
const size_t stacksize = is_internal_thread ? 64 * 1024 : 0;
|
||||||
char threadname[64];
|
char threadname[64];
|
||||||
|
|
||||||
(void)SDL_snprintf(threadname, sizeof(threadname), "SDLAudio%c%" SDL_PRIu32, (iscapture) ? 'C' : 'P', device->id);
|
SDL_snprintf(threadname, sizeof (threadname), "SDLAudio%c%d", (iscapture) ? 'C' : 'P', (int) device->id);
|
||||||
device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
|
device->thread = SDL_CreateThreadInternal(iscapture ? SDL_CaptureAudio : SDL_RunAudio, threadname, stacksize, device);
|
||||||
|
|
||||||
if (device->thread == NULL) {
|
if (device->thread == NULL) {
|
||||||
@@ -1520,7 +1560,9 @@ static SDL_AudioDeviceID open_audio_device(const char *devname, int iscapture,
|
|||||||
return device->id;
|
return device->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|
||||||
|
int
|
||||||
|
SDL_OpenAudio(SDL_AudioSpec * desired, SDL_AudioSpec * obtained)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceID id = 0;
|
SDL_AudioDeviceID id = 0;
|
||||||
|
|
||||||
@@ -1554,7 +1596,8 @@ int SDL_OpenAudio(SDL_AudioSpec *desired, SDL_AudioSpec *obtained)
|
|||||||
return (id == 0) ? -1 : 0;
|
return (id == 0) ? -1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioDeviceID SDL_OpenAudioDevice(const char *device, int iscapture,
|
SDL_AudioDeviceID
|
||||||
|
SDL_OpenAudioDevice(const char *device, int iscapture,
|
||||||
const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
|
const SDL_AudioSpec * desired, SDL_AudioSpec * obtained,
|
||||||
int allowed_changes)
|
int allowed_changes)
|
||||||
{
|
{
|
||||||
@@ -1562,7 +1605,8 @@ SDL_AudioDeviceID SDL_OpenAudioDevice(const char *device, int iscapture,
|
|||||||
allowed_changes, 2);
|
allowed_changes, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
|
SDL_AudioStatus
|
||||||
|
SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
SDL_AudioStatus status = SDL_AUDIO_STOPPED;
|
SDL_AudioStatus status = SDL_AUDIO_STOPPED;
|
||||||
@@ -1576,12 +1620,15 @@ SDL_AudioStatus SDL_GetAudioDeviceStatus(SDL_AudioDeviceID devid)
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioStatus SDL_GetAudioStatus(void)
|
|
||||||
|
SDL_AudioStatus
|
||||||
|
SDL_GetAudioStatus(void)
|
||||||
{
|
{
|
||||||
return SDL_GetAudioDeviceStatus(1);
|
return SDL_GetAudioDeviceStatus(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
|
void
|
||||||
|
SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
|
||||||
{
|
{
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
if (device) {
|
if (device) {
|
||||||
@@ -1591,12 +1638,15 @@ void SDL_PauseAudioDevice(SDL_AudioDeviceID devid, int pause_on)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_PauseAudio(int pause_on)
|
void
|
||||||
|
SDL_PauseAudio(int pause_on)
|
||||||
{
|
{
|
||||||
SDL_PauseAudioDevice(1, pause_on);
|
SDL_PauseAudioDevice(1, pause_on);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LockAudioDevice(SDL_AudioDeviceID devid)
|
|
||||||
|
void
|
||||||
|
SDL_LockAudioDevice(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
/* Obtain a lock on the mixing buffers */
|
/* Obtain a lock on the mixing buffers */
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
@@ -1605,12 +1655,14 @@ void SDL_LockAudioDevice(SDL_AudioDeviceID devid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_LockAudio(void)
|
void
|
||||||
|
SDL_LockAudio(void)
|
||||||
{
|
{
|
||||||
SDL_LockAudioDevice(1);
|
SDL_LockAudioDevice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
|
void
|
||||||
|
SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
/* Obtain a lock on the mixing buffers */
|
/* Obtain a lock on the mixing buffers */
|
||||||
SDL_AudioDevice *device = get_audio_device(devid);
|
SDL_AudioDevice *device = get_audio_device(devid);
|
||||||
@@ -1619,22 +1671,26 @@ void SDL_UnlockAudioDevice(SDL_AudioDeviceID devid)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_UnlockAudio(void)
|
void
|
||||||
|
SDL_UnlockAudio(void)
|
||||||
{
|
{
|
||||||
SDL_UnlockAudioDevice(1);
|
SDL_UnlockAudioDevice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
|
void
|
||||||
|
SDL_CloseAudioDevice(SDL_AudioDeviceID devid)
|
||||||
{
|
{
|
||||||
close_audio_device(get_audio_device(devid));
|
close_audio_device(get_audio_device(devid));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_CloseAudio(void)
|
void
|
||||||
|
SDL_CloseAudio(void)
|
||||||
{
|
{
|
||||||
SDL_CloseAudioDevice(1);
|
SDL_CloseAudioDevice(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AudioQuit(void)
|
void
|
||||||
|
SDL_AudioQuit(void)
|
||||||
{
|
{
|
||||||
SDL_AudioDeviceID i;
|
SDL_AudioDeviceID i;
|
||||||
|
|
||||||
@@ -1688,7 +1744,8 @@ static SDL_AudioFormat format_list[NUM_FORMATS][NUM_FORMATS] = {
|
|||||||
AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
|
AUDIO_S16LSB, AUDIO_U16MSB, AUDIO_U16LSB, AUDIO_U8, AUDIO_S8},
|
||||||
};
|
};
|
||||||
|
|
||||||
SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
|
SDL_AudioFormat
|
||||||
|
SDL_FirstAudioFormat(SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
|
for (format_idx = 0; format_idx < NUM_FORMATS; ++format_idx) {
|
||||||
if (format_list[format_idx][0] == format) {
|
if (format_list[format_idx][0] == format) {
|
||||||
@@ -1699,7 +1756,8 @@ SDL_AudioFormat SDL_FirstAudioFormat(SDL_AudioFormat format)
|
|||||||
return SDL_NextAudioFormat();
|
return SDL_NextAudioFormat();
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioFormat SDL_NextAudioFormat(void)
|
SDL_AudioFormat
|
||||||
|
SDL_NextAudioFormat(void)
|
||||||
{
|
{
|
||||||
if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
|
if ((format_idx == NUM_FORMATS) || (format_idx_sub == NUM_FORMATS)) {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -1707,7 +1765,8 @@ SDL_AudioFormat SDL_NextAudioFormat(void)
|
|||||||
return format_list[format_idx][format_idx_sub++];
|
return format_list[format_idx][format_idx_sub++];
|
||||||
}
|
}
|
||||||
|
|
||||||
Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format)
|
Uint8
|
||||||
|
SDL_SilenceValueForFormat(const SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
switch (format) {
|
switch (format) {
|
||||||
/* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a
|
/* !!! FIXME: 0x80 isn't perfect for U16, but we can't fit 0x8000 in a
|
||||||
@@ -1718,14 +1777,14 @@ Uint8 SDL_SilenceValueForFormat(const SDL_AudioFormat format)
|
|||||||
case AUDIO_U8:
|
case AUDIO_U8:
|
||||||
return 0x80;
|
return 0x80;
|
||||||
|
|
||||||
default:
|
default: break;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
void
|
||||||
|
SDL_CalculateAudioSpec(SDL_AudioSpec * spec)
|
||||||
{
|
{
|
||||||
spec->silence = SDL_SilenceValueForFormat(spec->format);
|
spec->silence = SDL_SilenceValueForFormat(spec->format);
|
||||||
spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
|
spec->size = SDL_AUDIO_BITSIZE(spec->format) / 8;
|
||||||
@@ -1733,11 +1792,13 @@ void SDL_CalculateAudioSpec(SDL_AudioSpec *spec)
|
|||||||
spec->size *= spec->samples;
|
spec->size *= spec->samples;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Moved here from SDL_mixer.c, since it relies on internals of an opened
|
* Moved here from SDL_mixer.c, since it relies on internals of an opened
|
||||||
* audio device (and is deprecated, by the way!).
|
* audio device (and is deprecated, by the way!).
|
||||||
*/
|
*/
|
||||||
void SDL_MixAudio(Uint8 *dst, const Uint8 *src, Uint32 len, int volume)
|
void
|
||||||
|
SDL_MixAudio(Uint8 * dst, const Uint8 * src, Uint32 len, int volume)
|
||||||
{
|
{
|
||||||
/* Mix the user-level audio format */
|
/* Mix the user-level audio format */
|
||||||
SDL_AudioDevice *device = get_audio_device(1);
|
SDL_AudioDevice *device = get_audio_device(1);
|
||||||
|
|||||||
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */
|
/* DO NOT EDIT, THIS FILE WAS GENERATED BY build-scripts/gen_audio_channel_conversion.c */
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 2))) - 2;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -43,7 +44,8 @@ static void SDLCALL SDL_ConvertMonoToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 3))) - 3;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -66,7 +68,8 @@ static void SDLCALL SDL_ConvertMonoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 4))) - 4;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -90,7 +93,8 @@ static void SDLCALL SDL_ConvertMonoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 5))) - 5;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -115,7 +119,8 @@ static void SDLCALL SDL_ConvertMonoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 6))) - 6;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -141,7 +146,8 @@ static void SDLCALL SDL_ConvertMonoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -168,7 +174,8 @@ static void SDLCALL SDL_ConvertMonoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 1) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 1;
|
||||||
@@ -196,7 +203,8 @@ static void SDLCALL SDL_ConvertMonoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -215,7 +223,8 @@ static void SDLCALL SDL_ConvertStereoToMono(SDL_AudioCVT *cvt, SDL_AudioFormat f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 3))) - 3;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -237,7 +246,8 @@ static void SDLCALL SDL_ConvertStereoTo21(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 4))) - 4;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -260,7 +270,8 @@ static void SDLCALL SDL_ConvertStereoToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 5))) - 5;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -284,7 +295,8 @@ static void SDLCALL SDL_ConvertStereoTo41(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 6))) - 6;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -309,7 +321,8 @@ static void SDLCALL SDL_ConvertStereoTo51(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -335,7 +348,8 @@ static void SDLCALL SDL_ConvertStereoTo61(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 2) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 2;
|
||||||
@@ -362,7 +376,8 @@ static void SDLCALL SDL_ConvertStereoTo71(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -381,7 +396,8 @@ static void SDLCALL SDL_Convert21ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -402,7 +418,8 @@ static void SDLCALL SDL_Convert21ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 4))) - 4;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
||||||
@@ -426,7 +443,8 @@ static void SDLCALL SDL_Convert21ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 5))) - 5;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
||||||
@@ -450,7 +468,8 @@ static void SDLCALL SDL_Convert21To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 6))) - 6;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
||||||
@@ -475,7 +494,8 @@ static void SDLCALL SDL_Convert21To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
||||||
@@ -501,7 +521,8 @@ static void SDLCALL SDL_Convert21To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 3) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 3;
|
||||||
@@ -528,7 +549,8 @@ static void SDLCALL SDL_Convert21To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -547,7 +569,8 @@ static void SDLCALL SDL_ConvertQuadToMono(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -569,7 +592,8 @@ static void SDLCALL SDL_ConvertQuadToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat f
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -592,7 +616,8 @@ static void SDLCALL SDL_ConvertQuadTo21(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 5))) - 5;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||||
@@ -616,7 +641,8 @@ static void SDLCALL SDL_ConvertQuadTo41(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 6))) - 6;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||||
@@ -641,7 +667,8 @@ static void SDLCALL SDL_ConvertQuadTo51(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||||
@@ -669,7 +696,8 @@ static void SDLCALL SDL_ConvertQuadTo61(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 4) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||||
@@ -696,7 +724,8 @@ static void SDLCALL SDL_ConvertQuadTo71(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -715,7 +744,8 @@ static void SDLCALL SDL_Convert41ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -738,7 +768,8 @@ static void SDLCALL SDL_Convert41ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -761,7 +792,8 @@ static void SDLCALL SDL_Convert41To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -784,7 +816,8 @@ static void SDLCALL SDL_Convert41ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 6))) - 6;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
||||||
@@ -809,7 +842,8 @@ static void SDLCALL SDL_Convert41To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
||||||
@@ -837,7 +871,8 @@ static void SDLCALL SDL_Convert41To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 5) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 5;
|
||||||
@@ -864,7 +899,8 @@ static void SDLCALL SDL_Convert41To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -883,7 +919,8 @@ static void SDLCALL SDL_Convert51ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -907,7 +944,8 @@ static void SDLCALL SDL_Convert51ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -931,7 +969,8 @@ static void SDLCALL SDL_Convert51To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -955,7 +994,8 @@ static void SDLCALL SDL_Convert51ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -979,7 +1019,8 @@ static void SDLCALL SDL_Convert51To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 7))) - 7;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||||
@@ -1007,7 +1048,8 @@ static void SDLCALL SDL_Convert51To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 6) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 6;
|
||||||
@@ -1034,7 +1076,8 @@ static void SDLCALL SDL_Convert51To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1053,7 +1096,8 @@ static void SDLCALL SDL_Convert61ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1078,7 +1122,8 @@ static void SDLCALL SDL_Convert61ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1103,7 +1148,8 @@ static void SDLCALL SDL_Convert61To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1130,7 +1176,8 @@ static void SDLCALL SDL_Convert61ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1157,7 +1204,8 @@ static void SDLCALL SDL_Convert61To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1184,7 +1232,8 @@ static void SDLCALL SDL_Convert61To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8;
|
float *dst = ((float *) (cvt->buf + ((cvt->len_cvt / 7) * 8))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 7;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 7;
|
||||||
@@ -1212,7 +1261,8 @@ static void SDLCALL SDL_Convert61To71(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1231,7 +1281,8 @@ static void SDLCALL SDL_Convert71ToMono(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1257,7 +1308,8 @@ static void SDLCALL SDL_Convert71ToStereo(SDL_AudioCVT *cvt, SDL_AudioFormat for
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1283,7 +1335,8 @@ static void SDLCALL SDL_Convert71To21(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1309,7 +1362,8 @@ static void SDLCALL SDL_Convert71ToQuad(SDL_AudioCVT *cvt, SDL_AudioFormat forma
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1335,7 +1389,8 @@ static void SDLCALL SDL_Convert71To41(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1361,7 +1416,8 @@ static void SDLCALL SDL_Convert71To51(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert71To61(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
const float *src = dst;
|
const float *src = dst;
|
||||||
@@ -1400,3 +1456,4 @@ static const SDL_AudioFilter channel_converters[8][8] = { /* [from][to] */
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
||||||
@@ -1059,3 +1059,4 @@ static const float ResamplerFilterDifference[RESAMPLER_FILTER_SIZE] = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/* vi: set ts=4 sw=4 expandtab: */
|
/* vi: set ts=4 sw=4 expandtab: */
|
||||||
|
|
||||||
+139
-173
@@ -95,7 +95,8 @@
|
|||||||
|
|
||||||
#if HAVE_SSE3_INTRINSICS
|
#if HAVE_SSE3_INTRINSICS
|
||||||
/* Convert from stereo to mono. Average left and right. */
|
/* Convert from stereo to mono. Average left and right. */
|
||||||
static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
const __m128 divby2 = _mm_set1_ps(0.5f);
|
const __m128 divby2 = _mm_set1_ps(0.5f);
|
||||||
float *dst = (float *) cvt->buf;
|
float *dst = (float *) cvt->buf;
|
||||||
@@ -110,17 +111,13 @@ static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFor
|
|||||||
aligned it'll be just as fast on modern processors */
|
aligned it'll be just as fast on modern processors */
|
||||||
while (i >= 4) { /* 4 * float32 */
|
while (i >= 4) { /* 4 * float32 */
|
||||||
_mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src+4)), divby2));
|
_mm_storeu_ps(dst, _mm_mul_ps(_mm_hadd_ps(_mm_loadu_ps(src), _mm_loadu_ps(src+4)), divby2));
|
||||||
i -= 4;
|
i -= 4; src += 8; dst += 4;
|
||||||
src += 8;
|
|
||||||
dst += 4;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish off any leftovers with scalar operations. */
|
/* Finish off any leftovers with scalar operations. */
|
||||||
while (i) {
|
while (i) {
|
||||||
*dst = (src[0] + src[1]) * 0.5f;
|
*dst = (src[0] + src[1]) * 0.5f;
|
||||||
dst++;
|
dst++; i--; src += 2;
|
||||||
i--;
|
|
||||||
src += 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cvt->len_cvt /= 2;
|
cvt->len_cvt /= 2;
|
||||||
@@ -132,7 +129,8 @@ static void SDLCALL SDL_ConvertStereoToMono_SSE3(SDL_AudioCVT *cvt, SDL_AudioFor
|
|||||||
|
|
||||||
#if HAVE_SSE_INTRINSICS
|
#if HAVE_SSE_INTRINSICS
|
||||||
/* Convert from mono to stereo. Duplicate to stereo left and right. */
|
/* Convert from mono to stereo. Duplicate to stereo left and right. */
|
||||||
static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT * cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
float *dst = ((float *) (cvt->buf + (cvt->len_cvt * 2))) - 8;
|
float *dst = ((float *) (cvt->buf + (cvt->len_cvt * 2))) - 8;
|
||||||
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
const float *src = ((const float *) (cvt->buf + cvt->len_cvt)) - 4;
|
||||||
@@ -149,21 +147,16 @@ static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioForm
|
|||||||
const __m128 input = _mm_loadu_ps(src); /* A B C D */
|
const __m128 input = _mm_loadu_ps(src); /* A B C D */
|
||||||
_mm_storeu_ps(dst, _mm_unpacklo_ps(input, input)); /* A A B B */
|
_mm_storeu_ps(dst, _mm_unpacklo_ps(input, input)); /* A A B B */
|
||||||
_mm_storeu_ps(dst+4, _mm_unpackhi_ps(input, input)); /* C C D D */
|
_mm_storeu_ps(dst+4, _mm_unpackhi_ps(input, input)); /* C C D D */
|
||||||
i -= 4;
|
i -= 4; src -= 4; dst -= 8;
|
||||||
src -= 4;
|
|
||||||
dst -= 8;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Finish off any leftovers with scalar operations. */
|
/* Finish off any leftovers with scalar operations. */
|
||||||
src += 3;
|
src += 3; dst += 6; /* adjust for smaller buffers. */
|
||||||
dst += 6; /* adjust for smaller buffers. */
|
|
||||||
while (i) { /* convert backwards, since output is growing in-place. */
|
while (i) { /* convert backwards, since output is growing in-place. */
|
||||||
const float srcFC = src[0];
|
const float srcFC = src[0];
|
||||||
dst[1] /* FR */ = srcFC;
|
dst[1] /* FR */ = srcFC;
|
||||||
dst[0] /* FL */ = srcFC;
|
dst[0] /* FL */ = srcFC;
|
||||||
i--;
|
i--; src--; dst -= 2;
|
||||||
src--;
|
|
||||||
dst -= 2;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cvt->len_cvt *= 2;
|
cvt->len_cvt *= 2;
|
||||||
@@ -173,15 +166,19 @@ static void SDLCALL SDL_ConvertMonoToStereo_SSE(SDL_AudioCVT *cvt, SDL_AudioForm
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/* Include the autogenerated channel converters... */
|
/* Include the autogenerated channel converters... */
|
||||||
#include "SDL_audio_channel_converters.h"
|
#include "SDL_audio_channel_converters.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* SDL's resampler uses a "bandlimited interpolation" algorithm:
|
/* SDL's resampler uses a "bandlimited interpolation" algorithm:
|
||||||
https://ccrma.stanford.edu/~jos/resample/ */
|
https://ccrma.stanford.edu/~jos/resample/ */
|
||||||
|
|
||||||
#include "SDL_audio_resampler_filter.h"
|
#include "SDL_audio_resampler_filter.h"
|
||||||
|
|
||||||
static Sint32 ResamplerPadding(const Sint32 inrate, const Sint32 outrate)
|
static Sint32
|
||||||
|
ResamplerPadding(const Sint32 inrate, const Sint32 outrate)
|
||||||
{
|
{
|
||||||
/* This function uses integer arithmetics to avoid precision loss caused
|
/* This function uses integer arithmetics to avoid precision loss caused
|
||||||
* by large floating point numbers. Sint32 is needed for the large number
|
* by large floating point numbers. Sint32 is needed for the large number
|
||||||
@@ -197,7 +194,8 @@ static Sint32 ResamplerPadding(const Sint32 inrate, const Sint32 outrate)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* lpadding and rpadding are expected to be buffers of (ResamplePadding(inrate, outrate) * chans * sizeof (float)) bytes. */
|
/* lpadding and rpadding are expected to be buffers of (ResamplePadding(inrate, outrate) * chans * sizeof (float)) bytes. */
|
||||||
static int SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
|
static int
|
||||||
|
SDL_ResampleAudio(const int chans, const int inrate, const int outrate,
|
||||||
const float *lpadding, const float *rpadding,
|
const float *lpadding, const float *rpadding,
|
||||||
const float *inbuf, const int inbuflen,
|
const float *inbuf, const int inbuflen,
|
||||||
float *outbuf, const int outbuflen)
|
float *outbuf, const int outbuflen)
|
||||||
@@ -212,14 +210,14 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
|||||||
const int framelen = chans * (int)sizeof (float);
|
const int framelen = chans * (int)sizeof (float);
|
||||||
const int inframes = inbuflen / framelen;
|
const int inframes = inbuflen / framelen;
|
||||||
/* outbuflen isn't total to write, it's total available. */
|
/* outbuflen isn't total to write, it's total available. */
|
||||||
const int wantedoutframes = (int)((Sint64)inframes * outrate / inrate);
|
const int wantedoutframes = ((Sint64) inframes) * outrate / inrate;
|
||||||
const int maxoutframes = outbuflen / framelen;
|
const int maxoutframes = outbuflen / framelen;
|
||||||
const int outframes = SDL_min(wantedoutframes, maxoutframes);
|
const int outframes = SDL_min(wantedoutframes, maxoutframes);
|
||||||
float *dst = outbuf;
|
float *dst = outbuf;
|
||||||
int i, j, chan;
|
int i, j, chan;
|
||||||
|
|
||||||
for (i = 0; i < outframes; i++) {
|
for (i = 0; i < outframes; i++) {
|
||||||
const int srcindex = (int)((Sint64)i * inrate / outrate);
|
const int srcindex = ((Sint64) i) * inrate / outrate;
|
||||||
/* Calculating the following way avoids subtraction or modulo of large
|
/* Calculating the following way avoids subtraction or modulo of large
|
||||||
* floats which have low result precision.
|
* floats which have low result precision.
|
||||||
* interpolation1
|
* interpolation1
|
||||||
@@ -260,7 +258,8 @@ static int SDL_ResampleAudio(const int chans, const int inrate, const int outrat
|
|||||||
return outframes * chans * sizeof (float);
|
return outframes * chans * sizeof (float);
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_ConvertAudio(SDL_AudioCVT *cvt)
|
int
|
||||||
|
SDL_ConvertAudio(SDL_AudioCVT * cvt)
|
||||||
{
|
{
|
||||||
/* !!! FIXME: (cvt) should be const; stack-copy it here. */
|
/* !!! FIXME: (cvt) should be const; stack-copy it here. */
|
||||||
/* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
|
/* !!! FIXME: (actually, we can't...len_cvt needs to be updated. Grr.) */
|
||||||
@@ -282,7 +281,8 @@ int SDL_ConvertAudio(SDL_AudioCVT *cvt)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
static void SDLCALL
|
||||||
|
SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
#if DEBUG_CONVERT
|
#if DEBUG_CONVERT
|
||||||
SDL_Log("SDL_AUDIO_CONVERT: Converting byte order\n");
|
SDL_Log("SDL_AUDIO_CONVERT: Converting byte order\n");
|
||||||
@@ -290,8 +290,7 @@ static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat form
|
|||||||
|
|
||||||
switch (SDL_AUDIO_BITSIZE(format)) {
|
switch (SDL_AUDIO_BITSIZE(format)) {
|
||||||
#define CASESWAP(b) \
|
#define CASESWAP(b) \
|
||||||
case b: \
|
case b: { \
|
||||||
{ \
|
|
||||||
Uint##b *ptr = (Uint##b *) cvt->buf; \
|
Uint##b *ptr = (Uint##b *) cvt->buf; \
|
||||||
int i; \
|
int i; \
|
||||||
for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \
|
for (i = cvt->len_cvt / sizeof (*ptr); i; --i, ++ptr) { \
|
||||||
@@ -306,9 +305,7 @@ static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat form
|
|||||||
|
|
||||||
#undef CASESWAP
|
#undef CASESWAP
|
||||||
|
|
||||||
default:
|
default: SDL_assert(!"unhandled byteswap datatype!"); break;
|
||||||
SDL_assert(!"unhandled byteswap datatype!");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cvt->filters[++cvt->filter_index]) {
|
if (cvt->filters[++cvt->filter_index]) {
|
||||||
@@ -322,7 +319,8 @@ static void SDLCALL SDL_Convert_Byteswap(SDL_AudioCVT *cvt, SDL_AudioFormat form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, SDL_AudioFilter filter)
|
static int
|
||||||
|
SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, const SDL_AudioFilter filter)
|
||||||
{
|
{
|
||||||
if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) {
|
if (cvt->filter_index >= SDL_AUDIOCVT_MAX_FILTERS) {
|
||||||
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS);
|
return SDL_SetError("Too many filters needed for conversion, exceeded maximum of %d", SDL_AUDIOCVT_MAX_FILTERS);
|
||||||
@@ -333,7 +331,8 @@ static int SDL_AddAudioCVTFilter(SDL_AudioCVT *cvt, SDL_AudioFilter filter)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
|
static int
|
||||||
|
SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat src_fmt)
|
||||||
{
|
{
|
||||||
int retval = 0; /* 0 == no conversion necessary. */
|
int retval = 0; /* 0 == no conversion necessary. */
|
||||||
|
|
||||||
@@ -350,24 +349,12 @@ static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat
|
|||||||
SDL_AudioFilter filter = NULL;
|
SDL_AudioFilter filter = NULL;
|
||||||
|
|
||||||
switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
|
switch (src_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
|
||||||
case AUDIO_S8:
|
case AUDIO_S8: filter = SDL_Convert_S8_to_F32; break;
|
||||||
filter = SDL_Convert_S8_to_F32;
|
case AUDIO_U8: filter = SDL_Convert_U8_to_F32; break;
|
||||||
break;
|
case AUDIO_S16: filter = SDL_Convert_S16_to_F32; break;
|
||||||
case AUDIO_U8:
|
case AUDIO_U16: filter = SDL_Convert_U16_to_F32; break;
|
||||||
filter = SDL_Convert_U8_to_F32;
|
case AUDIO_S32: filter = SDL_Convert_S32_to_F32; break;
|
||||||
break;
|
default: SDL_assert(!"Unexpected audio format!"); break;
|
||||||
case AUDIO_S16:
|
|
||||||
filter = SDL_Convert_S16_to_F32;
|
|
||||||
break;
|
|
||||||
case AUDIO_U16:
|
|
||||||
filter = SDL_Convert_U16_to_F32;
|
|
||||||
break;
|
|
||||||
case AUDIO_S32:
|
|
||||||
filter = SDL_Convert_S32_to_F32;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(!"Unexpected audio format!");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
@@ -382,8 +369,7 @@ static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat
|
|||||||
cvt->len_mult *= mult;
|
cvt->len_mult *= mult;
|
||||||
cvt->len_ratio *= mult;
|
cvt->len_ratio *= mult;
|
||||||
} else if (src_bitsize > dst_bitsize) {
|
} else if (src_bitsize > dst_bitsize) {
|
||||||
const int div = (src_bitsize / dst_bitsize);
|
cvt->len_ratio /= (src_bitsize / dst_bitsize);
|
||||||
cvt->len_ratio /= div;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
retval = 1; /* added a converter. */
|
retval = 1; /* added a converter. */
|
||||||
@@ -392,7 +378,8 @@ static int SDL_BuildAudioTypeCVTToFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
|
static int
|
||||||
|
SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioFormat dst_fmt)
|
||||||
{
|
{
|
||||||
int retval = 0; /* 0 == no conversion necessary. */
|
int retval = 0; /* 0 == no conversion necessary. */
|
||||||
|
|
||||||
@@ -401,24 +388,12 @@ static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioForm
|
|||||||
const Uint16 src_bitsize = 32;
|
const Uint16 src_bitsize = 32;
|
||||||
SDL_AudioFilter filter = NULL;
|
SDL_AudioFilter filter = NULL;
|
||||||
switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
|
switch (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN) {
|
||||||
case AUDIO_S8:
|
case AUDIO_S8: filter = SDL_Convert_F32_to_S8; break;
|
||||||
filter = SDL_Convert_F32_to_S8;
|
case AUDIO_U8: filter = SDL_Convert_F32_to_U8; break;
|
||||||
break;
|
case AUDIO_S16: filter = SDL_Convert_F32_to_S16; break;
|
||||||
case AUDIO_U8:
|
case AUDIO_U16: filter = SDL_Convert_F32_to_U16; break;
|
||||||
filter = SDL_Convert_F32_to_U8;
|
case AUDIO_S32: filter = SDL_Convert_F32_to_S32; break;
|
||||||
break;
|
default: SDL_assert(!"Unexpected audio format!"); break;
|
||||||
case AUDIO_S16:
|
|
||||||
filter = SDL_Convert_F32_to_S16;
|
|
||||||
break;
|
|
||||||
case AUDIO_U16:
|
|
||||||
filter = SDL_Convert_F32_to_U16;
|
|
||||||
break;
|
|
||||||
case AUDIO_S32:
|
|
||||||
filter = SDL_Convert_F32_to_S32;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SDL_assert(!"Unexpected audio format!");
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!filter) {
|
if (!filter) {
|
||||||
@@ -451,7 +426,8 @@ static int SDL_BuildAudioTypeCVTFromFloat(SDL_AudioCVT *cvt, const SDL_AudioForm
|
|||||||
|
|
||||||
#ifdef HAVE_LIBSAMPLERATE_H
|
#ifdef HAVE_LIBSAMPLERATE_H
|
||||||
|
|
||||||
static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
|
static void
|
||||||
|
SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
const float *src = (const float *) cvt->buf;
|
const float *src = (const float *) cvt->buf;
|
||||||
const int srclen = cvt->len_cvt;
|
const int srclen = cvt->len_cvt;
|
||||||
@@ -490,7 +466,8 @@ static void SDL_ResampleCVT_SRC(SDL_AudioCVT *cvt, const int chans, const SDL_Au
|
|||||||
|
|
||||||
#endif /* HAVE_LIBSAMPLERATE_H */
|
#endif /* HAVE_LIBSAMPLERATE_H */
|
||||||
|
|
||||||
static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
|
static void
|
||||||
|
SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioFormat format)
|
||||||
{
|
{
|
||||||
/* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator).
|
/* !!! FIXME in 2.1: there are ten slots in the filter list, and the theoretical maximum we use is six (seven with NULL terminator).
|
||||||
!!! FIXME in 2.1: We need to store data for this resampler, because the cvt structure doesn't store the original sample rates,
|
!!! FIXME in 2.1: We need to store data for this resampler, because the cvt structure doesn't store the original sample rates,
|
||||||
@@ -517,7 +494,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
|
|||||||
|
|
||||||
/* we keep no streaming state here, so pad with silence on both ends. */
|
/* we keep no streaming state here, so pad with silence on both ends. */
|
||||||
padding = (float *) SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof (float));
|
padding = (float *) SDL_calloc(paddingsamples ? paddingsamples : 1, sizeof (float));
|
||||||
if (padding == NULL) {
|
if (!padding) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -539,8 +516,7 @@ static void SDL_ResampleCVT(SDL_AudioCVT *cvt, const int chans, const SDL_AudioF
|
|||||||
!!! FIXME: vs arbitrary. When we rev the ABI, clean this up. */
|
!!! FIXME: vs arbitrary. When we rev the ABI, clean this up. */
|
||||||
#define RESAMPLER_FUNCS(chans) \
|
#define RESAMPLER_FUNCS(chans) \
|
||||||
static void SDLCALL \
|
static void SDLCALL \
|
||||||
SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \
|
SDL_ResampleCVT_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
|
||||||
{ \
|
|
||||||
SDL_ResampleCVT(cvt, chans, format); \
|
SDL_ResampleCVT(cvt, chans, format); \
|
||||||
}
|
}
|
||||||
RESAMPLER_FUNCS(1)
|
RESAMPLER_FUNCS(1)
|
||||||
@@ -553,8 +529,7 @@ RESAMPLER_FUNCS(8)
|
|||||||
#ifdef HAVE_LIBSAMPLERATE_H
|
#ifdef HAVE_LIBSAMPLERATE_H
|
||||||
#define RESAMPLER_FUNCS(chans) \
|
#define RESAMPLER_FUNCS(chans) \
|
||||||
static void SDLCALL \
|
static void SDLCALL \
|
||||||
SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) \
|
SDL_ResampleCVT_SRC_c##chans(SDL_AudioCVT *cvt, SDL_AudioFormat format) { \
|
||||||
{ \
|
|
||||||
SDL_ResampleCVT_SRC(cvt, chans, format); \
|
SDL_ResampleCVT_SRC(cvt, chans, format); \
|
||||||
}
|
}
|
||||||
RESAMPLER_FUNCS(1)
|
RESAMPLER_FUNCS(1)
|
||||||
@@ -565,46 +540,36 @@ RESAMPLER_FUNCS(8)
|
|||||||
#undef RESAMPLER_FUNCS
|
#undef RESAMPLER_FUNCS
|
||||||
#endif /* HAVE_LIBSAMPLERATE_H */
|
#endif /* HAVE_LIBSAMPLERATE_H */
|
||||||
|
|
||||||
static SDL_AudioFilter ChooseCVTResampler(const int dst_channels)
|
static SDL_AudioFilter
|
||||||
|
ChooseCVTResampler(const int dst_channels)
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LIBSAMPLERATE_H
|
#ifdef HAVE_LIBSAMPLERATE_H
|
||||||
if (SRC_available) {
|
if (SRC_available) {
|
||||||
switch (dst_channels) {
|
switch (dst_channels) {
|
||||||
case 1:
|
case 1: return SDL_ResampleCVT_SRC_c1;
|
||||||
return SDL_ResampleCVT_SRC_c1;
|
case 2: return SDL_ResampleCVT_SRC_c2;
|
||||||
case 2:
|
case 4: return SDL_ResampleCVT_SRC_c4;
|
||||||
return SDL_ResampleCVT_SRC_c2;
|
case 6: return SDL_ResampleCVT_SRC_c6;
|
||||||
case 4:
|
case 8: return SDL_ResampleCVT_SRC_c8;
|
||||||
return SDL_ResampleCVT_SRC_c4;
|
default: break;
|
||||||
case 6:
|
|
||||||
return SDL_ResampleCVT_SRC_c6;
|
|
||||||
case 8:
|
|
||||||
return SDL_ResampleCVT_SRC_c8;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif /* HAVE_LIBSAMPLERATE_H */
|
#endif /* HAVE_LIBSAMPLERATE_H */
|
||||||
|
|
||||||
switch (dst_channels) {
|
switch (dst_channels) {
|
||||||
case 1:
|
case 1: return SDL_ResampleCVT_c1;
|
||||||
return SDL_ResampleCVT_c1;
|
case 2: return SDL_ResampleCVT_c2;
|
||||||
case 2:
|
case 4: return SDL_ResampleCVT_c4;
|
||||||
return SDL_ResampleCVT_c2;
|
case 6: return SDL_ResampleCVT_c6;
|
||||||
case 4:
|
case 8: return SDL_ResampleCVT_c8;
|
||||||
return SDL_ResampleCVT_c4;
|
default: break;
|
||||||
case 6:
|
|
||||||
return SDL_ResampleCVT_c6;
|
|
||||||
case 8:
|
|
||||||
return SDL_ResampleCVT_c8;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels,
|
static int
|
||||||
|
SDL_BuildAudioResampleCVT(SDL_AudioCVT * cvt, const int dst_channels,
|
||||||
const int src_rate, const int dst_rate)
|
const int src_rate, const int dst_rate)
|
||||||
{
|
{
|
||||||
SDL_AudioFilter filter;
|
SDL_AudioFilter filter;
|
||||||
@@ -648,7 +613,8 @@ static int SDL_BuildAudioResampleCVT(SDL_AudioCVT *cvt, const int dst_channels,
|
|||||||
return 1; /* added a converter. */
|
return 1; /* added a converter. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
|
static SDL_bool
|
||||||
|
SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
|
||||||
{
|
{
|
||||||
switch (fmt) {
|
switch (fmt) {
|
||||||
case AUDIO_U8:
|
case AUDIO_U8:
|
||||||
@@ -670,19 +636,22 @@ static SDL_bool SDL_SupportedAudioFormat(const SDL_AudioFormat fmt)
|
|||||||
return SDL_FALSE; /* unsupported. */
|
return SDL_FALSE; /* unsupported. */
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SDL_SupportedChannelCount(const int channels)
|
static SDL_bool
|
||||||
|
SDL_SupportedChannelCount(const int channels)
|
||||||
{
|
{
|
||||||
return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE;
|
return ((channels >= 1) && (channels <= 8)) ? SDL_TRUE : SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Creates a set of audio filters to convert from one format to another.
|
/* Creates a set of audio filters to convert from one format to another.
|
||||||
Returns 0 if no conversion is needed, 1 if the audio filter is set up,
|
Returns 0 if no conversion is needed, 1 if the audio filter is set up,
|
||||||
or -1 if an error like invalid parameter, unsupported format, etc. occurred.
|
or -1 if an error like invalid parameter, unsupported format, etc. occurred.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
int
|
||||||
SDL_AudioFormat src_format, Uint8 src_channels, int src_rate,
|
SDL_BuildAudioCVT(SDL_AudioCVT * cvt,
|
||||||
SDL_AudioFormat dst_format, Uint8 dst_channels, int dst_rate)
|
SDL_AudioFormat src_fmt, Uint8 src_channels, int src_rate,
|
||||||
|
SDL_AudioFormat dst_fmt, Uint8 dst_channels, int dst_rate)
|
||||||
{
|
{
|
||||||
SDL_AudioFilter channel_converter = NULL;
|
SDL_AudioFilter channel_converter = NULL;
|
||||||
|
|
||||||
@@ -694,10 +663,10 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
/* Make sure we zero out the audio conversion before error checking */
|
/* Make sure we zero out the audio conversion before error checking */
|
||||||
SDL_zerop(cvt);
|
SDL_zerop(cvt);
|
||||||
|
|
||||||
if (!SDL_SupportedAudioFormat(src_format)) {
|
if (!SDL_SupportedAudioFormat(src_fmt)) {
|
||||||
return SDL_SetError("Invalid source format");
|
return SDL_SetError("Invalid source format");
|
||||||
}
|
}
|
||||||
if (!SDL_SupportedAudioFormat(dst_format)) {
|
if (!SDL_SupportedAudioFormat(dst_fmt)) {
|
||||||
return SDL_SetError("Invalid destination format");
|
return SDL_SetError("Invalid destination format");
|
||||||
}
|
}
|
||||||
if (!SDL_SupportedChannelCount(src_channels)) {
|
if (!SDL_SupportedChannelCount(src_channels)) {
|
||||||
@@ -721,12 +690,12 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
|
|
||||||
#if DEBUG_CONVERT
|
#if DEBUG_CONVERT
|
||||||
SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
SDL_Log("SDL_AUDIO_CONVERT: Build format %04x->%04x, channels %u->%u, rate %d->%d\n",
|
||||||
src_format, dst_format, src_channels, dst_channels, src_rate, dst_rate);
|
src_fmt, dst_fmt, src_channels, dst_channels, src_rate, dst_rate);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Start off with no conversion necessary */
|
/* Start off with no conversion necessary */
|
||||||
cvt->src_format = src_format;
|
cvt->src_format = src_fmt;
|
||||||
cvt->dst_format = dst_format;
|
cvt->dst_format = dst_fmt;
|
||||||
cvt->needed = 0;
|
cvt->needed = 0;
|
||||||
cvt->filter_index = 0;
|
cvt->filter_index = 0;
|
||||||
SDL_zeroa(cvt->filters);
|
SDL_zeroa(cvt->filters);
|
||||||
@@ -753,13 +722,13 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
|
|
||||||
/* see if we can skip float conversion entirely. */
|
/* see if we can skip float conversion entirely. */
|
||||||
if (src_rate == dst_rate && src_channels == dst_channels) {
|
if (src_rate == dst_rate && src_channels == dst_channels) {
|
||||||
if (src_format == dst_format) {
|
if (src_fmt == dst_fmt) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* just a byteswap needed? */
|
/* just a byteswap needed? */
|
||||||
if ((src_format & ~SDL_AUDIO_MASK_ENDIAN) == (dst_format & ~SDL_AUDIO_MASK_ENDIAN)) {
|
if ((src_fmt & ~SDL_AUDIO_MASK_ENDIAN) == (dst_fmt & ~SDL_AUDIO_MASK_ENDIAN)) {
|
||||||
if (SDL_AUDIO_BITSIZE(dst_format) == 8) {
|
if (SDL_AUDIO_BITSIZE(dst_fmt) == 8) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) {
|
if (SDL_AddAudioCVTFilter(cvt, SDL_Convert_Byteswap) < 0) {
|
||||||
@@ -771,10 +740,11 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Convert data types, if necessary. Updates (cvt). */
|
/* Convert data types, if necessary. Updates (cvt). */
|
||||||
if (SDL_BuildAudioTypeCVTToFloat(cvt, src_format) < 0) {
|
if (SDL_BuildAudioTypeCVTToFloat(cvt, src_fmt) < 0) {
|
||||||
return -1; /* shouldn't happen, but just in case... */
|
return -1; /* shouldn't happen, but just in case... */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Channel conversion */
|
/* Channel conversion */
|
||||||
|
|
||||||
/* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */
|
/* SDL_SupportedChannelCount should have caught these asserts, or we added a new format and forgot to update the table. */
|
||||||
@@ -790,23 +760,15 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
if (channel_converter == SDL_ConvertStereoToMono) {
|
if (channel_converter == SDL_ConvertStereoToMono) {
|
||||||
SDL_AudioFilter filter = NULL;
|
SDL_AudioFilter filter = NULL;
|
||||||
#if HAVE_SSE3_INTRINSICS
|
#if HAVE_SSE3_INTRINSICS
|
||||||
if (!filter && SDL_HasSSE3()) {
|
if (!filter && SDL_HasSSE3()) { filter = SDL_ConvertStereoToMono_SSE3; }
|
||||||
filter = SDL_ConvertStereoToMono_SSE3;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (filter) {
|
if (filter) { channel_converter = filter; }
|
||||||
channel_converter = filter;
|
|
||||||
}
|
|
||||||
} else if (channel_converter == SDL_ConvertMonoToStereo) {
|
} else if (channel_converter == SDL_ConvertMonoToStereo) {
|
||||||
SDL_AudioFilter filter = NULL;
|
SDL_AudioFilter filter = NULL;
|
||||||
#if HAVE_SSE_INTRINSICS
|
#if HAVE_SSE_INTRINSICS
|
||||||
if (!filter && SDL_HasSSE()) {
|
if (!filter && SDL_HasSSE()) { filter = SDL_ConvertMonoToStereo_SSE; }
|
||||||
filter = SDL_ConvertMonoToStereo_SSE;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
if (filter) {
|
if (filter) { channel_converter = filter; }
|
||||||
channel_converter = filter;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) {
|
if (SDL_AddAudioCVTFilter(cvt, channel_converter) < 0) {
|
||||||
@@ -827,12 +789,12 @@ int SDL_BuildAudioCVT(SDL_AudioCVT *cvt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Move to final data type. */
|
/* Move to final data type. */
|
||||||
if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_format) < 0) {
|
if (SDL_BuildAudioTypeCVTFromFloat(cvt, dst_fmt) < 0) {
|
||||||
return -1; /* shouldn't happen, but just in case... */
|
return -1; /* shouldn't happen, but just in case... */
|
||||||
}
|
}
|
||||||
|
|
||||||
cvt->needed = (cvt->filter_index != 0);
|
cvt->needed = (cvt->filter_index != 0);
|
||||||
return cvt->needed;
|
return (cvt->needed);
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef int (*SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen);
|
typedef int (*SDL_ResampleAudioStreamFunc)(SDL_AudioStream *stream, const void *inbuf, const int inbuflen, void *outbuf, const int outbuflen);
|
||||||
@@ -869,7 +831,8 @@ struct _SDL_AudioStream
|
|||||||
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
|
SDL_CleanupAudioStreamResamplerFunc cleanup_resampler_func;
|
||||||
};
|
};
|
||||||
|
|
||||||
static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
|
static Uint8 *
|
||||||
|
EnsureStreamBufferSize(SDL_AudioStream *stream, const int newlen)
|
||||||
{
|
{
|
||||||
Uint8 *ptr;
|
Uint8 *ptr;
|
||||||
size_t offset;
|
size_t offset;
|
||||||
@@ -877,8 +840,8 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
|
|||||||
if (stream->work_buffer_len >= newlen) {
|
if (stream->work_buffer_len >= newlen) {
|
||||||
ptr = stream->work_buffer_base;
|
ptr = stream->work_buffer_base;
|
||||||
} else {
|
} else {
|
||||||
ptr = (Uint8 *)SDL_realloc(stream->work_buffer_base, (size_t)newlen + 32);
|
ptr = (Uint8 *) SDL_realloc(stream->work_buffer_base, newlen + 32);
|
||||||
if (ptr == NULL) {
|
if (!ptr) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -892,7 +855,8 @@ static Uint8 *EnsureStreamBufferSize(SDL_AudioStream *stream, int newlen)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_LIBSAMPLERATE_H
|
#ifdef HAVE_LIBSAMPLERATE_H
|
||||||
static int SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
|
static int
|
||||||
|
SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
|
||||||
{
|
{
|
||||||
const float *inbuf = (const float *) _inbuf;
|
const float *inbuf = (const float *) _inbuf;
|
||||||
float *outbuf = (float *) _outbuf;
|
float *outbuf = (float *) _outbuf;
|
||||||
@@ -925,12 +889,14 @@ static int SDL_ResampleAudioStream_SRC(SDL_AudioStream *stream, const void *_inb
|
|||||||
return data.output_frames_gen * (sizeof(float) * stream->pre_resample_channels);
|
return data.output_frames_gen * (sizeof(float) * stream->pre_resample_channels);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream)
|
static void
|
||||||
|
SDL_ResetAudioStreamResampler_SRC(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
SRC_src_reset((SRC_STATE *)stream->resampler_state);
|
SRC_src_reset((SRC_STATE *)stream->resampler_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream)
|
static void
|
||||||
|
SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
SRC_STATE *state = (SRC_STATE *)stream->resampler_state;
|
SRC_STATE *state = (SRC_STATE *)stream->resampler_state;
|
||||||
if (state) {
|
if (state) {
|
||||||
@@ -943,19 +909,20 @@ static void SDL_CleanupAudioStreamResampler_SRC(SDL_AudioStream *stream)
|
|||||||
stream->cleanup_resampler_func = NULL;
|
stream->cleanup_resampler_func = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream)
|
static SDL_bool
|
||||||
|
SetupLibSampleRateResampling(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
int result = 0;
|
int result = 0;
|
||||||
SRC_STATE *state = NULL;
|
SRC_STATE *state = NULL;
|
||||||
|
|
||||||
if (SRC_available) {
|
if (SRC_available) {
|
||||||
state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
|
state = SRC_src_new(SRC_converter, stream->pre_resample_channels, &result);
|
||||||
if (state == NULL) {
|
if (!state) {
|
||||||
SDL_SetError("src_new() failed: %s", SRC_src_strerror(result));
|
SDL_SetError("src_new() failed: %s", SRC_src_strerror(result));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state == NULL) {
|
if (!state) {
|
||||||
SDL_CleanupAudioStreamResampler_SRC(stream);
|
SDL_CleanupAudioStreamResampler_SRC(stream);
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
@@ -969,7 +936,9 @@ static SDL_bool SetupLibSampleRateResampling(SDL_AudioStream *stream)
|
|||||||
}
|
}
|
||||||
#endif /* HAVE_LIBSAMPLERATE_H */
|
#endif /* HAVE_LIBSAMPLERATE_H */
|
||||||
|
|
||||||
static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
|
|
||||||
|
static int
|
||||||
|
SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf, const int inbuflen, void *_outbuf, const int outbuflen)
|
||||||
{
|
{
|
||||||
const Uint8 *inbufend = ((const Uint8 *) _inbuf) + inbuflen;
|
const Uint8 *inbufend = ((const Uint8 *) _inbuf) + inbuflen;
|
||||||
const float *inbuf = (const float *) _inbuf;
|
const float *inbuf = (const float *) _inbuf;
|
||||||
@@ -993,41 +962,34 @@ static int SDL_ResampleAudioStream(SDL_AudioStream *stream, const void *_inbuf,
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_ResetAudioStreamResampler(SDL_AudioStream *stream)
|
static void
|
||||||
|
SDL_ResetAudioStreamResampler(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
/* set all the padding to silence. */
|
/* set all the padding to silence. */
|
||||||
const int len = stream->resampler_padding_samples;
|
const int len = stream->resampler_padding_samples;
|
||||||
SDL_memset(stream->resampler_state, '\0', len * sizeof (float));
|
SDL_memset(stream->resampler_state, '\0', len * sizeof (float));
|
||||||
}
|
}
|
||||||
|
|
||||||
static void SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
|
static void
|
||||||
|
SDL_CleanupAudioStreamResampler(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
SDL_free(stream->resampler_state);
|
SDL_free(stream->resampler_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
SDL_AudioStream *
|
||||||
|
SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
||||||
const Uint8 src_channels,
|
const Uint8 src_channels,
|
||||||
const int src_rate,
|
const int src_rate,
|
||||||
const SDL_AudioFormat dst_format,
|
const SDL_AudioFormat dst_format,
|
||||||
const Uint8 dst_channels,
|
const Uint8 dst_channels,
|
||||||
const int dst_rate)
|
const int dst_rate)
|
||||||
{
|
{
|
||||||
int packetlen = 4096; /* !!! FIXME: good enough for now. */
|
const int packetlen = 4096; /* !!! FIXME: good enough for now. */
|
||||||
Uint8 pre_resample_channels;
|
Uint8 pre_resample_channels;
|
||||||
SDL_AudioStream *retval;
|
SDL_AudioStream *retval;
|
||||||
|
|
||||||
if (src_channels == 0) {
|
|
||||||
SDL_InvalidParamError("src_channels");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (dst_channels == 0) {
|
|
||||||
SDL_InvalidParamError("dst_channels");
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
retval = (SDL_AudioStream *) SDL_calloc(1, sizeof (SDL_AudioStream));
|
retval = (SDL_AudioStream *) SDL_calloc(1, sizeof (SDL_AudioStream));
|
||||||
if (retval == NULL) {
|
if (!retval) {
|
||||||
SDL_OutOfMemory();
|
SDL_OutOfMemory();
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@@ -1108,7 +1070,7 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
retval->queue = SDL_NewDataQueue(packetlen, (size_t)packetlen * 2);
|
retval->queue = SDL_NewDataQueue(packetlen, packetlen * 2);
|
||||||
if (!retval->queue) {
|
if (!retval->queue) {
|
||||||
SDL_FreeAudioStream(retval);
|
SDL_FreeAudioStream(retval);
|
||||||
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
return NULL; /* SDL_NewDataQueue should have called SDL_SetError. */
|
||||||
@@ -1117,7 +1079,8 @@ SDL_AudioStream *SDL_NewAudioStream(const SDL_AudioFormat src_format,
|
|||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
|
static int
|
||||||
|
SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf, int len, int *maxputbytes)
|
||||||
{
|
{
|
||||||
int buflen = len;
|
int buflen = len;
|
||||||
int workbuflen;
|
int workbuflen;
|
||||||
@@ -1169,7 +1132,7 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
workbuf = EnsureStreamBufferSize(stream, workbuflen);
|
workbuf = EnsureStreamBufferSize(stream, workbuflen);
|
||||||
if (workbuf == NULL) {
|
if (!workbuf) {
|
||||||
return -1; /* probably out of memory. */
|
return -1; /* probably out of memory. */
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1236,9 +1199,8 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
|
|||||||
|
|
||||||
if (maxputbytes) {
|
if (maxputbytes) {
|
||||||
const int maxbytes = *maxputbytes;
|
const int maxbytes = *maxputbytes;
|
||||||
if (buflen > maxbytes) {
|
if (buflen > maxbytes)
|
||||||
buflen = maxbytes;
|
buflen = maxbytes;
|
||||||
}
|
|
||||||
*maxputbytes -= buflen;
|
*maxputbytes -= buflen;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1246,7 +1208,8 @@ static int SDL_AudioStreamPutInternal(SDL_AudioStream *stream, const void *buf,
|
|||||||
return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0;
|
return buflen ? SDL_WriteToDataQueue(stream->queue, resamplebuf, buflen) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
int
|
||||||
|
SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
||||||
{
|
{
|
||||||
/* !!! FIXME: several converters can take advantage of SIMD, but only
|
/* !!! FIXME: several converters can take advantage of SIMD, but only
|
||||||
!!! FIXME: if the data is aligned to 16 bytes. EnsureStreamBufferSize()
|
!!! FIXME: if the data is aligned to 16 bytes. EnsureStreamBufferSize()
|
||||||
@@ -1260,10 +1223,10 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
|||||||
SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
|
SDL_Log("AUDIOSTREAM: wants to put %d preconverted bytes\n", buflen);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (stream == NULL) {
|
if (!stream) {
|
||||||
return SDL_InvalidParamError("stream");
|
return SDL_InvalidParamError("stream");
|
||||||
}
|
}
|
||||||
if (buf == NULL) {
|
if (!buf) {
|
||||||
return SDL_InvalidParamError("buf");
|
return SDL_InvalidParamError("buf");
|
||||||
}
|
}
|
||||||
if (len == 0) {
|
if (len == 0) {
|
||||||
@@ -1315,7 +1278,7 @@ int SDL_AudioStreamPut(SDL_AudioStream *stream, const void *buf, int len)
|
|||||||
|
|
||||||
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
if (stream == NULL) {
|
if (!stream) {
|
||||||
return SDL_InvalidParamError("stream");
|
return SDL_InvalidParamError("stream");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1333,9 +1296,8 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
|||||||
const SDL_bool first_run = stream->first_run;
|
const SDL_bool first_run = stream->first_run;
|
||||||
const int filled = stream->staging_buffer_filled;
|
const int filled = stream->staging_buffer_filled;
|
||||||
int actual_input_frames = filled / stream->src_sample_frame_size;
|
int actual_input_frames = filled / stream->src_sample_frame_size;
|
||||||
if (!first_run) {
|
if (!first_run)
|
||||||
actual_input_frames += stream->resampler_padding_samples / stream->pre_resample_channels;
|
actual_input_frames += stream->resampler_padding_samples / stream->pre_resample_channels;
|
||||||
}
|
|
||||||
|
|
||||||
if (actual_input_frames > 0) { /* don't bother if nothing to flush. */
|
if (actual_input_frames > 0) { /* don't bother if nothing to flush. */
|
||||||
/* This is how many bytes we're expecting without silence appended. */
|
/* This is how many bytes we're expecting without silence appended. */
|
||||||
@@ -1367,16 +1329,17 @@ int SDL_AudioStreamFlush(SDL_AudioStream *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* get converted/resampled data from the stream */
|
/* get converted/resampled data from the stream */
|
||||||
int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
|
int
|
||||||
|
SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
|
||||||
{
|
{
|
||||||
#if DEBUG_AUDIOSTREAM
|
#if DEBUG_AUDIOSTREAM
|
||||||
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
|
SDL_Log("AUDIOSTREAM: want to get %d converted bytes\n", len);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (stream == NULL) {
|
if (!stream) {
|
||||||
return SDL_InvalidParamError("stream");
|
return SDL_InvalidParamError("stream");
|
||||||
}
|
}
|
||||||
if (buf == NULL) {
|
if (!buf) {
|
||||||
return SDL_InvalidParamError("buf");
|
return SDL_InvalidParamError("buf");
|
||||||
}
|
}
|
||||||
if (len <= 0) {
|
if (len <= 0) {
|
||||||
@@ -1390,17 +1353,19 @@ int SDL_AudioStreamGet(SDL_AudioStream *stream, void *buf, int len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* number of converted/resampled bytes available */
|
/* number of converted/resampled bytes available */
|
||||||
int SDL_AudioStreamAvailable(SDL_AudioStream *stream)
|
int
|
||||||
|
SDL_AudioStreamAvailable(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
return stream ? (int) SDL_CountDataQueue(stream->queue) : 0;
|
return stream ? (int) SDL_CountDataQueue(stream->queue) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SDL_AudioStreamClear(SDL_AudioStream *stream)
|
void
|
||||||
|
SDL_AudioStreamClear(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
if (stream == NULL) {
|
if (!stream) {
|
||||||
SDL_InvalidParamError("stream");
|
SDL_InvalidParamError("stream");
|
||||||
} else {
|
} else {
|
||||||
SDL_ClearDataQueue(stream->queue, (size_t)stream->packetlen * 2);
|
SDL_ClearDataQueue(stream->queue, stream->packetlen * 2);
|
||||||
if (stream->reset_resampler_func) {
|
if (stream->reset_resampler_func) {
|
||||||
stream->reset_resampler_func(stream);
|
stream->reset_resampler_func(stream);
|
||||||
}
|
}
|
||||||
@@ -1410,7 +1375,8 @@ void SDL_AudioStreamClear(SDL_AudioStream *stream)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* dispose of a stream */
|
/* dispose of a stream */
|
||||||
void SDL_FreeAudioStream(SDL_AudioStream *stream)
|
void
|
||||||
|
SDL_FreeAudioStream(SDL_AudioStream *stream)
|
||||||
{
|
{
|
||||||
if (stream) {
|
if (stream) {
|
||||||
if (stream->cleanup_resampler_func) {
|
if (stream->cleanup_resampler_func) {
|
||||||
|
|||||||
Loaded 100 of 800 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user