Squashed 'deps/vitaGL/' changes from c816fec50f..2934af8af0

2934af8af0 Added Patreon sponsor link.
c8f18b6f0f Getting current program only when required for vglDrawObjects.
4c5d136b0d Added directive to enable vitaShaRK usage from cmd.
4a10df3be5 Minor adjustments and bugfixes.
14a0124acf Added GL_TEXTURE_LOD_BIAS support.
40c8c6205e Added GL_NONE def and fixed glUniform4f impl.
868079c51e Added glUniform4f implementation.
0a682cbad2 Typo fix.
be3ce61ae7 Added GL_DEPTH_BITS and GL_STENCIL_BITS support.
21e6d1d330 Added runtime shader compiler support.
696e40bc62 Beautify error handler code.
537b37b110 Added glUniform3fv implementation.
7dd1403015 Fixed GLenum size and added missing types defines.
0c75f27ff1 Moved to NEON optimized memcpy usage.
98951895de Added gluPerspective implementation.
23e0b0b309 Fix for vglInitExtended not working on sys app mode.
4989c33ef5 Run clang-format.
429f1c1d8a Added system mode support.
9231680d02 Initializing sceGxm before free mem checking on vglInitExtended.
091e5e7882 Added vglInitWithCustomSizes.
f4c646ea78 Added vglSetParamBufferSize.
1b9a063c41 Beautify some code.
089e81efc5 Fix for duplicated symbols
789dcbf812 Typo fix in readRGBA4444.
1514a4b2cb Disabling lto due to it being broken on vitasdk with gcc 9.1.
fca18d9ab7 Added support for RGBA4444 texture format.
d449f12808 Added support for RGB565 texture format.

git-subtree-dir: deps/vitaGL
git-subtree-split: 2934af8af083a9acf598ab75233c518a251c6f0d
This commit is contained in:
Francisco José García García 2020-07-05 11:43:47 +02:00
parent 4439e2fcb5
commit 51922ea5be
8552 changed files with 1161 additions and 2297000 deletions

View File

@ -1,20 +0,0 @@
# EditorConfig: http://EditorConfig.org
# Top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
# 3 space indentation
[*.{c,h,js,css,html}]
indent_style = space
indent_size = 3
# Tab indentation
[Makefile*]
indent_style = tab

13
.github/FUNDING.yml vendored
View File

@ -1,12 +1 @@
# These are supported funding model platforms
github: [libretro]
patreon: libretro
open_collective: # Replace with a single Open Collective username
ko_fi: # Replace with a single Ko-fi username
tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
liberapay: # Replace with a single Liberapay username
issuehunt: # Replace with a single IssueHunt username
otechie: # Replace with a single Otechie username
custom: # Replace with a single custom sponsorship URL
patreon: Rinnegatamante

View File

@ -1,35 +0,0 @@
# First and foremost consider this:
- Only RetroArch bugs should be filed here. Not core bugs or game bugs
- This is not a forum or a help section, this is strictly developer oriented
## Description
[Description of the bug]
### Expected behavior
[What you expected to happen]
### Actual behavior
[What is actually happening]
### Steps to reproduce the bug
1. [First step]
2. [Second step]
3. [and so on...]
### Bisect Results
[Try to bisect and tell us when this started happening]
### Version/Commit
You can find this information under Information/System Information
- RetroArch: [version/commit]
### Environment information
- OS: [The operating system you're running]
- Compiler: [In case you are running local builds]

View File

@ -1,21 +0,0 @@
## Guidelines
1. Rebase before opening a pull request
2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each
3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises
## Description
[Description of the pull request, detail any issues you are fixing or any features you are implementing]
## Related Issues
[Any issues this pull request may be addressing]
## Related Pull Requests
[Any other PRs from related repositories that might be needed for this pull request to work]
## Reviewers
[If possible @mention all the people that should review your pull request]

232
.gitignore vendored
View File

@ -1,187 +1,57 @@
*.o
*.bmpobj
*.binobj
*.so
*.dll
*.a
*.vpk
*.elf
*.dol
*.map
*.swp
.tmp
.tmp.c
.tmp.cxx
.moc.h
.moc.cpp
config.log
/.project
/.externalToolBuilders/
/retroarch
/retroarch.cfg
/retroarch.exe
/retroarch_debug.exe
/config.h
/config.mk
/tools/retroarch-joyconfig
/tools/retroarch-joyconfig.exe
*.ncb
*.sdf
*.opensdf
*.suo
Debug
Release
ipch
*.user
/bootstrap/gx/wii/app_booter/app_booter.bin
*.zip
RetroArch-w32/
RetroArch-w64/
*.velf
*.bin
*.sfo
# Windows image file caches
Thumbs.db
ehthumbs.db
# Folder config file
Desktop.ini
# Recycle Bin used on file shares
$RECYCLE.BIN/
# Windows Installer files
*.cab
*.msi
*.msm
*.msp
# Windows shortcuts
*.lnk
# =========================
# Operating System Files
# =========================
# OSX
# =========================
.DS_Store
*/build/*
*.pbxuser
!default.pbxuser
*.mode1v3
!default.mode1v3
*.mode2v3
!default.mode2v3
*.perspectivev3
!default.perspectivev3
xcuserdata
profile
*.moved-aside
DerivedData
.idea/
*.hmap
apple/tmp
apple/*.mobileprovision
apple/RetroArch_iOS.xcodeproj/project.xcworkspace/*
/Cg/
/GL/
/SDL/
/ffmpeg/
/freetype2/
/ft2build.h
/iconv.h
/phoenix/
/python/
/rsound.h
.pc
/media/shaders_glsl/
/obj-w32/
.cproject
.settings
libretro-super
run.sh
convert_rumble.awk
*~
assets
info
content_image_history.lpl
saves
screenshots
.AppleDouble
.LSOverride
# Thumbnails
._*
# Wii U
*.depend
*.rpx
*.last
wiiu/wut/elf2rpl/elf2rpl
/pkg/wiiu/retroarch
/pkg/wiiu/wiiu
/pkg/wiiu/rpx
/wiiu-devel.properties
# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
# 3ds
/.lst
*.3dsx
*.cia
*.3ds
*.bnr
*.smdh
/retroarch_3ds.core
/retroarch_3ds.icn
/retroarch_3ds_salamander.icn
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
# Ctags
/tags
# CLion
/cmake-build-debug/
# Android
/pkg/android/phoenix/obj/
/pkg/android/phoenix/assets/
/pkg/android/phoenix/libs/
/pkg/android/phoenix/bin/
/pkg/android/phoenix/gen/
/pkg/android/phoenix/local.properties
/pkg/android/phoenix/gradle.properties
/pkg/android/phoenix/.gradle
/pkg/android/phoenix/.externalNativeBuild
/pkg/android/phoenix/build
# Cloned by libretro-fetch.sh
/media/assets/
/media/autoconfig/
/media/overlays/
/media/shaders_cg/
/media/libretrodb/
pkg/apple/iOS/build/
pkg/apple/build/
ui/drivers/qt/moc_*
ui/drivers/moc_*
obj-unix/
.vagrant/
/pkg/msvc/Release Cg/*.exe
/pkg/msvc/Release Cg/*.iobj
/pkg/msvc/Release Cg/*.ipdb
/pkg/msvc/Release Cg/*.pdb
/pkg/msvc/Release Cg/*.lpl
/pkg/msvc/Release Cg/*.cfg
/pkg/msvc/*.db
/pkg/msvc/.vs
/pkg/msvc/*/.vs
/pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.tlog
/pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.lastbuildstate
/pkg/msvc/msvc-2010/Release Cg/*.log
/pkg/msvc/msvc-2010/Release Cg/*.obj
/pkg/msvc/msvc-2010/Release Cg/*.res
/pkg/msvc/msvc-2010/Release Cg/*.pdb
retroarch.cfg
Makefile.local
# Emscripten artifacts
retroarch.js
retroarch.js.mem
*.bc
*.wasm
# only ignore .js files in the repo root
/*.js
# Switch
*.d
exefs/*
retroarch_switch.pfs0
retroarch_switch.lst
retroarch_switch.nacp
retroarch_switch.nro
retroarch_switch.nso
# PS2
ps2/irx/*.c
ps2/libcdvd/lib/
# Wayland
gfx/common/wayland/idle-inhibit-unstable-v1.c
gfx/common/wayland/idle-inhibit-unstable-v1.h
gfx/common/wayland/xdg-shell-unstable-v6.c
gfx/common/wayland/xdg-shell-unstable-v6.h
gfx/common/wayland/xdg-decoration-unstable-v1.h
gfx/common/wayland/xdg-decoration-unstable-v1.c
gfx/common/wayland/xdg-shell.c
gfx/common/wayland/xdg-shell.h
# Vita build stuffs
*.a
*.o

View File

@ -1,8 +0,0 @@
before_script:
- apt-get update -qq && apt-get install -y -qq git build-essential
- apt-get update -qq && apt-get build-dep -y retroarch
build:
script:
- ./configure
- make -j2

View File

@ -1,27 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>RetroArch_</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.genmakebuilder</name>
<triggers>clean,full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.cdt.core.cnature</nature>
<nature>org.eclipse.cdt.core.ccnature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.managedBuildNature</nature>
<nature>org.eclipse.cdt.managedbuilder.core.ScannerConfigNature</nature>
</natures>
</projectDescription>

View File

@ -1,208 +0,0 @@
# This setting is to prevent travis to launch duplicate builds on PRs
branches:
only:
- master
- /^v.*$/
# Use 'generic' to be able to override CC/CXX for clang
language: generic
# Use a release with a longer normal LTS
dist: xenial
matrix:
include:
- compiler: mingw-x86
addons: true
env: CROSS_COMPILE=i686-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: mingw-x86
addons: true
env: C89_BUILD=1 CROSS_COMPILE=i686-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: mingw-x86
addons: true
env: CXX_BUILD=1 CROSS_COMPILE=i686-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: mingw-x64
addons: true
env: CROSS_COMPILE=x86_64-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: mingw-x64
addons: true
env: C89_BUILD=1 CROSS_COMPILE=x86_64-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: mingw-x64
addons: true
env: CXX_BUILD=1 CROSS_COMPILE=x86_64-w64-mingw32- CFLAGS="-D_WIN32_WINNT=0x0501"
- compiler: gcc
env: CC=gcc-8 CXX=g++-8
- compiler: gcc
env: CC="gcc-8 --sysroot=/" CXX="g++-8 --sysroot=/"
- compiler: gcc
env: C89_BUILD=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: CXX_BUILD=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_MENU=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_NETWORKING=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_OVERLAY=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_CDROM=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_VIDEO_LAYOUT=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_THREADS=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: DISABLE_AUDIOMIXER=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: ENABLE_GLES=1 CC=gcc-8 CXX=g++-8
- compiler: gcc
env: ENABLE_GLES=1 ENABLE_GLES3=1 CC=gcc-8 CXX=g++-8
- compiler: clang
env: CC=clang-6.0 CXX=clang++-6.0
- compiler: clang
env: C89_BUILD=1 CC=clang-6.0 CXX=clang++-6.0
- compiler: clang
env: CXX_BUILD=1 CC=clang-6.0 CXX=clang++-6.0
- os: osx
env: CC=clang CXX=clang++
- name: OSX OpenGL Make
os: osx
osx_image: xcode11.2
script:
- ./configure --enable-opengl --disable-metal
- make
- os: osx
osx_image: xcode8
script:
- xcodebuild -target RetroArch -configuration Release -project pkg/apple/RetroArch.xcodeproj
- os: osx
osx_image: xcode11.2
script:
- brew update-reset
- brew install --force-bottle qt5
- security create-keychain -p travis build.keychain
- security default-keychain -s build.keychain
- security unlock-keychain -p travis build.keychain
- echo $OSX_CERT | base64 --decode > dev.p12
- security import dev.p12 -k build.keychain -P $OSX_CERT_PASS -T /usr/bin/codesign
- rm dev.p12
- security set-key-partition-list -S "apple-tool:,apple:,codesign:" -s -k travis build.keychain
- xcodebuild -target RetroArchQt -configuration Release -project pkg/apple/RetroArch_Metal.xcodeproj
deploy:
skip_cleanup: true
provider: script
script: bash travis_metal_deploy.sh
on:
branch: master
- language: android
# Android builds are only supported on Trusty
dist: trusty
android:
components:
- tools
- build-tools-28.0.3
- android-28
install:
- echo y | sdkmanager "ndk-bundle"
before_script:
- export ANDROID_NDK_HOME=$ANDROID_HOME/ndk-bundle
script:
- cd pkg/android/phoenix
- ./gradlew assembleNormalRelease
jobs:
allow_failure:
- os: osx
before_install:
- |
if [[ "$CC" =~ ^gcc-8.* ]]; then
# Install a more recent gcc than the default
sudo apt-get install -y g++-8
elif [ "$CC" = clang-6.0 ]; then
# Install a more recent clang than the default
sudo apt-get install -y clang-6.0
elif [ "$CROSS_COMPILE" = i686-w64-mingw32- ]; then
sudo update-alternatives --set i686-w64-mingw32-g++ /usr/bin/i686-w64-mingw32-g++-posix
elif [ "$CROSS_COMPILE" = x86_64-w64-mingw32- ]; then
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
fi
before_script:
- |
if [ -n "$CROSS_COMPILE" ]; then
ARGS="$ARGS --disable-d3d8 --disable-d3d9 --disable-d3d10 --disable-d3d11 --disable-d3d12"
fi
- |
if [ -n "$DISABLE_MENU" ]; then
ARGS="$ARGS --disable-menu"
fi
- |
if [ -n "$DISABLE_OVERLAY" ]; then
ARGS="$ARGS --disable-overlay"
fi
- |
if [ -n "$DISABLE_NETWORKING" ]; then
ARGS="$ARGS --disable-networking"
fi
- |
if [ -n "$DISABLE_CDROM" ]; then
ARGS="$ARGS --disable-cdrom"
fi
- |
if [ -n "$DISABLE_VIDEO_LAYOUT" ]; then
ARGS="$ARGS --disable-video_layout"
fi
- |
if [ -n "$DISABLE_THREADS" ]; then
ARGS="$ARGS --disable-threads --disable-glslang"
fi
- |
if [ -n "$DISABLE_AUDIOMIXER" ]; then
ARGS="$ARGS --disable-audiomixer"
fi
- |
if [ -n "$ENABLE_GLES" ]; then
ARGS="$ARGS --enable-opengles"
fi
- |
if [ -n "$ENABLE_GLES3" ]; then
ARGS="$ARGS --enable-opengles3"
fi
- echo "Configure arguments = $ARGS"
script:
- ./configure $ARGS
- |
if [ -n "$C89_BUILD" ]; then
make C89_BUILD=1
elif [ -n "$CXX_BUILD" ]; then
make CXX_BUILD=1
else
make
fi
env:
global:
- ARGS=""
- MAKEFLAGS="-j2"
- secure: "qc91ReC3OlzSh2gFaSH6TYzC2qIQvgA2AZff6J13eaH8xijAhuMzttZ0rMQJ0DWCIhPeUb0kIzVyaGoe4MwPALzpw1C1AznIWiZJ53HN+hWCOcS/af7YVPk6HPySnwqrS+Wv3AIIvIKFV2mxv21F/JbT/N+pArlRrp904Xj+KPo="
addons:
apt:
packages:
- libsdl2-dev
- libusb-1.0-0-dev
- qtbase5-dev
- qtdeclarative5-dev
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial
coverity_scan:
project:
name: "RetroArch"
description: "RetroArch is the official reference frontend for the libretro API."
notification_email: libretro@gmail.com
build_command_prepend: "./configure; make clean"
build_command: "make"
branch_pattern: coverity_scan
notifications:
email: true

View File

@ -1,155 +0,0 @@
{
"configurations": [
{
"name": "Mac",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}",
"${workspaceRoot}/libretro-common/include"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"macFrameworkPath": [
"/System/Library/Frameworks",
"/Library/Frameworks"
]
},
{
"name": "Linux",
"includePath": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}",
"${workspaceFolder}/libretro-common/include",
"${workspaceRoot}/libretro-common/include"
],
"defines": [],
"intelliSenseMode": "clang-x64",
"browse": {
"path": [
"/usr/include",
"/usr/local/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Win32",
"includePath": [
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt",
"${workspaceRoot}",
"${workspaceFolder}/libretro-common/include"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared",
"C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
},
"cStandard": "c11",
"cppStandard": "c++17"
},
{
"name": "msys2-mingw32",
"includePath": [
"C:/msys64/mingw32/include",
"C:/msys64/mingw32/i686-w64-mingw32/include",
"${workspaceRoot}/libretro-common/include",
"${workspaceRoot}/include",
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/msys64/mingw32/include",
"C:/msys64/mingw32/i686-w64-mingw32/include",
"${workspaceRoot}/libretro-common/include",
"${workspaceRoot}/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "msys2-mingw64",
"includePath": [
"C:/msys64/mingw64/include",
"C:/msys64/mingw64/x86_64-w64-mingw32/include",
"${workspaceRoot}/libretro-common/include",
"${workspaceRoot}/include",
"${workspaceRoot}"
],
"defines": [
"_DEBUG",
"UNICODE"
],
"intelliSenseMode": "msvc-x64",
"browse": {
"path": [
"C:/msys64/mingw64/include",
"C:/msys64/mingw64/x86_64-w64-mingw32/include",
"${workspaceRoot}/libretro-common/include",
"${workspaceRoot}/include",
"${workspaceRoot}"
],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
},
{
"name": "Switch",
"includePath": [
"/opt/devkitpro/devkitA64/aarch64-none-elf/include",
"/opt/devkitpro/devkitA64/lib/gcc/aarch64-none-elf/8.3.0/include",
"/opt/devkitpro/libnx/include",
"/opt/devkitpro/portlibs/switch/include",
"/opt/devkitpro/portlibs/switch/include/freetype2",
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE",
"__aarch64__",
"__SWITCH__",
"HAVE_LIBNX"
],
"windowsSdkVersion": "10.0.17763.0",
"compilerPath": "/opt/devkitpro/devkitA64/bin/aarch64-none-elf-gcc",
"cStandard": "c11",
"cppStandard": "c++11",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}

70
.vscode/launch.json vendored
View File

@ -1,70 +0,0 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/retroarch.exe",
"args": ["-v"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "(gdb) Attach",
"type": "cppdbg",
"request": "attach",
"program": "${workspaceFolder}/retroarch.exe",
"processId": "${command:pickProcess}",
"MIMode": "gdb",
"miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
},
{
"name": "PSP-GDB Debugger",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/retroarchpsp.elf",
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"setupCommands": [
{
"text": "symbol-file ${workspaceFolder}/retroarchpsp.elf",
"description": "read symbols for elf file",
"ignoreFailures": true
},
{
"description": "Enable all-exceptions",
"text": "-exec \"catch throw\"",
"ignoreFailures": true
}
],
"showDisplayString": true,
"targetArchitecture": "mips",
"MIMode": "gdb",
"miDebuggerPath": "/usr/local/pspdev/bin/psp-gdb",
"miDebuggerServerAddress": "127.0.0.1:10001",
}
]
}

72
.vscode/settings.json vendored
View File

@ -1,72 +0,0 @@
{
"terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe",
"terminal.integrated.env.windows": {
"PATH": "/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:$PATH",
"MSYSTEM": "MINGW64",
},
"terminal.integrated.cursorBlinking": true,
"editor.tabSize": 3,
"editor.detectIndentation": false,
"editor.renderWhitespace": "all",
"editor.insertSpaces": true,
"files.associations": {
"frontend_driver.h": "c",
"*.in": "c",
"*.rh": "c",
"array": "c",
"file_stream.h": "c",
"driver.h": "c",
"iosfwd": "c",
"xlocbuf": "c",
"xmemory0": "c",
"ios": "c",
"list": "c",
"input_driver.h": "c",
"menu_driver.h": "c",
"file_path.h": "c",
"unordered_map": "c",
"unordered_set": "c",
"sstream": "cpp",
"hash_map": "c",
"hash_set": "c",
"initializer_list": "c",
"string_view": "c",
"utility": "c",
"menu_input.h": "c",
"tasks_internal.h": "c",
"ozone.h": "c",
"ozone_theme.h": "c",
"ozone_texture.h": "c",
"string_list.h": "c",
"core_info.h": "c",
"thread": "c",
"xlocale": "c",
"gfx_widgets.h": "c",
"message_queue.h": "c",
"task_queue.h": "c",
"fifo_queue.h": "c",
"file_list.h": "c",
"strl.h": "c",
"configuration.h": "c",
"ozone_display.h": "c",
"verbosity.h": "c",
"retroarch.h": "c",
"gfx_animation.h": "c",
"netplay.h": "c",
"scaler.h": "c",
"deque": "c",
"vector": "c",
"xhash": "c",
"xiosbase": "c",
"xstring": "c",
"xtree": "c",
"xutility": "c",
"menu_input_dialog.h": "c",
"menu_filebrowser.h": "c",
"ozone_sidebar.h": "c",
"menu_thumbnail_path.h": "c",
"badges.h": "c"
},
"C_Cpp.dimInactiveRegions": false,
}

128
.vscode/tasks.json vendored
View File

@ -1,128 +0,0 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "linux clean build",
"type": "shell",
"group": "build",
"command": "make clean && ./configure && make -j12"
},
{
"label": "linux clean",
"type": "shell",
"group": "build",
"command": "make clean"
},
{
"label": "linux build with debug symbols",
"type": "shell",
"group": "build",
"command": "DEBUG=1 make -j12"
},
{
"label": "linux build",
"type": "shell",
"group": "build",
"command": "make -j12"
},
{
"label": "linux build and run",
"type": "shell",
"group": "build",
"command": "make -j12 && ./retroarch -v"
},
{
"label": "linux build and run with debug symbols",
"type": "shell",
"group": "build",
"command": "DEBUG=1 make -j12 && ./retroarch -v"
},
{
"label": "msys2-mingw64 build",
"type": "shell",
"group": {
"kind": "build",
"isDefault": true
},
"command": "./configure; make -j2",
"options": {
"shell": {
"executable": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"-c"
]
}
}
},
{
"label": "msys2-mingw64 build with debug symbols",
"type": "shell",
"group": "build",
"command": "./configure; DEBUG=1 make -j2",
"options": {
"shell": {
"executable": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"-c"
]
}
}
},
{
"label": "msys2-mingw64 rebuild",
"type": "shell",
"group": "build",
"command": "make -j2",
"options": {
"shell": {
"executable": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"-c"
]
}
}
},
{
"label": "msys2-mingw64 clean",
"type": "shell",
"group": "build",
"command": "make clean",
"options": {
"shell": {
"executable": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"-c"
]
}
}
},
{
"label": "msys2-mingw64 run",
"type": "shell",
"group": {
"kind": "test",
"isDefault": true },
"command": "./retroarch -v",
"options": {
"shell": {
"executable": "C:\\msys64\\usr\\bin\\bash.exe",
"args": [
"-c"
]
}
}
}
]
}

View File

@ -1,96 +0,0 @@
diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c
index b90a8e40c3..e57c4df194 100644
--- a/gfx/drivers_context/wgl_ctx.c
+++ b/gfx/drivers_context/wgl_ctx.c
@@ -78,6 +78,47 @@
#ifndef WGL_CONTEXT_DEBUG_BIT_ARB
#define WGL_CONTEXT_DEBUG_BIT_ARB 0x0001
#endif
+
+#ifndef WGL_ACCELERATION_ARB
+#define WGL_ACCELERATION_ARB 0x2003
+#endif
+
+#ifndef WGL_FULL_ACCELERATION_ARB
+#define WGL_FULL_ACCELERATION_ARB 0x2027
+#endif
+
+#ifndef WGL_DRAW_TO_WINDOW_ARB
+#define WGL_DRAW_TO_WINDOW_ARB 0x2001
+#endif
+
+#ifndef WGL_DOUBLE_BUFFER_ARB
+#define WGL_DOUBLE_BUFFER_ARB 0x2011
+#endif
+
+#ifndef WGL_RED_BITS_ARB
+#define WGL_RED_BITS_ARB 0x2015
+#endif
+
+#ifndef WGL_GREEN_BITS_ARB
+#define WGL_GREEN_BITS_ARB 0x2017
+#endif
+
+#ifndef WGL_BLUE_BITS_ARB
+#define WGL_BLUE_BITS_ARB 0x2019
+#endif
+
+#ifndef WGL_ALPHA_BITS_ARB
+#define WGL_ALPHA_BITS_ARB 0x201B
+#endif
+
+#ifndef WGL_PIXEL_TYPE_ARB
+#define WGL_PIXEL_TYPE_ARB 0x2013
+#endif
+
+#ifndef WGL_TYPE_RGBA_ARB
+#define WGL_TYPE_RGBA_ARB 0x202B
+#endif
+
#endif
#if defined(HAVE_OPENGL)
@@ -313,6 +354,43 @@ static void create_gl_context(HWND hwnd, bool *quit)
RARCH_LOG("[WGL]: Adaptive VSync supported.\n");
wgl_adaptive_vsync = true;
}
+ if (wgl_has_extension("WGL_ARB_pixel_format", extensions))
+ {
+ BOOL (WINAPI * wglChoosePixelFormatARB)
+ (HDC hdc,
+ const int *piAttribIList,
+ const FLOAT *pfAttribFList,
+ UINT nMaxFormats,
+ int *piFormats,
+ UINT *nNumFormats);
+ UINT nMatchingFormats;
+ int index = 0;
+ int attribsDesired[] = {
+ WGL_DRAW_TO_WINDOW_ARB, 1,
+ WGL_ACCELERATION_ARB, WGL_FULL_ACCELERATION_ARB,
+ WGL_PIXEL_TYPE_ARB, WGL_TYPE_RGBA_ARB,
+ WGL_RED_BITS_ARB, 10,
+ WGL_GREEN_BITS_ARB, 10,
+ WGL_BLUE_BITS_ARB, 10,
+ WGL_ALPHA_BITS_ARB, 2,
+ WGL_DOUBLE_BUFFER_ARB, 1,
+ 0,0
+ };
+ wglChoosePixelFormatARB = (BOOL (WINAPI *) (HDC, const int *,
+ const FLOAT*, UINT, int*, UINT*))
+ gfx_ctx_wgl_get_proc_address("wglChoosePixelFormatARB");
+
+ RARCH_LOG("[WGL]: ARB pixel format supported.\n");
+
+ if (wglChoosePixelFormatARB(win32_hdc, attribsDesired,
+ NULL, 1, &index, &nMatchingFormats))
+ {
+ if (nMatchingFormats == 0)
+ {
+ RARCH_WARN("No 10bpc WGL_ARB_pixel_formats found!\n");
+ }
+ }
+ }
}
}
#endif

321
AUTHORS.h
View File

@ -1,321 +0,0 @@
static const char *retroarch_contributors_list = R"(
RetroArch and the libretro team would like to
acknowledge the following contributors:
1ch (L0sted)
Aaahh Ahh (Aaahh)
Aaron Oneal (aarononeal)
Adam Londero (alondero)
Adam Mechtley (amechtley)
AdrianoML
ajefr
Alberto Simon (asimonf)
Alcaro
Aleksey Samoilov (Sunderland93)
Alessandro Mangone (Vektor) (zevektor)
Alex Eckhart (alex34567)
Alex Folland (AlexFolland)
Alexander Spady (alkaseltzerspadt)
Alexandre Garcia (Alexandre-Garcia)
Alfredo Monclus (alfrix)
aliaspider
alphanu1
altiereslima
Alwin Garside (Yogarine)
Amiga1200Gamer (amigagamer)
Andre Leiradella (leiradel)
Andrés (fr500)
Anthony J. Bentley (bentley)
Antonio Jose Ramos Marquez (psxdev)
AridRayne
ArnaudFaucher
Arto Vainiolehto (arakerlu)
Ash (QuarkTheAwesome)
Ashura (CoalaJoe)
Autechre64
Avton1
ayssia
barbudreadmon
bearoso
benutzer193
blackgur
Boris Timofeev (btimofeev)
bparker06
Brandon Johnson (Denu8thell)
Brian Koropoff (bkoropoff)
Brian S. Stephan (bsstephan)
Brunnis
bubuleur
Casey Borders (CaseyB)
ceb33
celerizer
Chris Merrett (chrisfu)
Christian Murphy (grimpunch)
chu (9chu)
CidVonHighwind
clienthax
cold-brewed
CompCom
Conn O'Griofa (psyke83)
CozmoP
cpsw
Cray Elliott (MP2E)
Cristian Sandu (crazyquark)
ctult
cucholix
cudencuden
cxd4
dalter
Dan Weiss (Dwedit)
danieljg
Daniil Zhilin (LaserMoai)
dankcushions
Dave (freakdave)
Dave Leaver (danzel)
David Demelier (markand)
David Erickson (daviderickson)
David Shah (daveshah1)
David Walters (hiddenasbestos)
DEX357
diablodiab
dibas
Diego A. (SuperrSonic)
Diego Viola (diegoviola)
Diogo Barros (BlueKore)
DogParty
dor3k
driver1998
Dudu Akiva (duduke)
duganchen
dukemiller
duskgao
ekipan
Emmanuel Martin (daliaetnano)
endrift
erbridge
esoptron
Ethan Lee (flibitijibibo)
Exvat
Ezio-PS
Fabio (Oibaf66)
Fabio Ritrovato (Sephiroth87)
Fayne Aldan (FayneAldan)
FIX94
Flame Sage (chris062689)
flyinghead
Francisco Javier Trujillo Mata (fjtrujy)
Francisco José García García (frangarcj)
Gabriel (Ghabry)
GameDragon2k
Garrett Brown (garbear)
gblues
Geoffrey Plitt (GeoffreyPlitt)
Glenn Hevey (hevey)
Googer
gouchi
grant2258
Gregor Richards (GregorR)
Gui Andrade (archshift)
Gustavo Maciel Dias Vieira (gmdvieira)
gvbr
H. İbrahim Güngör (igungor)
hadess
Hans-Kristian Arntzen (Themaister)
Henri Gomez (hgomez)
Henri Gomez (hgomez-sonarsource)
Higor Eurípedes (heuripedes)
Hisman Yosika (dnjstlr555)
hizzlekizzle
Hugo B. (hug0b)
Hugo Hromic (hhromic)
hunterk
hyarsan
Hyllian
i30817
iAmGhost
Jack (jakcron)
Jacob (cubtekki)
James Le Cuirot (chewi)
James Sexton (Bezier89)
Jamiras
Jan Holthuis (Holzhaus)
Jay McCarthy (jeapostrophe)
jdgleaver
Jean-André Santoni (kivutar)
Jean-Paul Mari (djipi)
Jean-Sébastien Guay (Skylark13)
Jesse Bryan (winneon)
Joel (joel16)
Joerg Sonnenberger (jsonn)
Johannes Schickel (lordhoto)
John Regan (jprjr)
Jon Maddox (maddox)
Jonathan Relf (jonathanrelf)
Joohan Lee (losernator)
Jools Wills (joolswills)
Jose Lage Miguez (Joselagem)
Joseph Carter (iKarith)
Joseph Conan Montgomery (Grotke)
Josh Palmer (ShiftyAxel)
JuanVCS
Justin Jacobs (dorkster)
Justin Weiss (justinweiss)
Ken Rossato (rossato)
krzys_h (krzys-h)
kurumushi
kwyxz
l3iggs
lambolighting
lasers
Lawrence Kesteloot (lkesteloot)
lifajucejo
liffy (lifning)
Lionel Flandrin (simias)
littleguy77
Logan (loganmc10)
lordashram
Lothar Serra Mari (lotharsm)
Lubosz Sarnecki (lubosz)
lucianposton
lxerandrew
m4xw
Mahyar Koshkouei (deltabeard)
Manuel Alfayate Corchete (vanfanel)
Marcelo Munhoz Pélos (mpelos)
markwkidd
Maschell
Mat M. (lioncash)
Mats A. (Datamats)
Matt Sephton (gingerbeardman)
Matthew Wang (asakous)
Max K. (langerhans)
Maxime Gauduin (alucryd)
mcrisostomo
meancoot
meepingsnesroms
meleu
Michael K. (kuxii2016)
Michael Lelli (ToadKing)
Michał Durak (micechal)
mickski56
Mico Chopitea (micochops)
miguelpinheiro
Mike Swanson (chungy)
miqlas (extrowerk)
misson20000
Monroe88
mprobinson
MrHuu
MrJs (mrjschulte)
muzuiget
mwtremblay
myfreeweb
Nathan S. (natinusala)
NathanStrong-Tripwire
nattycleopatra
nayslayer
netux79
nfnty
nia (ensra)
Nicolas Adenis-Lamarre (nadenislamarre)
Nicolas Guillaumin (nguillaumin)
Nicolas Lopez Fernandez (pyroesp)
Nikita Vakhrushev (SwooodGa)
Nikola Kocić (nikola-kocic)
Niouby
nosh01
not6 (r-type)
notaz
nstCactus
nurupo
Oggom
Oleg Shevchenko (olsh)
opendata26
orbea
OV2
pamapa
Paolo Bonzini (bonzini)
Paul McCarty (notabeatle)
Pedro Ribeiro (pedrib)
pinumbernumber
pponso1
Ramiro Morales (ramiro)
Raphaël Zumer (rzumer)
retro-wertz
retrotails
reztek
Richard Howell (rmaz)
rlnilsen
Rob Loach (RobLoach)
Romain Gay (vikbez)
Romain Graillot (notnotme)
Romain TISSERAND (rtissera)
Roman Kalashnikov (lunixoid)
Royerson
rrooij
rsn8887
Ryunam
rz5
Saggi Mizrahi (ficoos)
SAKUJ0
Sam Pagenkopf (44100hertz)
Sam Stenvall (Jalle19)
Samuel P. (p-sam)
Scheiker
Sebastien Ronsse (sronsse)
Sergi Granell (xerpi)
Sergio Padrino (sergiou87)
sergio-br2 (sergiobenrocha2)
Seth Kingsley (sethk)
Shane Mouton (ismouton)
Shizeeg Unadequatov (shizeeg)
slotek
sparklewind
spec-chum
Stefan (gizmo98)
stefan-gr
stellarporter
Steven M. Vascellaro (stevoisiak)
Stuart Carnie (stuartcarnie)
Sunguk Lee (d3m3vilurr)
Supernature2k
Sven (RetroSven)
Swingflip
Swizzy
Sylvain Colinet (Skarsnik)
Tatsuya79
Terry Lewis (terry-au)
thedax
theheroGAC
TheMrIron2
TheOfficialFloW
thiolliere
Thomas Lorblanchès (Zlika)
Tobias Jakobi (tobiasjakobi)
Tomáš Kelemen (ToKe79)
Torsten Paul (t-paul)
TotalCaesar659
TroggleMonkey
Twinaphex
URBANsUNITED
vgmoose
Vicky C Lau (vickychenglau)
Vladimir Panteleev (CyberShadow)
Vladimir Serbinenko (phcoder)
Víctor "IlDucci" (IlDucci)
waitingmoon
Wang Vincent (susemm)
webgeek1234
Weedy Weed Smoker (WeedyWeedSmoker)
WerWolv
Wiimpathy
Wiktor Strzębała (wiktorek140)
xhp-creations
yesfish (huwpascoe)
Yongwoon Cho (ssangkong)
yoshisuga
zeromus
zlice
Zoran Vuckovic (casdevel)
Ömercan Kömür (fpscan)
)";

1396
CHANGES.md

File diff suppressed because it is too large Load Diff

View File

@ -1,58 +0,0 @@
# Contributing to RetroArch
If you are a developer and want to contribute to the development of RetroArch, please read this.
If you have found a bug and want to submit a minor patch or a bug report, please read this as well.
# Submitting a bug report
When submitting a bug report, make sure that the bug is local to RetroArch.
A bug in a libretro core or something deemed to be external is likely to be closed very fast.
If you still suspect a bug in RetroArch, make sure to test with several cores to make sure.
If you have troubles building RetroArch on Linux/BSD/OSX, make sure to paste shell output of ./configure,
as well as config.log and shell output of make. If building on Windows, just paste shell output of make.
If the issue occurs during runtime, make sure to paste RetroArch's verbose log.
If using Phoenix frontend, you can find log in (File -> Show Log) after running.
In console, make sure to run with verbose (-v) flag.
# Pull Requests
Outside contributions are generally only accepted in the form of a pull request. The process is very simple.
Fork RetroArch, make your changes, and issue a pull request on GitHub. This can all be done within the browser.
The changes are reviewed, and might be merged in. If the pull request isn't acceptable at the time,
note that it's possible to continue pushing up commits to your branch.
If you want to develop a larger feature,
we'd like to discuss this first (ideally on IRC) so that you don't risk developing something
that won't be merged. A pull request with a proof-of-concept is fine, but please indicate so.
## libretro API
If you wish to add functionality to libretro's API, it can take some time to merge in, because changes
to libretro API will affect other projects as well, and we highly value API/ABI stability.
Features will only be added when deemed *necessary* for a concrete libretro core to function properly.
Features will not be added on basis of hypothetical libretro implementations.
# Coding style
Having a consistent code style throughout the code base is highly valued.
Please look through the code to get a feel for the coding style.
A pull request may be asked to fix the coding style before submission.
In other cases, a pull request may be followed up with a "style nit commit".
## Non-obvious things:
- Code should be both C89 and ISO C++ compatible. This dual requirement is for XBox360 and MSVC in general. Think of it as a C++ compatible subset of C99.
- Warnings are not allowed (-Wall). Make sure your code is warning-free. Note that warning sensitivity differs a bit across compiler versions.
- Using deprecated APIs is discouraged.
# Copyright Headers and AUTHORS
If you have contributed to a part of a source file (a chunk of code that's written by you),
you should add yourself to the copyright header in that file.
If you have contributed significantly
(a feature, a contribution you can "name", e.g. "Added audio driver foo"), you should add yourself to AUTHORS file.
We'd like your full name and email, and which features you have been part of.
# IRC
Active development happens on IRC. (#retroarch @ irc.freenode.org)
We value discussing things in "real-time".
# Commit Access
Contributors who show a track record of making good pull requests over time will eventually get commit access to the repo.
This typically happens when the "overhead" of looking through pull requests over time becomes a burden.

View File

@ -1,7 +1,7 @@
GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
@ -645,7 +645,7 @@ the "copyright" line and a pointer to where the full notice is found.
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
along with this program. If not, see <https://www.gnu.org/licenses/>.
Also add information on how to contact you by electronic and paper mail.
@ -664,11 +664,11 @@ might be different; for a GUI interface, you would use an "about box".
You should also get your employer (if you work as a programmer) or school,
if any, to sign a "copyright disclaimer" for the program, if necessary.
For more information on this, and how to apply and follow the GNU GPL, see
<http://www.gnu.org/licenses/>.
<https://www.gnu.org/licenses/>.
The GNU General Public License does not permit incorporating your program
into proprietary programs. If your program is a subroutine library, you
may consider it more useful to permit linking proprietary applications with
the library. If this is what you want to do, use the GNU Lesser General
Public License instead of this License. But first, please read
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
<https://www.gnu.org/licenses/why-not-lgpl.html>.

2482
Doxyfile

File diff suppressed because it is too large Load Diff

349
Makefile
View File

@ -1,296 +1,79 @@
HAVE_FILE_LOGGER=1
NEED_CXX_LINKER?=0
NEED_GOLD_LINKER?=0
MISSING_DECLS =0
TARGET := libvitaGL
SOURCES := source source/utils
SHADERS := shaders
ifneq ($(C90_BUILD),)
C89_BUILD=1
ifeq ($(HAVE_SBRK),1)
SOURCES += source/hacks
endif
include config.mk
CFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.c))
ASMFILES := $(foreach dir,$(SOURCES), $(wildcard $(dir)/*.S))
CGFILES := $(foreach dir,$(SHADERS), $(wildcard $(dir)/*.cg))
HEADERS := $(CGFILES:.cg=.h)
OBJS := $(CFILES:.c=.o) $(ASMFILES:.S=.o)
# Put your favorite compile flags in this file, if you want different defaults than upstream.
# Do not attempt to create that file upstream.
# (It'd be better to put this comment in that file, but .gitignore doesn't work on files that exist in the repo.)
-include Makefile.local
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
AR = $(PREFIX)-gcc-ar
CFLAGS = -g -Wl,-q -O2 -ffast-math -mtune=cortex-a9 -mfpu=neon -ftree-vectorize -DSTB_DXT_IMPLEMENTATION
ASFLAGS = $(CFLAGS)
ifeq ($(HAVE_ANGLE), 1)
TARGET = retroarch_angle
else
TARGET = retroarch
ifeq ($(NO_DEBUG),1)
CFLAGS += -DSKIP_ERROR_HANDLING
endif
OBJ :=
LIBS :=
DEF_FLAGS :=
ASFLAGS :=
DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64
DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"'
OBJDIR_BASE := obj-unix
ifeq ($(NEED_GOLD_LINKER), 1)
LDFLAGS += -fuse-ld=gold
ifeq ($(HAVE_SHARK),1)
CFLAGS += -DHAVE_SHARK
endif
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
CFLAGS ?= -O0 -g
CXXFLAGS ?= -O0 -g
DEFINES += -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
CFLAGS ?= -O3
CXXFLAGS ?= -O3
DEF_FLAGS += -ffast-math
endif
all: $(TARGET).a
DEF_FLAGS += -Wall
$(TARGET).a: $(OBJS)
$(AR) -rc $@ $^
ifneq ($(findstring BSD,$(OS)),)
DEF_FLAGS += -DBSD
LDFLAGS += -L/usr/local/lib
UDEV_CFLAGS += -I/usr/local/include/libepoll-shim
UDEV_LIBS += -lepoll-shim
endif
ifneq ($(findstring DOS,$(OS)),)
DEF_FLAGS += -march=i386
LDFLAGS += -lemu
endif
ifneq ($(findstring FPGA,$(OS)),)
DEFINES += -DHAVE_FPGA
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -static-libgcc -lwinmm
endif
include Makefile.common
ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"),1)
DEF_FLAGS += -Wno-invalid-source-encoding -Wno-incompatible-ms-struct
endif
ifeq ($(shell $(CC) -v 2>&1 | grep -c "tcc"),1)
MD = -MD
else
MD = -MMD
endif
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
ifeq ($(MISSING_DECLS), 1)
DEF_FLAGS += -Werror=missing-declarations
endif
ifeq ($(HAVE_DYLIB), 1)
LIBS += $(DYLIB_LIB)
endif
ifeq ($(HAVE_DYNAMIC), 1)
LIBS += $(DYLIB_LIB)
else
LIBS += $(libretro)
endif
ifneq ($(V),1)
Q := @
endif
ifeq ($(HAVE_DRMINGW), 1)
DEF_FLAGS += -DHAVE_DRMINGW
LDFLAGS += $(DRMINGW_LIBS)
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -mwindows
endif
ifneq ($(CXX_BUILD), 1)
ifneq ($(C89_BUILD),)
CFLAGS += -std=c89 -ansi -pedantic -Werror=pedantic -Wno-long-long
else ifeq ($(HAVE_C99), 1)
CFLAGS += $(C99_CFLAGS)
endif
CFLAGS += -D_GNU_SOURCE
endif
DEF_FLAGS += $(INCLUDE_DIRS) -I. -Ideps -Ideps/stb
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS) -D__STDC_CONSTANT_MACROS
OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
ifeq ($(HAVE_CXX), 1)
ifeq ($(CXX_BUILD), 1)
LINK = $(CXX)
CFLAGS := $(CXXFLAGS) -xc++
CFLAGS += -DCXX_BUILD
CXXFLAGS += -DCXX_BUILD
else ifeq ($(NEED_CXX_LINKER),1)
LINK = $(CXX)
else
LINK = $(CC)
endif
else
LINK = $(CC)
endif
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
ifneq ($(X86),)
CFLAGS += -m32
CXXFLAGS += -m32
LDFLAGS += -m32
endif
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
CXXFLAGS := -fsanitize=$(SANITIZER) $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
endif
ifneq ($(findstring $(GPERFTOOLS),profiler),)
LIBS += -lprofiler
endif
ifneq ($(findstring $(GPERFTOOLS),tcmalloc),)
LIBS += -ltcmalloc
endif
# Qt MOC generation, required for QObject-derived classes
ifneq ($(MOC_HEADERS),)
# prefix moc_ to base filename of paths and change extension from h to cpp, so a/b/foo.h becomes a/b/moc_foo.cpp
MOC_SRC := $(join $(addsuffix moc_,$(addprefix $(OBJDIR)/,$(dir $(MOC_HEADERS)))), $(notdir $(MOC_HEADERS:.h=.cpp)))
MOC_OBJ := $(patsubst %.cpp,%.o,$(MOC_SRC))
RARCH_OBJ += $(MOC_OBJ)
endif
all: $(TARGET) config.mk
$(MOC_SRC):
@$(if $(Q), $(shell echo echo MOC $<),)
$(eval MOC_TMP := $(patsubst %.h,%_moc.cpp,$@))
$(Q)QT_SELECT=$(QT_VERSION) $(MOC) -o $(MOC_TMP) $<
$(foreach x,$(join $(addsuffix :,$(MOC_SRC)),$(MOC_HEADERS)),$(eval $x))
$(MOC_OBJ):
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(foreach x,$(join $(addsuffix :,$(MOC_OBJ)),$(MOC_SRC)),$(eval $x))
ifeq ($(MAKECMDGOALS),clean)
config.mk:
else
-include $(RARCH_OBJ:.o=.d)
ifeq ($(HAVE_CONFIG_MK),)
config.mk: configure qb/*
@echo "config.mk is outdated or non-existing. Run ./configure again."
@exit 1
endif
endif
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c config.h config.mk
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(MD) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp config.h config.mk
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(Q)$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
.FORCE:
$(OBJDIR)/git_version.o: git_version.c .FORCE
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S config.h config.mk $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(Q)$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.rc $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo WINDRES $<),)
$(Q)$(WINDRES) -o $@ $<
install: $(TARGET)
rm -f $(OBJDIR)/git_version.o
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/applications 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DOC_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(DATA_DIR)/pixmaps 2>/dev/null || /bin/true
cp $(TARGET) $(DESTDIR)$(BIN_DIR)
cp tools/cg2glsl.py $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
cp retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)
cp retroarch.desktop $(DESTDIR)$(DATA_DIR)/applications
cp docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6
cp docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6
cp media/retroarch.svg $(DESTDIR)$(DATA_DIR)/pixmaps
cp COPYING $(DESTDIR)$(DOC_DIR)
cp README.md $(DESTDIR)$(DOC_DIR)
chmod 755 $(DESTDIR)$(BIN_DIR)/$(TARGET)
chmod 755 $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
chmod 644 $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
chmod 644 $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
chmod 644 $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
chmod 644 $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg
@if test -d media/assets && test $(HAVE_ASSETS); then \
echo "Installing media assets..."; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/assets; \
if test $(HAVE_MATERIALUI) = 1; then \
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
if test $(HAVE_XMB) = 1; then \
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
if test $(HAVE_OZONE) = 1; then \
cp -r media/assets/ozone/ $(DESTDIR)$(ASSETS_DIR)/assets; \
fi; \
cp media/assets/COPYING $(DESTDIR)$(DOC_DIR)/COPYING.assets; \
echo "Asset copying done."; \
fi
uninstall:
rm -f $(DESTDIR)$(BIN_DIR)/$(TARGET)
rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
rm -f $(DESTDIR)$(DATA_DIR)/applications/retroarch.desktop
rm -f $(DESTDIR)$(DATA_DIR)/pixmaps/retroarch.svg
rm -f $(DESTDIR)$(DOC_DIR)/COPYING
rm -f $(DESTDIR)$(DOC_DIR)/COPYING.assets
rm -f $(DESTDIR)$(DOC_DIR)/README.md
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
rm -rf $(DESTDIR)$(ASSETS_DIR)
%_f.h:
psp2cgc -profile sce_fp_psp2 $(@:_f.h=_f.cg) -Wperf -o $(@:_f.h=_f.gxp)
bin2c $(@:_f.h=_f.gxp) source/shaders/$(notdir $(@)) $(notdir $(@:_f.h=_f))
@rm -rf $(@:_f.h=_f.gxp)
%_v.h:
psp2cgc -profile sce_vp_psp2 $(@:_v.h=_v.cg) -Wperf -o $(@:_v.h=_v.gxp)
bin2c $(@:_v.h=_v.gxp) source/shaders/$(notdir $(@:_v.h=_v.h)) $(notdir $(@:_v.h=_v))
@rm -rf $(@:_v.h=_v.gxp)
shaders: $(HEADERS)
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
.PHONY: all install uninstall clean
print-%:
@echo '$*=$($*)'
@rm -rf $(TARGET).a $(TARGET).elf $(OBJS)
@make -C samples/sample1 clean
@make -C samples/sample2 clean
@make -C samples/sample3 clean
@make -C samples/sample4 clean
@make -C samples/sample5 clean
@make -C samples/sample6 clean
@make -C samples/sample7 clean
@make -C samples/sample8 clean
install: $(TARGET).a
@mkdir -p $(VITASDK)/$(PREFIX)/lib/
cp $(TARGET).a $(VITASDK)/$(PREFIX)/lib/
@mkdir -p $(VITASDK)/$(PREFIX)/include/
cp source/vitaGL.h $(VITASDK)/$(PREFIX)/include/
samples: $(TARGET).a
@make -C samples/sample1
cp "samples/sample1/vitaGL-Sample001.vpk" .
@make -C samples/sample2
cp "samples/sample2/vitaGL-Sample002.vpk" .
@make -C samples/sample3
cp "samples/sample3/vitaGL-Sample003.vpk" .
@make -C samples/sample4
cp "samples/sample4/vitaGL-Sample004.vpk" .
@make -C samples/sample5
cp "samples/sample5/vitaGL-Sample005.vpk" .
@make -C samples/sample6
cp "samples/sample6/vitaGL-Sample006.vpk" .
@make -C samples/sample7
cp "samples/sample7/vitaGL-Sample007.vpk" .
@make -C samples/sample8
cp "samples/sample8/vitaGL-Sample008.vpk" .

View File

@ -1,24 +0,0 @@
include Makefile.common
# Qt MOC generation, required for QObject-derived classes
ifneq ($(MOC_HEADERS),)
# prefix moc_ to base filename of paths and change extension from h to cpp, so a/b/foo.h becomes a/b/moc_foo.cpp
MOC_SRC := $(join $(addsuffix moc_,$(dir $(MOC_HEADERS))), $(notdir $(MOC_HEADERS:.h=.cpp)))
endif
MOC ?= $(error missing moc path)
.PHONY: generate
$(MOC_SRC):
@$(if $(Q), $(shell echo echo MOC $<),)
$(eval MOC_TMP := $(patsubst %.h,%_moc.cpp,$@))
$(MOC) -o $(MOC_TMP) $<
$(foreach x,$(join $(addsuffix :,$(MOC_SRC)),$(MOC_HEADERS)),$(eval $x))
generate: $(MOC_SRC)
@echo $(MOC_SRC)
print-%:
@echo '$*=$($*)'

View File

@ -1,49 +0,0 @@
# This build was put together and is maintained by ModMyClassic.com for Libretro.
# The purpose is to give Libretro a proper "official" build platform for classic consoles.
# If you need any help in building for the classics or have any questions then please visit
# https://modmyclassic.com and we will help in any way possible!
# Building Prerequisites ##############
# arm-linux-gnueabihf-strip
include version.all
# General Shared Variables ############
TARGET := retroarch
# Libretro Defines ####################
#HAVE_CLASSIC = Classic Hook, disable some features
#HAVE_C_A7A7 = Classic Armv7 Cortex A7 optimisation override
#HAVE_SEGAM = Sega Mini Hook, change default configurations etc (TODO)
all: $(TARGET)
retroarch:
#Build the RetroArch Binary for cross platform classics (ARMv7 Cortex A7)
patchelf --version #Check if you have patchelf installed... (sudo apt-get install patchelf)
CFLAGS="-marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard" ./configure --host=arm-linux-gnueabihf --disable-wayland --disable-x11 --disable-opengl --disable-opengl1 --disable-opengl_core --enable-mali_fbdev --disable-freetype --enable-opengles --enable-udev --enable-alsa --enable-neon --enable-floathard --disable-discord
make HAVE_CLASSIC=1 HAVE_C_A7A7=1 HAVE_SEGAM=1 -j #Cook it
arm-linux-gnueabihf-strip -v retroarch
@echo "*********************************************************************"
@echo "*** SEGA Mega Drive Mini RetroArch binary built successfully! ***"
@echo "*********************************************************************"
clean:
rm -rf obj-unix
rm -f *.d
rm -f *.o
rm -f audio/*.o
rm -f conf/*.o
rm -f gfx/*.o
rm -f gfx/drivers_font/*.o
rm -f gfx/drivers_font_renderer/*.o
rm -f gfx/drivers_context/*.o
rm -f gfx/py_state/*.o
rm -f compat/*.o
rm -f record/*.o
rm -f input/*.o
rm -f tools/*.o
rm -f $(BINDIR)/retroarch
rm -f $(BINDIR)/retroarch-joyconfig
rm -f $(PNDDIR)/readme.html
rm -f retroarch

View File

@ -1,53 +0,0 @@
# This build was put together and is maintained by ModMyClassic.com for Libretro.
# The purpose is to give Libretro a proper "official" build platform for classic consoles.
# If you need any help in building for the classics or have any questions then please visit
# https://modmyclassic.com and we will help in any way possible!
# INFO: THIS BUILD TARGET ALSO COVERS THE NESC!!!
# Building Prerequisites ##############
# arm-linux-gnueabihf-strip
# patchelf
include version.all
# General Shared Variables ############
TARGET := retroarch
# Libretro Defines ####################
#HAVE_CLASSIC = Classic Hook, disable some features
#HAVE_C_A7A7 = Classic Armv7 Cortex A7 optimisation override
#HAVE_HAKCHI = Hakchi Hook, change default configurations etc (TODO)
all: $(TARGET)
retroarch:
#Build the RetroArch Binary for cross platform classics (ARMv7 Cortex A7)
patchelf --version #Check if you have patchelf installed... (sudo apt-get install patchelf)
CFLAGS="-marm -mtune=cortex-a7 -mfpu=neon-vfpv4 -mfloat-abi=hard" ./configure --host=arm-linux-gnueabihf --disable-wayland --disable-x11 --disable-opengl --disable-opengl1 --disable-opengl_core --enable-mali_fbdev --disable-freetype --enable-opengles --enable-udev --enable-alsa --enable-neon --enable-floathard --disable-discord
make HAVE_CLASSIC=1 HAVE_C_A7A7=1 HAVE_HAKCHI=1 -j #Cook it
arm-linux-gnueabihf-strip -v retroarch
patchelf --replace-needed libSDL2-2.0.so.0 libSDL2.so retroarch #libSDL2-2.0.so.0 sym link doesn't exist on native build. Just patch the binary...
@echo "*********************************************************************"
@echo "*** NES/SNES Classic RetroArch binary built successfully! ***"
@echo "*********************************************************************"
clean:
rm -rf obj-unix
rm -f *.d
rm -f *.o
rm -f audio/*.o
rm -f conf/*.o
rm -f gfx/*.o
rm -f gfx/drivers_font/*.o
rm -f gfx/drivers_font_renderer/*.o
rm -f gfx/drivers_context/*.o
rm -f gfx/py_state/*.o
rm -f compat/*.o
rm -f record/*.o
rm -f input/*.o
rm -f tools/*.o
rm -f $(BINDIR)/retroarch
rm -f $(BINDIR)/retroarch-joyconfig
rm -f $(PNDDIR)/readme.html
rm -f retroarch

File diff suppressed because it is too large Load Diff

View File

@ -1,282 +0,0 @@
TARGET := retroarch_3ds
LIBRETRO =
DEBUG = 0
GRIFFIN_BUILD = 1
WHOLE_ARCHIVE_LINK = 0
BUILD_3DSX = 1
BUILD_3DS = 0
BUILD_CIA = 1
LIBCTRU_NO_DEPRECATION = 1
APP_TITLE = RetroArch 3DS
APP_DESCRIPTION = RetroArch 3DS
APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RETROARCH-3DS
APP_UNIQUE_ID = 0xBAC00
APP_ICON = pkg/ctr/assets/default.png
APP_BANNER = pkg/ctr/assets/libretro_banner.png
APP_AUDIO = pkg/ctr/assets/silent.wav
APP_RSF = pkg/ctr/tools/template.rsf
APP_SYSTEM_MODE = 64MB
APP_SYSTEM_MODE_EXT = 124MB
APP_BIG_TEXT_SECTION = 0
APP_USE_SVCHAX = 0
include pkg/ctr/Makefile.cores
OBJ :=
OBJ += gfx/drivers/ctr_shaders/ctr_sprite.o
OBJ += ctr/ctr_system.o
OBJ += ctr/ctr_memory.o
OBJ += ctr/ctr_linear.o
OBJ += ctr/gpu_old.o
OBJ += ctr/exec-3dsx/exec_cia.o \
ctr/exec-3dsx/exec_3dsx.o \
ctr/exec-3dsx/mini-hb-menu/launch.o \
ctr/exec-3dsx/mini-hb-menu/loaders/rosalina.o \
ctr/exec-3dsx/mini-hb-menu/loaders/hax2.o \
ctr/exec-3dsx/mini-hb-menu/loaders/ninjhax1.o
ifeq ($(APP_BIG_TEXT_SECTION), 1)
APP_USE_SVCHAX = 1
LDFLAGS += -Wl,--defsym,__ctr_patch_services=__service_ptr
endif
ifeq ($(APP_USE_SVCHAX), 1)
OBJ += ctr/ctr_svchax.o
endif
DEFINES :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_ZLIB -DHAVE_7ZIP -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA
DEFINES += -DHAVE_NETWORKING -DHAVE_CHEEVOS -DRC_DISABLE_LUA
#DEFINES += -DHAVE_SOCKET_LEGACY -DHAVE_THREADS
#-DHAVE_SSL -DHAVE_BUILTINMBEDTLS -DMBEDTLS_SSL_DEBUG_ALL
#ssl is currently incompatible with griffin due to use of the "static" flag on repeating functions that will conflict when included in one file
else
HAVE_CC_RESAMPLER = 1
HAVE_MENU_COMMON = 1
HAVE_RTGA = 1
HAVE_RPNG = 1
HAVE_RJPEG = 1
HAVE_RBMP = 1
HAVE_MENU = 1
HAVE_RGUI = 1
HAVE_ZLIB = 1
HAVE_7ZIP = 1
HAVE_BUILTINZLIB = 1
HAVE_LIBRETRODB = 1
HAVE_MATERIALUI = 1
HAVE_XMB = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
#HAVE_NETWORKING = 1
#HAVE_CHEEVOS = 1
#HAVE_SOCKET_LEGACY = 1
#HAVE_THREADS = 1
#HAVE_SSL = 1
#HAVE_BUILTINMBEDTLS = 1
include Makefile.common
CFLAGS += $(DEF_FLAGS)
BLACKLIST :=
BLACKLIST += input/input_overlay.o
BLACKLIST += tasks/task_overlay.o
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitpro")
endif
ifeq ($(strip $(CTRULIB)),)
CTRULIB = $(DEVKITPRO)/libctru
endif
APP_TITLE := $(shell echo "$(APP_TITLE)" | cut -c1-128)
APP_DESCRIPTION := $(shell echo "$(APP_DESCRIPTION)" | cut -c1-256)
APP_AUTHOR := $(shell echo "$(APP_AUTHOR)" | cut -c1-128)
APP_PRODUCT_CODE := $(shell echo $(APP_PRODUCT_CODE) | cut -c1-16)
APP_UNIQUE_ID := $(shell echo $(APP_UNIQUE_ID) | cut -c1-7)
MAKEROM_ARGS_COMMON = -rsf $(APP_RSF) -exefslogo -elf $(TARGET).elf -icon $(TARGET).icn -banner $(TARGET).bnr -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(APP_PRODUCT_CODE)" -DAPP_UNIQUE_ID=$(APP_UNIQUE_ID) -DAPP_SYSTEM_MODE=$(APP_SYSTEM_MODE) -DAPP_SYSTEM_MODE_EXT=$(APP_SYSTEM_MODE_EXT)
INCDIRS := -I$(CTRULIB)/include
LIBDIRS := -L. -L$(CTRULIB)/lib
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
CFLAGS += -mword-relocations \
-fomit-frame-pointer -ffast-math \
-Werror=implicit-function-declaration \
$(ARCH)
#CFLAGS += -Wall
CFLAGS += -DARM11 -D_3DS
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
ifeq ($(LIBCTRU_NO_DEPRECATION), 1)
CFLAGS += -DLIBCTRU_NO_DEPRECATION
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
CFLAGS += -I. \
-Ideps \
-Ideps/7zip \
-Ideps/stb \
-Ideps/rcheevos/include \
-Ilibretro-common/include \
-Ilibretro-common/include/compat/zlib
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH) -O3
LDFLAGS += -specs=ctr/3dsx_custom.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
CFLAGS += -std=gnu99 -ffast-math
LIBS := $(WHOLE_START) -lretro_ctr $(WHOLE_END) -lm
ifeq ($(DEBUG), 1)
LIBS += -lctrud
else
LIBS += -lctru
endif
ifeq ($(BUILD_3DSX), 1)
TARGET_3DSX := $(TARGET).3dsx $(TARGET).smdh
endif
ifeq ($(BUILD_3DS), 1)
TARGET_3DS := $(TARGET).3ds
endif
ifeq ($(BUILD_CIA), 1)
TARGET_CIA := $(TARGET).cia
endif
.PHONY: $(BUILD) clean all
all: $(TARGET)
$(TARGET): $(TARGET_3DSX) $(TARGET_3DS) $(TARGET_CIA)
$(TARGET).3dsx: $(TARGET).elf
$(TARGET).elf: $(OBJ) libretro_ctr.a
PREFIX := $(DEVKITARM)/bin/arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)
ifeq ($(strip $(CTRBANNERTOOL)),)
ifneq ($(findstring Linux,$(shell uname)),)
BANNERTOOL = pkg/ctr/tools/bannertool-linux
else ifneq ($(findstring Darwin,$(shell uname)),)
BANNERTOOL = pkg/ctr/tools/bannertool-mac
else
BANNERTOOL = pkg/ctr/tools/bannertool.exe
endif
else
BANNERTOOL = $(CTRBANNERTOOL)
endif
ifeq ($(strip $(CTRMAKEROM)),)
ifneq ($(findstring Linux,$(shell uname)),)
MAKEROM = pkg/ctr/tools/makerom-linux
else ifneq ($(findstring Darwin,$(shell uname)),)
MAKEROM = pkg/ctr/tools/makerom-mac
else
MAKEROM = pkg/ctr/tools/makerom.exe
endif
else
MAKEROM = $(CTRMAKEROM)
endif
%.o: %.vsh %.gsh
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.vsh
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
%.o: %.s
$(CC) -c -o $@ $< $(ASFLAGS)
%.o: %.S
$(CC) -c -o $@ $< $(ASFLAGS)
%.a:
$(AR) -rc $@ $^
%.vsh:
$(TARGET).smdh: $(APP_ICON)
$(DEVKITARM)/bin/smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
$(TARGET).3dsx: $(TARGET).elf
ifeq ($(APP_BIG_TEXT_SECTION), 1)
cp pkg/ctr/big_text_section.xml $(TARGET).xml
else
rm -f $(TARGET).xml
endif
$(DEVKITARM)/bin/3dsxtool $< $@ $(_3DSXFLAGS)
$(TARGET).elf: ctr/3dsx_custom_crt0.o
$(LD) $(LDFLAGS) $(OBJ) $(LIBDIRS) $(LIBS) -o $@
$(NM) -CSn $@ > $(notdir $*.lst)
$(TARGET).bnr: $(APP_BANNER) $(APP_AUDIO)
$(BANNERTOOL) makebanner -i "$(APP_BANNER)" -a "$(APP_AUDIO)" -o $@
$(TARGET).icn: $(APP_ICON)
$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i $(APP_ICON) -o $@
$(TARGET).3ds: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(MAKEROM) -f cci -o $@ $(MAKEROM_ARGS_COMMON) -DAPP_ENCRYPTED=true
$(TARGET).cia: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(MAKEROM) -f cia -o $@ $(MAKEROM_ARGS_COMMON) -DAPP_ENCRYPTED=false
clean:
rm -f $(OBJ)
rm -f $(TARGET).3dsx
rm -f $(TARGET).elf
rm -f $(TARGET).3ds
rm -f $(TARGET).cia
rm -f $(TARGET).smdh
rm -f $(TARGET).bnr
rm -f $(TARGET).icn
rm -f ctr/ctr_config_*.o
rm -f ctr/3dsx_custom_crt0.o
.PHONY: clean

View File

@ -1,221 +0,0 @@
TARGET := retroarch_3ds_salamander
LIBRETRO =
DEBUG = 0
BUILD_3DSX = 1
BUILD_3DS = 0
BUILD_CIA = 1
APP_TITLE = RetroArch 3DS
APP_DESCRIPTION = RetroArch 3DS
APP_AUTHOR = Team Libretro
APP_PRODUCT_CODE = RETROARCH-3DS
APP_UNIQUE_ID = 0xBAC00
APP_ICON = pkg/ctr/assets/default.png
APP_BANNER = pkg/ctr/assets/libretro_banner.png
APP_AUDIO = pkg/ctr/assets/silent.wav
APP_RSF = pkg/ctr/tools/template.rsf
APP_SYSTEM_MODE = 64MB
APP_SYSTEM_MODE_EXT = 124MB
OBJ := ctr/ctr_system.o \
ctr/ctr_memory.o \
ctr/ctr_linear.o \
frontend/frontend_salamander.o \
frontend/frontend_driver.o \
frontend/drivers/platform_ctr.o \
libretro-common/encodings/encoding_utf.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/compat/fopen_utf8.o \
libretro-common/file/file_path.o \
libretro-common/file/file_path_io.o \
libretro-common/string/stdstring.o \
libretro-common/lists/string_list.o \
libretro-common/lists/dir_list.o \
libretro-common/file/retro_dirent.o \
libretro-common/compat/compat_strl.o \
libretro-common/file/config_file.o \
libretro-common/streams/file_stream.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/hash/rhash.o \
file_path_str.o \
verbosity.o
OBJ += ctr/exec-3dsx/exec_cia.o \
ctr/exec-3dsx/exec_3dsx.o \
ctr/exec-3dsx/mini-hb-menu/launch.o \
ctr/exec-3dsx/mini-hb-menu/loaders/rosalina.o \
ctr/exec-3dsx/mini-hb-menu/loaders/hax2.o \
ctr/exec-3dsx/mini-hb-menu/loaders/ninjhax1.o
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitpro")
endif
ifeq ($(strip $(CTRULIB)),)
CTRULIB = $(DEVKITPRO)/libctru
endif
APP_TITLE := $(shell echo "$(APP_TITLE)" | cut -c1-128)
APP_DESCRIPTION := $(shell echo "$(APP_DESCRIPTION)" | cut -c1-256)
APP_AUTHOR := $(shell echo "$(APP_AUTHOR)" | cut -c1-128)
APP_PRODUCT_CODE := $(shell echo $(APP_PRODUCT_CODE) | cut -c1-16)
APP_UNIQUE_ID := $(shell echo $(APP_UNIQUE_ID) | cut -c1-7)
MAKEROM_ARGS_COMMON = -rsf $(APP_RSF) -exefslogo -elf $(TARGET).elf -icon $(TARGET).icn -banner $(TARGET).bnr -DAPP_TITLE="$(APP_TITLE)" -DAPP_PRODUCT_CODE="$(APP_PRODUCT_CODE)" -DAPP_UNIQUE_ID=$(APP_UNIQUE_ID) -DAPP_SYSTEM_MODE=$(APP_SYSTEM_MODE) -DAPP_SYSTEM_MODE_EXT=$(APP_SYSTEM_MODE_EXT)
INCDIRS := -I$(CTRULIB)/include
LIBDIRS := -L. -L$(CTRULIB)/lib
ARCH := -march=armv6k -mtune=mpcore -mfloat-abi=hard -marm -mfpu=vfp -mtp=soft
CFLAGS += -mword-relocations \
-fomit-frame-pointer -ffast-math \
-Werror=implicit-function-declaration \
$(ARCH)
#CFLAGS += -Wall
CFLAGS += -DARM11 -D_3DS
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
CFLAGS += -I. -Ideps/7zip -Ideps/stb -Ilibretro-common/include -Ilibretro-common/include/compat/zlib
#CFLAGS += -DRARCH_INTERNAL
CFLAGS += -DRARCH_CONSOLE -DIS_SALAMANDER
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH) -O3
LDFLAGS += -specs=ctr/3dsx_custom.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
CFLAGS += -std=gnu99 -ffast-math
LIBS := -lctru -lm
ifeq ($(BUILD_3DSX), 1)
TARGET_3DSX := $(TARGET).3dsx $(TARGET).smdh
endif
ifeq ($(BUILD_3DS), 1)
TARGET_3DS := $(TARGET).3ds
endif
ifeq ($(BUILD_CIA), 1)
TARGET_CIA := $(TARGET).cia
endif
.PHONY: $(BUILD) clean all
all: $(TARGET)
$(TARGET): $(TARGET_3DSX) $(TARGET_3DS) $(TARGET_CIA)
$(TARGET).3dsx: $(TARGET).elf
$(TARGET).elf: $(OBJ)
PREFIX := $(DEVKITARM)/bin/arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)
ifeq ($(strip $(CTRBANNERTOOL)),)
ifneq ($(findstring Linux,$(shell uname)),)
BANNERTOOL = pkg/ctr/tools/bannertool-linux
else ifneq ($(findstring Darwin,$(shell uname)),)
BANNERTOOL = pkg/ctr/tools/bannertool-mac
else
BANNERTOOL = pkg/ctr/tools/bannertool.exe
endif
else
BANNERTOOL = $(CTRBANNERTOOL)
endif
ifeq ($(strip $(CTRMAKEROM)),)
ifneq ($(findstring Linux,$(shell uname)),)
MAKEROM = pkg/ctr/tools/makerom-linux
else ifneq ($(findstring Darwin,$(shell uname)),)
MAKEROM = pkg/ctr/tools/makerom-mac
else
MAKEROM = pkg/ctr/tools/makerom.exe
endif
else
MAKEROM = $(CTRMAKEROM)
endif
%.o: %.vsh %.gsh
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.vsh
$(DEVKITARM)/bin/picasso $^ -o $*.shbin
$(DEVKITARM)/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS)
%.o: %.s
$(CC) -c -o $@ $< $(ASFLAGS)
%.o: %.S
$(CC) -c -o $@ $< $(ASFLAGS)
%.a:
$(AR) -rc $@ $^
%.vsh:
$(TARGET).smdh: $(APP_ICON)
$(DEVKITARM)/bin/smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
$(TARGET).3dsx: $(TARGET).elf
ifeq ($(APP_BIG_TEXT_SECTION), 1)
cp pkg/ctr/big_text_section.xml $(TARGET).xml
else
rm -f $(TARGET).xml
endif
$(DEVKITARM)/bin/3dsxtool $< $@ $(_3DSXFLAGS)
$(TARGET).elf: ctr/3dsx_custom_crt0.o
$(LD) $(LDFLAGS) $(OBJ) $(LIBDIRS) $(LIBS) -o $@
$(NM) -CSn $@ > $(notdir $*.lst)
$(TARGET).bnr: $(APP_BANNER) $(APP_AUDIO)
$(BANNERTOOL) makebanner -i "$(APP_BANNER)" -a "$(APP_AUDIO)" -o $@
$(TARGET).icn: $(APP_ICON)
$(BANNERTOOL) makesmdh -s "$(APP_TITLE)" -l "$(APP_TITLE)" -p "$(APP_AUTHOR)" -i $(APP_ICON) -o $@
$(TARGET).3ds: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(MAKEROM) -f cci -o $@ $(MAKEROM_ARGS_COMMON) -DAPP_ENCRYPTED=true
$(TARGET).cia: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(MAKEROM) -f cia -o $@ $(MAKEROM_ARGS_COMMON) -DAPP_ENCRYPTED=false
clean:
rm -f $(OBJ)
rm -f $(TARGET).3dsx
rm -f $(TARGET).elf
rm -f $(TARGET).3ds
rm -f $(TARGET).cia
rm -f $(TARGET).smdh
rm -f $(TARGET).bnr
rm -f $(TARGET).icn
rm -f ctr/ctr_config_*.o
rm -f ctr/3dsx_custom_crt0.o
.PHONY: clean

View File

@ -1,189 +0,0 @@
CC = /opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-gcc
CXX = /opt/gcw0-toolchain/usr/bin/mipsel-gcw0-linux-uclibc-g++
PACKAGE_NAME = retroarch
DEBUG ?= 0
HAVE_7ZIP = 1
HAVE_AL = 1
# this freezes when switching back from menu
HAVE_ALSA = 0
HAVE_BUILTINMBEDTLS = 1
HAVE_BUILTINZLIB = 1
HAVE_C99 = 1
HAVE_CC = 1
HAVE_CC_RESAMPLER = 1
HAVE_CHD = 1
HAVE_CHEEVOS = 1
HAVE_COMMAND = 1
HAVE_CXX = 1
HAVE_DR_MP3 = 1
HAVE_DYNAMIC = 1
HAVE_EGL = 1
HAVE_FREETYPE = 1
HAVE_GDI = 1
HAVE_GETADDRINFO = 1
HAVE_GETOPT_LONG = 1
HAVE_GLSL = 1
HAVE_HID = 1
HAVE_IBXM = 1
HAVE_IMAGEVIEWER = 1
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_MENU = 1
HAVE_MENU_COMMON = 1
HAVE_GFX_WIDGETS = 1
HAVE_MMAP = 1
HAVE_NETWORKING = 1
HAVE_OPENDINGUX_FBDEV = 1
HAVE_OPENGL = 1
HAVE_OPENGL1 = 0
HAVE_OPENGLES = 1
HAVE_OPENGLES3 = 0
HAVE_OPENGL_CORE = 0
HAVE_OPENSSL = 1
HAVE_OVERLAY = 1
HAVE_RBMP = 1
HAVE_RJPEG = 1
HAVE_RPILED = 1
HAVE_RPNG = 1
HAVE_RUNAHEAD = 1
HAVE_SDL_DINGUX = 1
HAVE_SHADERPIPELINE = 1
HAVE_STB_FONT = 1
HAVE_STB_IMAGE = 1
HAVE_STB_VORBIS = 1
HAVE_STDIN_CMD = 1
HAVE_STRCASESTR = 1
HAVE_THREADS = 1
HAVE_TRANSLATE = 1
HAVE_UDEV = 1
HAVE_VIDEO_LAYOUT = 1
HAVE_XMB = 1
HAVE_ZLIB = 1
HAVE_CONFIGFILE = 1
OS = Linux
TARGET = retroarch
OPK_NAME = retroarch.opk
OBJ :=
LINK := $(CXX)
DEF_FLAGS := -march=mips32 -mtune=mips32r2 -mhard-float -ffast-math -fomit-frame-pointer -fdata-sections
DEF_FLAGS += -I. -Ideps -Ideps/stb -DDINGUX=1 -MMD
DEF_FLAGS += -Wall -Wno-unused-variable
DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE
LIBS := -ldl -lz -lrt -lcrypto -lssl -ludev -pthread
CFLAGS :=
CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS
ASFLAGS :=
LDFLAGS := -flto
INCLUDE_DIRS = -I/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/include
LIBRARY_DIRS = -L/opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/lib
DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY
DEFINES += -DHAVE_C99=1 -DHAVE_CXX=1 -DHAVE_OPENDINGUX_FBDEV=1
DEFINES += -DHAVE_GETOPT_LONG=1 -DHAVE_STRCASESTR=1 -DHAVE_DYNAMIC=1
DEFINES += -DHAVE_AL=1
DEFINES += -DHAVE_ONLINE_UPDATER=1
DEFINES += -DHAVE_UPDATE_ASSETS=1
DEFINES += -DHAVE_UDEV=1
SDL_DINGUX_CFLAGS := $(shell /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/sdl-config --cflags)
SDL_DINGUX_LIBS := $(shell /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/sdl-config --libs)
FREETYPE_CFLAGS := $(shell /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/freetype-config --cflags)
FREETYPE_LIBS := $(shell /opt/gcw0-toolchain/usr/mipsel-gcw0-linux-uclibc/sysroot/usr/bin/freetype-config --libs)
AL_LIBS := -lopenal
OPENGLES_CFLAGS := -DMESA_EGL_NO_X11_HEADERS
OPENGLES_LIBS := -lGLESv2 -lEGL
MMAP_LIBS = -lc
OBJDIR_BASE := obj-unix
ifeq ($(DEBUG), 1)
OBJDIR := $(OBJDIR_BASE)/debug
DEF_FLAGS += -O0 -g -DDEBUG -D_DEBUG
else
OBJDIR := $(OBJDIR_BASE)/release
DEF_FLAGS += -O2 -DNDEBUG
endif
include Makefile.common
DEF_FLAGS += $(INCLUDE_DIRS)
CFLAGS += $(DEF_FLAGS)
CXXFLAGS += $(DEF_FLAGS)
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
Q := @
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
define DESKTOP_ENTRY
[Desktop Entry]
Name=retroarch
Comment=Retroarch
Exec=retroarch
Terminal=false
Type=Application
StartupNotify=true
Icon=retroarch
Categories=emulators;
X-OD-NeedsDownscaling=true
endef
export DESKTOP_ENTRY
all: $(TARGET) opk
-include $(RARCH_OBJ:.o=.d)
SYMBOL_MAP := -Wl,-Map=output.map
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(LINK) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LIBRARY_DIRS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo OBJC $<),)
$(CXX) $(OBJCFLAGS) $(DEFINES) -MMD -c -o $@ $<
.FORCE:
$(OBJDIR)/git_version.o: git_version.c .FORCE
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.S $(HEADERS)
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo AS $<),)
$(CC) $(CFLAGS) $(ASFLAGS) $(DEFINES) -c -o $@ $<
clean:
rm -rf $(OBJDIR_BASE)
rm -f $(TARGET)
rm -f *.d
rm -rf $(OPK_NAME)
opk: $(TARGET)
echo "$$DESKTOP_ENTRY" > default.gcw0.desktop
rm -f $(OPK_NAME)
cp media/ico_src/icon32.png retroarch.png
mksquashfs retroarch default.gcw0.desktop retroarch.png $(OPK_NAME) -all-root -no-xattrs -noappend -no-exports
rm -f default.gcw0.desktop retroarch.png
.PHONY: all clean opk
print-%:
@echo '$*=$($*)'

View File

@ -1,108 +0,0 @@
TARGET := retroarch.js
EOPT = USE_ZLIB=1 # Emscripten specific options
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
PTHREAD = 0
OS = Emscripten
OBJ :=
DEFINES := -DRARCH_INTERNAL -DHAVE_MAIN -s USE_PTHREADS=$(PTHREAD)
DEFINES += -DHAVE_FILTERS_BUILTIN
HAVE_OVERLAY = 1
HAVE_GLSL = 1
HAVE_AUDIOMIXER = 1
HAVE_VIDEO_LAYOUT = 0
HAVE_CC_RESAMPLER = 1
HAVE_EGL = 1
HAVE_OPENGLES = 1
HAVE_RJPEG = 0
HAVE_RPNG = 1
HAVE_EMSCRIPTEN = 1
HAVE_MENU = 1
HAVE_GFX_WIDGETS = 1
HAVE_RGUI = 1
HAVE_SDL = 0
HAVE_SDL2 = 0
HAVE_ZLIB = 1
HAVE_SHADERPIPELINE = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_STB_FONT = 1
HAVE_CONFIGFILE = 1
MEMORY = 134217728
PRECISE_F32 = 1
OBJDIR := obj-emscripten
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
LIBS := -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \
-s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
--js-library emscripten/library_rwebaudio.js \
--js-library emscripten/library_rwebcam.js \
--js-library emscripten/library_errno_codes.js
ifneq ($(PTHREAD), 0)
LDFLAGS += -s USE_PTHREADS=$(PTHREAD) -s PTHREAD_POOL_SIZE=2
endif
ifeq ($(ASYNC), 1)
LDFLAGS += -s ASYNCIFY=$(ASYNC)
endif
ifeq ($(HAVE_SDL2), 1)
LIBS += -s USE_SDL=2
DEFINES += -DHAVE_SDL2
endif
include Makefile.common
CFLAGS += $(DEF_FLAGS) -Ideps -Ideps/stb
libretro = libretro_emscripten.bc
ifneq ($(V), 1)
Q := @
endif
ifeq ($(DEBUG), 1)
LDFLAGS += -O0 -g
CFLAGS += -O0 -g
else
LDFLAGS += -O3 -s WASM=1
# WARNING: some optimizations can break some cores (ex: LTO breaks tyrquake)
LDFLAGS += -s PRECISE_F32=$(PRECISE_F32)
ifeq ($(LTO), 1)
LDFLAGS += --llvm-lto 3
endif
CFLAGS += -O3
endif
CFLAGS += -Wall -I. -Ilibretro-common/include -std=gnu99 $(LIBS) \
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
all: $(TARGET)
$(TARGET): $(RARCH_OBJ) $(libretro)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(LD) -o $@ $(RARCH_OBJ) $(libretro) $(LIBS) $(LDFLAGS)
$(OBJDIR)/%.o: %.c
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
$(OBJDIR)/%.o: %.cpp
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
.PHONY: all clean

File diff suppressed because it is too large Load Diff

View File

@ -1,262 +0,0 @@
include version.all
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>/devkitpro")
endif
TOPDIR ?= $(CURDIR)
include $(DEVKITPRO)/libnx/switch_rules
TARGET := retroarch_switch
DEBUG ?= 0
WHOLE_ARCHIVE_LINK = 0
GRIFFIN_BUILD = 0
OBJ :=
DEFINES := -D__SWITCH__=1 -U__linux__ -U__linux -DGLM_FORCE_PURE=1 -DRARCH_CONSOLE -DRARCH_INTERNAL -DGLOBAL_CONFIG_DIR='"/switch"' -DHAVE_STB_VORBIS
HAVE_DR_MP3 = 1
HAVE_TRANSLATE = 1
HAVE_AUDIOMIXER = 1
HAVE_CC_RESAMPLER = 1
HAVE_MENU_COMMON = 1
HAVE_RTGA = 1
HAVE_RPNG = 1
HAVE_RJPEG = 1
HAVE_RBMP = 1
HAVE_ZLIB = 1
HAVE_BUILTINZLIB = 1
HAVE_LIBRETRODB = 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_MENU = 1
HAVE_CONFIGFILE = 1
HAVE_RUNAHEAD = 1
HAVE_NETWORKING = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_STB_FONT = 1
HAVE_CHEEVOS = 1
HAVE_CHD = 0 # disabled due to static libretro-common and libchdr conflicts between different cores
HAVE_STB_VORBIS = 1
# RetroArch libnx useful flags
HAVE_THREADS = 1
HAVE_PTHREADS = 1
HAVE_FREETYPE = 0
HAVE_SWITCH = 1
HAVE_LIBNX = 1
HAVE_OPENGL = 1
HAVE_LANGEXTRA = 1
HAVE_GFX_WIDGETS = 1
ifeq ($(HAVE_OPENGL), 1)
HAVE_EGL = 1
HAVE_SHADERPIPELINE = 1
HAVE_RGUI = 1
HAVE_MATERIALUI = 1
HAVE_XMB = 1
HAVE_OZONE = 1
HAVE_OVERLAY = 1
HAVE_VIDEO_LAYOUT = 1
HAVE_GLSL = 1
else
HAVE_RGUI = 1
HAVE_MATERIALUI = 0
HAVE_XMB = 0
HAVE_OZONE = 0
HAVE_STRIPES = 0
endif
include Makefile.common
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
#---------------------------------------------------------------------------------
# TARGET is the name of the output
# BUILD is the directory where object files & intermediate files will be placed
# SOURCES is a list of directories containing source code
# DATA is a list of directories containing data files
# INCLUDES is a list of directories containing header files
# EXEFS_SRC is the optional input directory containing data copied into exefs, if anything this normally should only contain "main.npdm".
# ROMFS is the directory containing data to be added to RomFS, relative to the Makefile (Optional)
#
# NO_ICON: if set to anything, do not use icon.
# NO_NACP: if set to anything, no .nacp file is generated.
# APP_TITLE is the name of the app stored in the .nacp file (Optional)
# APP_AUTHOR is the author of the app stored in the .nacp file (Optional)
# APP_VERSION is the version of the app stored in the .nacp file (Optional)
# APP_TITLEID is the titleID of the app stored in the .nacp file (Optional)
# ICON is the filename of the icon (.jpg), relative to the project folder.
# If not set, it attempts to use one of the following (in this order):
# - <Project name>.jpg
# - icon.jpg
# - <libnx folder>/default_icon.jpg
#---------------------------------------------------------------------------------
BUILD := build
SOURCES := $(CURDIR)/source
DATA := data
INCLUDES := include
EXEFS_SRC := exefs_src
#ROMFS := switch/romfs
APP_TITLE := RetroArch
APP_VERSION := $(RARCH_VERSION)
APP_AUTHOR := libretro Team
APP_ICON := pkg/libnx/retroarch.jpg
#---------------------------------------------------------------------------------
# options for code generation
#---------------------------------------------------------------------------------
ARCH := -march=armv8-a -mtune=cortex-a57 -mtp=soft -fPIE -mcpu=cortex-a57+crc+fp+simd
CFLAGS := -g -Wall -O3 -ffast-math -ffunction-sections \
$(ARCH) $(DEFINES) $(INCLUDE_DIRS) -I$(LIBNX)/include -I$(PORTLIBS)/include/ -include $(LIBNX)/include/switch.h #$(shell $(PORTLIBS)/bin/freetype-config --cflags)
CFLAGS += $(INCLUDE) -DSWITCH=1 -DHAVE_LIBNX=1 -DNXLINK=1 -DHAVE_SHADERPIPELINE -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES -DHAVE_STB_FONT #-DHAVE_FREETYPE
ifeq ($(strip $(HAVE_STATIC_DUMMY)),1)
CFLAGS += -DHAVE_STATIC_DUMMY=1
endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions -std=gnu++11
ASFLAGS := -g $(ARCH)
LDFLAGS = -specs=$(DEVKITPRO)/libnx/switch.specs $(ARCH) -Wl,--allow-multiple-definition -Wl,-Map,$(notdir $*.map)
# add things from Makefile.common
CFLAGS += $(DEF_FLAGS)
LIBS := -lswresample -lavformat -lavcodec -lavutil -lswscale -lstdc++ -lbz2 -lpng -lz -lnx -lvpx -lopus -llzma -lm
ifeq ($(HAVE_OPENGL), 1)
LIBS := -lEGL -lglapi -ldrm_nouveau $(LIBS)
endif
#---------------------------------------------------------------------------------
# list of directories containing libraries, this must be the top level containing
# include and lib
#---------------------------------------------------------------------------------
LIBDIRS := $(PORTLIBS) $(LIBNX)
#---------------------------------------------------------------------------------
# no real need to edit anything past this point unless you need to add additional
# rules for different file extensions
#---------------------------------------------------------------------------------
ifneq ($(BUILD),$(notdir $(CURDIR)))
#---------------------------------------------------------------------------------
export OUTPUT := $(TARGET)
export TOPDIR := $(CURDIR)
export VPATH := $(foreach dir,$(SOURCES),$(CURDIR)/$(dir)) \
$(foreach dir,$(DATA),$(CURDIR)/$(dir))
export DEPSDIR := $(CURDIR)/
CFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.c)))
CPPFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.cpp)))
SFILES := $(foreach dir,$(SOURCES),$(notdir $(wildcard $(dir)/*.s)))
BINFILES := $(foreach dir,$(DATA),$(notdir $(wildcard $(dir)/*.*)))
#---------------------------------------------------------------------------------
# use CXX for linking C++ projects, CC for standard C
#---------------------------------------------------------------------------------
ifeq ($(strip $(CPPFILES)),)
#---------------------------------------------------------------------------------
export LD := $(CC)
#---------------------------------------------------------------------------------
else
#---------------------------------------------------------------------------------
export LD := $(CXX)
#---------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------
export OFILES := $(OBJ)
ifeq ($(strip $(HAVE_STATIC_DUMMY)),)
OFILES += libretro_libnx.a
endif
export HFILES_BIN := $(addsuffix .h,$(subst .,_,$(BINFILES)))
export INCLUDE := $(foreach dir,$(INCLUDES),-I$(CURDIR)/$(dir)) \
$(foreach dir,$(LIBDIRS),-I$(dir)/include) \
-I$(CURDIR)/$(BUILD)
export LIBPATHS := $(foreach dir,$(LIBDIRS),-L$(dir)/lib)
export BUILD_EXEFS_SRC := $(TOPDIR)/$(EXEFS_SRC)
ifeq ($(strip $(ICON)),)
icons := $(wildcard *.jpg)
ifneq (,$(findstring $(TARGET).jpg,$(icons)))
export APP_ICON := $(TOPDIR)/$(TARGET).jpg
else
ifneq (,$(findstring icon.jpg,$(icons)))
export APP_ICON := $(TOPDIR)/icon.jpg
endif
endif
else
export APP_ICON := $(TOPDIR)/$(ICON)
endif
ifeq ($(strip $(NO_ICON)),)
export NROFLAGS += --icon=$(APP_ICON)
endif
ifeq ($(strip $(NO_NACP)),)
export NROFLAGS += --nacp=$(CURDIR)/$(TARGET).nacp
endif
ifneq ($(APP_TITLEID),)
export NACPFLAGS += --titleid=$(APP_TITLEID)
endif
ifneq ($(ROMFS),)
export NROFLAGS += --romfsdir=$(CURDIR)/$(ROMFS)
endif
DEPENDS_TMP := $(OFILES:.o=.d)
DEPENDS := $(filter-out libretro_libnx.a,$(DEPENDS_TMP))
.PHONY: clean all
#---------------------------------------------------------------------------------
# main targets
#---------------------------------------------------------------------------------
all : $(OUTPUT).pfs0 $(OUTPUT).nro
$(OUTPUT).pfs0 : $(OUTPUT).nso
$(OUTPUT).nso : $(OUTPUT).elf
ifeq ($(strip $(NO_NACP)),)
$(OUTPUT).nro : $(OUTPUT).elf $(OUTPUT).nacp
else
$(OUTPUT).nro : $(OUTPUT).elf
endif
$(OUTPUT).elf : $(OBJ)
clean:
rm -f $(DEPENDS) $(OBJ) $(OUTPUT).pfs0 $(OUTPUT).nro $(OUTPUT).elf
#---------------------------------------------------------------------------------
# you need a rule like this for each extension you use as binary data
#---------------------------------------------------------------------------------
%.bin.o %_bin.h : %.bin
#---------------------------------------------------------------------------------
@echo $(notdir $<)
@$(bin2o)
#---------------------------------------------------------------------------------------
endif
#---------------------------------------------------------------------------------------

View File

@ -1,354 +0,0 @@
#---------------------------------------------------------------------------------
.SUFFIXES:
#---------------------------------------------------------------------------------
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPro")
endif
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
export PATH := $(DEVKITPPC)/bin:$(PATH)
ifeq ($(PLATFORM),)
PLATFORM=wii
endif
#---------------------------------------------------------------------------------
# change shell on Snow Leopard
#---------------------------------------------------------------------------------
UNAME_S := $(shell uname -s)
UNAME_R := $(shell uname -r)
ifneq (,$(findstring Darwin,$(UNAME_S)))
ifneq (,$(findstring 10.8.0,$(UNAME_R)))
export SHELL=/bin/bash
endif
endif
#---------------------------------------------------------------------------------
# path to tools
#---------------------------------------------------------------------------------
export PORTLIBS := $(DEVKITPRO)/portlibs/ppc
export PATH := $(DEVKITPPC)/bin:$(PORTLIBS)/bin:$(PATH)
#---------------------------------------------------------------------------------
# the prefix on the compiler executables
#---------------------------------------------------------------------------------
PREFIX := powerpc-eabi-
export AS := $(PREFIX)as
export CC := $(PREFIX)gcc
export CXX := $(PREFIX)g++
export AR := $(PREFIX)ar
export OBJCOPY := $(PREFIX)objcopy
ISVC=$(or $(VCBUILDHELPER_COMMAND),$(MSBUILDEXTENSIONSPATH32),$(MSBUILDEXTENSIONSPATH))
#---------------------------------------------------------------------------------
%.a:
#---------------------------------------------------------------------------------
@rm -f $@
$(AR) -rc $@ $^
#---------------------------------------------------------------------------------
%.o: %.cpp
$(CXX) $(CXXFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.c
$(CC) $(CFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.m
$(CC) $(OBJCFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.s
$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
%.o: %.S
$(CC) -x assembler-with-cpp $(ASFLAGS) -c $< -o $@
#---------------------------------------------------------------------------------
# canned command sequence for binary data
#---------------------------------------------------------------------------------
define bin2o
bin2s -a 32 $< | $(AS) -o $(@)
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(<F) | tr . _)`.h
echo "extern const u8" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(<F) | tr . _)`.h
echo "extern const u32" `(echo $(<F) | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(<F) | tr . _)`.h
endef
BUILD := build
BUILD_LITE = 1
CURDIR = .
export BASEDIR := $(CURDIR)
export DEPSDIR := $(BASEDIR)/wii/libogc/deps
export LWIPDIR := $(BASEDIR)/wii/libogc/lwip
export OGCDIR := $(BASEDIR)/wii/libogc/libogc
export DBDIR := $(BASEDIR)/wii/libogc/libdb
export BTEDIR := $(BASEDIR)/wii/libogc/lwbt
export WIIUSEDIR := $(BASEDIR)/wii/libogc/wiiuse
export LIBWIIKEYB := $(BASEDIR)/wii/libogc/libwiikeyboard
export STUBSDIR := $(BASEDIR)/wii/libogc/lockstubs
export LIBS := $(BASEDIR)/wii/libogc/libs
export INCDIR := $(BASEDIR)/wii/libogc/include
export LIBDIR := $(LIBS)/$(PLATFORM)
#---------------------------------------------------------------------------------
BBALIB := $(LIBDIR)/libbba
OGCLIB := $(LIBDIR)/libogc
DBLIB := $(LIBDIR)/libdb
BTELIB := $(LIBDIR)/libbte
WIIUSELIB := $(LIBDIR)/libwiiuse
WIIKEYBLIB := $(LIBDIR)/libwiikeyboard
STUBSLIB := $(LIBDIR)/libgclibstubs
#---------------------------------------------------------------------------------
DEFAULTINCDIR := $(BASEDIR)/wii/libogc/include
DEFINCS := -I$(DEFAULTINCDIR)
INCLUDES := $(DEFINCS) \
-I$(BASEDIR)/wii/libogc \
-I$(DEFAULTINCDIR)/netif \
-I$(DEFAULTINCDIR)/ipv4 \
-I$(DEFAULTINCDIR)/sdcard \
-I$(DEFAULTINCDIR)/ogc \
-I$(DEFAULTINCDIR)/ogc/machine \
-I$(DEFAULTINCDIR)/bte \
-I$(DEFAULTINCDIR)/sdcard \
-I$(DEFAULTINCDIR)/wiikeyboard \
-I$(DEFAULTINCDIR)/wiiuse \
-I$(DEFAULTINCDIR)/di
MACHDEP := -DBIGENDIAN -DGEKKO -mcpu=750 -meabi -msdata=eabi -mhard-float -ffunction-sections -fdata-sections
ifeq ($(PLATFORM),wii)
MACHDEP += -DHW_RVL
endif
ifeq ($(PLATFORM),cube)
MACHDEP += -DHW_DOL
endif
CFLAGS := -DLIBOGC_INTERNAL -DNDEBUG -O2 -fno-strict-aliasing -mregnames -Wall $(MACHDEP) $(INCLUDES)
ASFLAGS := $(MACHDEP) -mregnames -D_LANGUAGE_ASSEMBLY $(INCLUDES)
#---------------------------------------------------------------------------------
VPATH := $(LWIPDIR) \
$(LWIPDIR)/arch/gc \
$(LWIPDIR)/arch/gc/netif \
$(LWIPDIR)/core \
$(LWIPDIR)/core/ipv4 \
$(LWIPDIR)/netif \
$(OGCDIR) \
$(DBDIR) \
$(DBDIR)/uIP \
$(BTEDIR) \
$(WIIUSEDIR) \
$(SDCARDDIR) \
$(LIBWIIKEYB) \
$(STUBSDIR)
#---------------------------------------------------------------------------------
SOURCES_LWIP := $(LWIPDIR)/network.c \
$(LWIPDIR)/netio.c \
$(LWIPDIR)/arch/gc/netif/gcif.c \
$(LWIPDIR)/core/inet.c \
$(LWIPDIR)/core/mem.c \
$(LWIPDIR)/core/dhcp.c \
$(LWIPDIR)/core/raw.c \
$(LWIPDIR)/core/memp.c \
$(LWIPDIR)/core/netif.c \
$(LWIPDIR)/core/pbuf.c \
$(LWIPDIR)/core/stats.c \
$(LWIPDIR)/core/sys.c \
$(LWIPDIR)/core/tcp.c \
$(LWIPDIR)/core/tcp_in.c \
$(LWIPDIR)/core/tcp_out.c \
$(LWIPDIR)/core/udp.c \
$(LWIPDIR)/core/ipv4/icmp.c \
$(LWIPDIR)/core/ipv4/ip.c \
$(LWIPDIR)/core/ipv4/ip_frag.c \
$(LWIPDIR)/core/ipv4/ip_addr.c \
$(LWIPDIR)/netif/etharp.c \
$(LWIPDIR)/netif/loopif.c
LWIPOBJ := $(SOURCES_LWIP:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_OGC := \
$(OGCDIR)/console.c \
$(OGCDIR)/lwp_priority.c \
$(OGCDIR)/lwp_queue.c \
$(OGCDIR)/lwp_threadq.c \
$(OGCDIR)/lwp_threads.c \
$(OGCDIR)/lwp_sema.c \
$(OGCDIR)/lwp_messages.c \
$(OGCDIR)/lwp.c \
$(OGCDIR)/lwp_stack.c \
$(OGCDIR)/lwp_mutex.c \
$(OGCDIR)/lwp_watchdog.c \
$(OGCDIR)/lwp_wkspace.c \
$(OGCDIR)/lwp_objmgr.c \
$(OGCDIR)/lwp_heap.c \
$(OGCDIR)/sys_state.c \
$(OGCDIR)/exception.c \
$(OGCDIR)/irq.c \
$(OGCDIR)/semaphore.c \
$(OGCDIR)/video.c \
$(OGCDIR)/pad.c \
$(OGCDIR)/exi.c \
$(OGCDIR)/mutex.c \
$(OGCDIR)/arqueue.c \
$(OGCDIR)/arqmgr.c \
$(OGCDIR)/system.c \
$(OGCDIR)/cond.c \
$(OGCDIR)/gx.c \
$(OGCDIR)/gu.c \
$(OGCDIR)/audio.c \
$(OGCDIR)/cache.c \
$(OGCDIR)/decrementer.c \
$(OGCDIR)/message.c \
$(OGCDIR)/card.c \
$(OGCDIR)/aram.c \
$(OGCDIR)/depackrnc1.c \
$(OGCDIR)/dsp.c \
$(OGCDIR)/si.c \
$(OGCDIR)/tpl.c \
$(OGCDIR)/ipc.c \
$(OGCDIR)/console_font_8x16.c \
$(OGCDIR)/timesupp.c \
$(OGCDIR)/lock_supp.c \
$(OGCDIR)/newlibc.c \
$(OGCDIR)/usbgecko.c \
$(OGCDIR)/usbmouse.c \
$(OGCDIR)/sbrk.c \
$(OGCDIR)/malloc_lock.c \
$(OGCDIR)/kprintf.c \
$(OGCDIR)/stm.c \
$(OGCDIR)/ios.c \
$(OGCDIR)/es.c \
$(OGCDIR)/isfs.c \
$(OGCDIR)/usb.c \
$(OGCDIR)/network_common.c \
$(OGCDIR)/sdgecko_io.c \
$(OGCDIR)/sdgecko_buf.c \
$(OGCDIR)/gcsd.c \
$(OGCDIR)/argv.c \
$(OGCDIR)/network_wii.c \
$(OGCDIR)/wiisd.c \
$(OGCDIR)/conf.c \
$(OGCDIR)/usbstorage.c \
$(OGCDIR)/texconv.c \
$(OGCDIR)/wiilaunch.c
SOURCES_OGC_ASM := $(OGCDIR)/cache_asm.S \
$(OGCDIR)/decrementer_handler.S \
$(OGCDIR)/depackrnc.S \
$(OGCDIR)/exception_handler.S \
$(OGCDIR)/gu_psasm.S \
$(OGCDIR)/irq_handler.S \
$(OGCDIR)/lwp_handler.S \
$(OGCDIR)/ogc_crt0.S \
$(OGCDIR)/system_asm.S \
$(OGCDIR)/video_asm.S
ifneq ($(BUILD_LITE), 1)
SOURCES_OGC += $(OGCDIR)/dvd.c
endif
OGCOBJ := $(SOURCES_OGC:.c=.o) $(SOURCES_OGC_ASM:.S=.o)
#---------------------------------------------------------------------------------
SOURCES_DB := \
$(DBDIR)/uIP/uip_ip.c \
$(DBDIR)/uIP/uip_tcp.c \
$(DBDIR)/uIP/uip_pbuf.c \
$(DBDIR)/uIP/uip_netif.c \
$(DBDIR)/uIP/uip_arp.c \
$(DBDIR)/uIP/uip_arch.c \
$(DBDIR)/uIP/uip_icmp.c \
$(DBDIR)/uIP/memb.c \
$(DBDIR)/uIP/memr.c \
$(DBDIR)/uIP/bba.c \
$(DBDIR)/tcpip.c \
$(DBDIR)/debug.c \
$(DBDIR)/debug_handler.c \
$(DBDIR)/debug_supp.c \
$(DBDIR)/geckousb.c
DBOBJ := $(SOURCES_DB:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_BTE := \
$(BTEDIR)/bte.c \
$(BTEDIR)/hci.c \
$(BTEDIR)/l2cap.c \
$(BTEDIR)/btmemb.c \
$(BTEDIR)/btmemr.c \
$(BTEDIR)/btpbuf.c \
$(BTEDIR)/physbusif.c
BTEOBJ := $(SOURCES_BTE:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_WIIUSE := \
$(WIIUSEDIR)/classic.c \
$(WIIUSEDIR)/dynamics.c \
$(WIIUSEDIR)/events.c \
$(WIIUSEDIR)/io.c \
$(WIIUSEDIR)/io_wii.c \
$(WIIUSEDIR)/ir.c \
$(WIIUSEDIR)/nunchuk.c \
$(WIIUSEDIR)/wiiuse.c \
$(WIIUSEDIR)/speaker.c \
$(WIIUSEDIR)/wpad.c \
$(WIIUSEDIR)/motion_plus.c
WIIUSEOBJ := $(SOURCES_WIIUSE:.c=.o)
#---------------------------------------------------------------------------------
SOURCES_WIIKEYB = $(LIBWIIKEYB)/usbkeyboard.c \
$(LIBWIIKEYB)/keyboard.c \
$(LIBWIIKEYB)/ukbdmap.c \
$(LIBWIIKEYB)/wskbdutil.c
WIIKEYBLIBOBJ := $(SOURCES_WIIKEYB:.c=.o)
LIBRARIES := $(OGCLIB).a $(DBLIB).a
ifeq ($(PLATFORM),cube)
LIBRARIES += $(BBALIB).a
endif
ifeq ($(PLATFORM),wii)
LIBRARIES += $(BTELIB).a $(WIIUSELIB).a $(WIIKEYBLIB).a
endif
all: $(LIBRARIES)
#---------------------------------------------------------------------------------
$(BBALIB).a: $(LWIPOBJ)
#---------------------------------------------------------------------------------
$(OGCLIB).a: $(OGCOBJ)
#---------------------------------------------------------------------------------
$(DBLIB).a: $(DBOBJ)
#---------------------------------------------------------------------------------
$(WIIKEYBLIB).a: $(WIIKEYBLIBOBJ)
#---------------------------------------------------------------------------------
$(BTELIB).a: $(BTEOBJ)
#---------------------------------------------------------------------------------
$(WIIUSELIB).a: $(WIIUSEOBJ)
#---------------------------------------------------------------------------------
#---------------------------------------------------------------------------------
clean:
#---------------------------------------------------------------------------------
rm -fr $(LWIPOBJ) $(OGCOBJ) $(DBOBJ) $(BTEOBJ) $(WIIUSEOBJ) $(WIIKEYBLIBOBJ)
rm -f *.map

View File

@ -1,282 +0,0 @@
TARGET := retroarch.exe
DEBUG = 0
GRIFFIN_BUILD = 0
OS = Win32
ARCH = amd64
#TARGET_ARCH = x86
BUILD_DIR = objs/msvc
CXX_BUILD = 0
WindowsSdkDir = C:\Program Files (x86)\Windows Kits\10\$(NOTHING)
WindowsSDKVersion := 10.0.14393.0\$(NOTHING)
VCINSTALLDIR := C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\$(NOTHING)
HAVE_AUDIOMIXER := 1
HAVE_D3DX := 1
HAVE_D3D8 := 0
HAVE_D3D9 := 1
HAVE_D3D10 := 1
HAVE_D3D11 := 1
HAVE_D3D12 := 1
HAVE_CG := 1
HAVE_OPENGL := 1
HAVE_OPENGL1 := 1
HAVE_GFX_WIDGETS := 1
HAVE_VULKAN := 1
HAVE_XAUDIO := 1
HAVE_XINPUT := 1
HAVE_WASAPI := 0
HAVE_THREAD_STORAGE := 1
HAVE_WINMM := 1
HAVE_RPNG := 1
HAVE_ZLIB := 1
HAVE_CONFIGFILE := 1
HAVE_MENU := 1
HAVE_RGUI := 1
HAVE_XMB := 1
HAVE_MATERIALUI := 1
HAVE_STB_FONT := 1
HAVE_THREADS := 1
HAVE_LIBRETRODB := 1
HAVE_COMMAND := 1
HAVE_STDIN_CMD := 1
HAVE_CMD := 1
HAVE_DYLIB := 1
HAVE_DYNAMIC := 1
HAVE_DINPUT := 1
HAVE_MENU_COMMON := 1
HAVE_BUILTINZLIB := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_7ZIP := 1
HAVE_NETWORKING := 1
HAVE_NETWORK_CMD := 1
HAVE_OVERLAY := 1
HAVE_VIDEO_LAYOUT := 0
HAVE_LANGEXTRA := 1
HAVE_CHEEVOS := 1
HAVE_SHADERPIPELINE := 1
HAVE_IMAGEVIEWER := 1
ifeq ($(HAVE_D3D8), 1)
D3D8_LIBS := -ld3d8
ifeq ($(HAVE_D3DX), 1)
D3DX8_LIBS := -ld3dx8
endif
endif
ifeq ($(HAVE_D3D9), 1)
D3D9_LIBS := -ld3d9
ifeq ($(HAVE_D3DX), 1)
D3DX9_LIBS := -ld3dx9
endif
endif
include Makefile.common
INCLUDE_DIRS := $(patsubst -isystem%,-I%,$(INCLUDE_DIRS))
CFLAGS := $(filter-out -Wno-unknown-pragmas,$(DEF_FLAGS))
CXXFLAGS := $(filter-out -fpermissive -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -Wno-parentheses,$(CXXFLAGS))
LIBS := $(filter-out -lstdc++,$(LIBS))
ifeq ($(ARCH),x64)
ARCH := amd64
endif
ARCH2 := $(ARCH)
ifeq ($(ARCH),amd64)
ARCH2 := x64
endif
ifeq ($(TARGET_ARCH),)
TARGET_ARCH = $(ARCH)
endif
ifeq ($(TARGET_ARCH),x64)
TARGET_ARCH = amd64
endif
TARGET_ARCH2 = $(TARGET_ARCH)
ifeq ($(TARGET_ARCH2),amd64)
TARGET_ARCH2 = x64
endif
CROSS = $(ARCH)
ifeq ($(ARCH),x86)
CROSS =
endif
INCLUDE := $(VCINSTALLDIR)include;$(VCINSTALLDIR)atlmfc\include;$(WindowsSdkDir)include\$(WindowsSDKVersion)ucrt;$(WindowsSdkDir)include\$(WindowsSDKVersion)shared;$(WindowsSdkDir)include\$(WindowsSDKVersion)um;
LIB := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS);$(WindowsSdkDir)lib\$(WindowsSDKVersion)ucrt\$(TARGET_ARCH2);$(WindowsSdkDir)lib\$(WindowsSDKVersion)um\$(TARGET_ARCH2);C:\Program Files (x86)\NVIDIA Corporation\Cg\lib.$(TARGET_ARCH2);C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Lib\$(TARGET_ARCH2);
LIBPATH := $(VCINSTALLDIR)LIB\$(CROSS);$(VCINSTALLDIR)atlmfc\lib\$(CROSS);
PATH := $(shell IFS=$$'\n'; cygpath "$(VCINSTALLDIR)bin\\$(CROSS)"):$(shell IFS=$$'\n'; cygpath "$(WindowsSdkDir)\bin\\$(ARCH2)"):$(PATH)
export INCLUDE := $(INCLUDE)
export LIB := $(LIB)
export LIBPATH := $(LIBPATH)
export PATH := $(PATH)
#$(info WindowsSdkDir : $(WindowsSdkDir))
#$(info WindowsSDKVersion : $(WindowsSDKVersion))
#$(info VCINSTALLDIR : $(VCINSTALLDIR))
#$(info INCLUDE : $(INCLUDE))
#$(info LIB : $(LIB))
#$(info LIBPATH : $(LIBPATH))
#$(info PATH : $(PATH))
#$(error end)
DEFINES += -D__SSE__ -D__SSE2__
ifeq ($(TARGET_ARCH2),x64)
DEFINES += -D__x86_64__
else
#DEFINES += -D__i686__
endif
FLAGS += -nologo -MP
FLAGS += -Gm- -Zc:inline -fp:precise -Zc:forScope -GR- -Gd -Oi -volatile:iso
#FLAGS += -Zc:wchar_t -Zp16 -Z7
FLAGS += -utf-8
#FLAGS += -source-charset:utf-8
CXXFLAGS += $(CFLAGS) -TP -EHsc
ifeq ($(CXX_BUILD),1)
CFLAGS := $(CXXFLAGS)
DEFINES += -DCXX_BUILD
else
CFLAGS += -TC
endif
WARNINGS += -WX -W3
WARNINGS += -wd4101 -wd4996 -wd4244 -wd4267 -wd4090 -wd4305 -wd4146 -wd4334 -wd4018 -wd4800 -wd4838
CC = cl.exe
CXX = cl.exe
LD = link.exe
RC = rc.exe
LIBS += shell32.lib user32.lib gdi32.lib comdlg32.lib winmm.lib ole32.lib
LDFLAGS += -nologo -wx -nxcompat -machine:$(TARGET_ARCH2)
ifeq ($(DEBUG),1)
FLAGS += -GS -Gy -Od -RTC1 -D_SECURE_SCL=1 -Zi
FLAGS += -MDd
LDFLAGS += -DEBUG
DEFINES += -DDEBUG -D_DEBUG
else
FLAGS += -GS- -Gy- -O2 -Ob2 -GF -GT -Oy -Ot -D_SECURE_SCL=0
FLAGS += -MD
endif
ifeq ($(DEBUG),1)
BUILD_DIR := $(BUILD_DIR)-debug
endif
ifeq ($(GRIFFIN_BUILD),1)
BUILD_DIR := $(BUILD_DIR)-griffin
endif
BUILD_DIR := $(BUILD_DIR)-$(TARGET_ARCH2)
ifneq ($(V), 1)
Q := @
endif
ifeq ($(GRIFFIN_BUILD), 1)
OBJ := griffin/griffin.o griffin/griffin_cpp.o
DEFINES += -DHAVE_GRIFFIN -DUSE_MATH_DEFINES
else
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
endif
DEFINES += -DRARCH_INTERNAL -DHAVE_DYNAMIC -DJSON_STATIC
INCLUDE_DIRS += -I. -Igfx/include
#OBJ := version_git.o
OBJ := $(patsubst %rarch.o,%rarch.res,$(OBJ))
OBJ := $(addprefix $(BUILD_DIR)/,$(OBJ))
OBJ := $(OBJ:.o=.obj)
LDFLAGS += -WX -SUBSYSTEM:WINDOWS -ENTRY:mainCRTStartup
DEFINES := $(patsubst -f%,,$(DEFINES))
LDFLAGS := $(patsubst -l%,%.lib,$(LDFLAGS))
LIBS := $(filter-out -lm,$(LIBS))
LIBS := $(patsubst -l%,%.lib,$(LIBS))
#$(info INCLUDE_DIRS : $(INCLUDE_DIRS))
#$(info DEFINES : $(DEFINES))
#$(info CFLAGS : $(CFLAGS))
#$(info CXXFLAGS : $(CXXFLAGS))
#$(info LDFLAGS : $(LDFLAGS))
#$(info LIBS : $(LIBS))
#$(info OBJ : $(OBJ))
#$(info target : $(TARGET))
#$(info flags : $(FLAGS))
#$(info INCLUDE : $(INCLUDE))
#$(info LIB : $(LIB))
#$(info LIBPATH : $(LIBPATH))
#$(error end)
$(info os : $(OS))
$(info host : $(ARCH))
$(info target : $(TARGET_ARCH))
all: $(TARGET)
%: $(BUILD_DIR)/%
cp $< $@
ifeq ($(DEBUG),1)
%.exe: $(BUILD_DIR)/%.exe
cp $< $@
cp $(BUILD_DIR)/$*.pdb $*.pbd
endif
SHELL:=$(SHELL) -o pipefail
DEPFLAGS = -showIncludes | tee $(BUILD_DIR)/$*.dtemp | sed /'Note: including file:'/d
MAKEDEPS = echo $@: $< \\ > $(BUILD_DIR)/$*.depend && \
grep 'Note: including file:' $(BUILD_DIR)/$*.dtemp \
| sed '/$(subst \,\\,$(WindowsSdkDir))/Id; /$(subst \,\\,$(VCINSTALLDIR))/Id; s/Note: including file:[ ]*//g; s/\\/\//g; s/ /\\ /g; s/.*/ & \\/g' \
>> $(BUILD_DIR)/$*.depend && \
rm -f $(BUILD_DIR)/$*.dtemp
#DEPFLAGS :=
#MAKEDEPS :=
$(BUILD_DIR)/%.obj: %.cpp
@mkdir -p $(dir $@)
$(Q)$(CXX) -c -Fo:$@ $< $(FLAGS) $(CXXFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS)
@$(MAKEDEPS)
$(BUILD_DIR)/%.obj: %.c
@mkdir -p $(dir $@)
$(Q)$(CC) -c -Fo:$@ $< $(FLAGS) $(CFLAGS) $(DEFINES) $(INCLUDE_DIRS) $(WARNINGS) $(DEPFLAGS)
@$(MAKEDEPS)
$(BUILD_DIR)/%.res: %.rc
@mkdir -p $(dir $@)
$(Q)$(RC) $<
$(Q)mv $*.res $@
$(BUILD_DIR)/$(TARGET): $(OBJ) .$(TARGET).last
@touch .$(TARGET).last
$(Q)$(LD) $(OBJ) $(LDFLAGS) $(LIBS) -out:$(BUILD_DIR)/$(TARGET)
%.h %.hpp %.depend %.last: ;
clean:
rm -f $(OBJ) $(TARGET)
rm -f $(BUILD_DIR)/$(TARGET)
rm -f .$(TARGET).last
rm -f $(OBJ:.obj=.depend)
.PHONY: clean all
.PRECIOUS: %.depend %.last
-include $(patsubst %.obj,%.depend,$(filter %.obj,$(OBJ)))

View File

@ -1,46 +0,0 @@
include version.all
DEBUG = 0
CC = $(PNDSDK)/bin/arm-none-linux-gnueabi-gcc
LD = $(PNDSDK)/bin/arm-none-linux-gnueabi-gcc -o
TARGET := retroarch-pandora
LDDIRS = -L. -L$(PNDSDK)/usr/lib
INCDIRS = -I. -I$(PNDSDK)/usr/include
OBJ = griffin/griffin.o audio/resamplers/sinc_resampler_neon.o libretro-common/conversion/s16_to_float_neon.o libretro-common/conversion/float_to_s16_neon.o
LDFLAGS = -L$(PNDSDK)/usr/lib -Wl,-rpath,$(PNDSDK)/usr/lib
LIBS = -lGLESv2 -lEGL -ldl -lm -lpthread -lrt -lasound
DEFINES = -std=gnu99 -DHAVE_THREADS -DHAVE_GETOPT_LONG=1 -DHAVE_GRIFFIN -DRARCH_INTERNAL
DEFINES += -DHAVE_CONFIGFILE -D__ARM_ARCH_6__ -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_OVERLAY -DHAVE_VIDEO_LAYOUT -DHAVE_ALSA -DHAVE_ZLIB -D__linux__
DEFINES += $(INCDIRS)
DEFINES += -D__OPENPANDORA__ -DPANDORA
DEFINES += -marm -march=armv7-a -mcpu=cortex-a8 -mtune=cortex-a8 -mfpu=neon -mfloat-abi=softfp -ftree-vectorize
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
else
OPTIMIZE_LV := -O3
endif
all: $(TARGET)
CFLAGS := $(OPTIMIZE_LV) $(DEFINES)
$(TARGET): $(OBJ)
$(CC) -o $@ $(OBJ) $(LDFLAGS) $(LDDIRS) $(LIBS)
%.o: %.S
$(CC) $(CFLAGS) -c -o $@ $<
%.o: %.c config.h
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -f $(TARGET)
rm -f $(OBJ)
.PHONY: clean

View File

@ -1,165 +0,0 @@
TARGET := retroarch_orbis
DEBUG ?= 0
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
PS4_TITLE_ID := RETROARCH
PS4_TITLE_NAME := RetroArch
PC_DEVELOPMENT_IP_ADDRESS =
PC_DEVELOPMENT_UDP_PORT =
OBJ :=
DEFINES :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1
DEFINES += -DHAVE_MENU -DHAVE_LIBRETRODB -DHAVE_CONFIGFILE
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_CC_RESAMPLER
ifeq ($(DEBUG), 1)
DEFINES += -DHAVE_NETLOGGER
endif
else
HAVE_FILTERS_BUILTIN := 1
HAVE_LANGEXTRA := 0
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_ZLIB := 1
HAVE_OVERLAY := 1
HAVE_VIDEO_LAYOUT := 0
HAVE_7ZIP := 1
HAVE_EGL := 1
HAVE_GFX_WIDGETS := 1
HAVE_GLSL := 1
HAVE_OPENGLES := 1
HAVE_NETWORKING := 0
HAVE_SOCKET_LEGACY := 0
HAVE_MENU := 1
HAVE_MENU_COMMON := 1
HAVE_CONFIGFILE := 1
HAVE_RGUI := 0
HAVE_MATERIALUI := 0
HAVE_XMB := 1
HAVE_THREADS := 1
HAVE_LIBRETRODB := 1
HAVE_CC_RESAMPLER := 1
HAVE_CHEEVOS := 1
RARCH_CONSOLE := 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
ifeq ($(DEBUG), 1)
HAVE_NETLOGGER = 1
endif
include Makefile.common
CFLAGS += $(DEF_FLAGS)
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
endif
ifeq ($(strip $(PS4SDK)),)
$(error "Please set PS4SDK in your environment. export PS4SDK=<path to>ps4sdk")
endif
export PATH := $(PATH):$(PS4SDK)/bin
PREFIX :=
CC := $(PREFIX)clang
CXX := $(PREFIX)clang
AS := $(PREFIX)clang
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)
INCDIRS := -I. -Ideps/7zip -Ilibretro-common/include -Ideps/stb -Ilibretro-common/include/compat/zlib
LIBDIRS := -L.
ARCHFLAGS := -m64 -DORBIS
CFLAGS += $(ARCHFLAGS) -std=c11 -mcmodel=large -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-stack-protector
ifeq ($(DEBUG), 1)
CFLAGS += -O2 -g
else
CFLAGS += -O3
endif
ASFLAGS := $(ARCHFLAGS) -I$(PS4SDK)/include -target x86_64-scei-ps4-elf -fPIE
LDFLAGS := -O3 -Wall -m64 -nostartfiles -nostdlib -L$(PS4SDK)/lib -pie
ARFLAGS := rcs
CRTFILE ?= $(PS4SDK)/crt0.s
CFLAGS += -Wall -pedantic -Wno-zero-length-array -Wno-format-pedantic
CFLAGS += -D__PS4__ -I$(PS4SDK)/include -I $(PS4SDK)/include/sce
CFLAGS += -target x86_64-scei-ps4-elf -fPIE
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),)
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS='"$(PC_DEVELOPMENT_IP_ADDRESS)"'
endif
ifneq ($(PC_DEVELOPMENT_UDP_PORT),)
CFLAGS += -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
CXXFLAGS := $(CFLAGS)
PS4_LIBS := -lps4link -ldebugnet -lorbisFile -lelfloader -lorbisKeyboard -lorbis2d -lpng -lz -lorbisGl -lorbisPad -lorbisAudio -lmod -lorbisFileBrowser -lorbisXbmFont -lSceNet_stub -lScePigletv2VSH_stub -lSceSystemService_stub -lSceUserService_stub -lScePad_stub -lSceAudioOut_stub -lSceIme_stub -lSceSysmodule_stub \
-lPs4_extension_kernel_call_standard -lPs4_extension_kernel_execute_dynlib_prepare_dlclose -lPs4_common_kernel -lPs4_common_user -lPs4_common_generic -lPs4LibCInternalAdaptive_stub -lPs4LibKernelAdaptive_stub -lSceLibcInternal_stub -lkernel_stub -lps4Kernel_stub -lPs4_base_stub_resolve_minimal -lPs4_base_kernel_dlsym_standard -lPs4_base_kernel_seek_elf_address_standard -lPs4_base_assembler_register_parameter_standard -lPs4_base_assembler_system_call_standard
LIBS := $(WHOLE_START) -lretro_orbis $(WHOLE_END) $(PS4_LIBS)
TARGETS := $(TARGET).elf
DEPFLAGS = -MT $@ -MMD -MP -MF $*.Tdepend
POSTCOMPILE = mv -f $*.Tdepend $*.depend
all: $(TARGETS)
%.o: %.cpp
%.o: %.cpp %.depend
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.c
%.o: %.c %.depend
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.S
%.o: %.S %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.s
%.o: %.s %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.depend: ;
$(TARGET).elf: $(OBJ) libretro_orbis.a
$(LD) $(CRTFILE) $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
clean:
rm -f $(OBJ) $(TARGET).elf
rm -f $(OBJ:.o=.depend)
.PHONY: clean all
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend)

View File

@ -1,54 +0,0 @@
# Before using this Makefile, be sure to do:
# $ source /usr/local/angstrom/arm/environment-setup
# $ setprj retroarch
PNDDIR=./pkg/pandora
BINDIR=$(PNDDIR)/bin
all: $(BINDIR)/retroarch
mkdir -p $(PNDDIR)/lib
@echo "Put libretro-*.so files in $(PNDDIR)/lib/ before making pnd!"
pnd: retroarch.pnd
install: all $(BINDIR)/retroarch-joyconfig $(BINDIR)/retroarch-zip $(PNDDIR)/readme.html
retroarch:
./configure --prefix=$PND_BASEDIR/$PRJ --disable-ffmpeg --disable-cg --disable-python --disable-libpng --disable-pulse --disable-jack --enable-gles --enable-xml
make -f Makefile
$(BINDIR)/retroarch: retroarch
mkdir -p $(BINDIR)
cp retroarch $(BINDIR)/retroarch
$(BINDIR)/retroarch-joyconfig: tools/retroarch-joyconfig
mkdir -p $(BINDIR)
cp tools/retroarch-joyconfig $(BINDIR)/retroarch-joyconfig
$(BINDIR)/retroarch-zip: retroarch-zip
mkdir -p $(BINDIR)
cp retroarch-zip $(BINDIR)/retroarch-zip
$(PNDDIR)/readme.html: README.md
markdown README.md > $(PNDDIR)/readme.html
retroarch.pnd: install
pnd_make -c -p retroarch.pnd -d $(PNDDIR)/ -x $(PNDDIR)/PXML.xml -i $(PNDDIR)/icon.png
clean:
rm -f *.o
rm -f audio/*.o
rm -f conf/*.o
rm -f gfx/*.o
rm -f gfx/drivers_font/*.o
rm -f gfx/drivers_font_renderer/*.o
rm -f gfx/drivers_context/*.o
rm -f gfx/py_state/*.o
rm -f compat/*.o
rm -f record/*.o
rm -f input/*.o
rm -f tools/*.o
rm -f $(BINDIR)/retroarch
rm -f $(BINDIR)/retroarch-joyconfig
rm -f $(PNDDIR)/readme.html
rm -f retroarch

View File

@ -1,116 +0,0 @@
BUILD_FOR_PCSX2 = 0
DEBUG = 0
HAVE_KERNEL_PRX = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
HAVE_THREADS = 0
BIG_STACK = 0
MUTE_WARNINGS = 1
PS2_IP = 192.168.1.150
TARGET = retroarchps2.elf
TARGET_RELEASE = retroarchps2-release.elf
# Compile the IRXs first
IRX_DIR = ps2/irx
IRX_FILES = $(wildcard ps2/irx/*.c)
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
RARCH_DEFINES += -DDEBUG
else
OPTIMIZE_LV := -O2
LDFLAGS := -s
endif
ifeq ($(MUTE_WARNINGS), 1)
DISABLE_WARNINGS := -Wno-sign-compare -Wno-unused -Wno-parentheses
endif
INCDIR = -I$(PS2DEV)/gsKit/include -I$(PS2SDK)/ports/include
INCDIR += -Ips2 -Ips2/include -Ilibretro-common/include -Ideps -Ideps/stb -Ideps/7zip
INCDIR += -Ideps/pthreads -Ideps/pthreads/platform/ps2 -Ideps/pthreads/platform/helper
GPVAL = -G0
CFLAGS = $(OPTIMIZE_LV) $(DISABLE_WARNINGS) -ffast-math -fsingle-precision-constant
ASFLAGS = $(CFLAGS)
RARCH_DEFINES += -DPS2 -DUSE_IOP_CTYPE_MACRO -D_MIPS_ARCH_R5900 -DHAVE_ZLIB -DHAVE_NO_BUILTINZLIB -DHAVE_RPNG -DHAVE_RJPEG
RARCH_DEFINES += -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
LIBDIR =
LDFLAGS += -L$(PS2SDK)/ports/lib -L$(PS2DEV)/gsKit/lib -L$(PS2SDK)/ee/lib -L.
LIBS += -lretro_ps2 -lgskit -ldmakit -lgskit_toolkit -laudsrv -lpadx -lmtap -lmc -lhdd -lsdl -lfileXio -lz
LIBS += -lpatches -lpoweroff
ifeq ($(BUILD_FOR_PCSX2), 1)
RARCH_DEFINES += -DBUILD_FOR_PCSX2
endif
ifeq ($(HAVE_THREADS), 1)
RARCH_DEFINES += -DHAVE_THREADS
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
ifeq ($(HAVE_KERNEL_PRX), 1)
CFLAGS += -DHAVE_KERNEL_PRX
endif
ifeq ($(BIG_STACK), 1)
CFLAGS += -DBIG_STACK
endif
CFLAGS += $(RARCH_DEFINES)
# All the IRX objects
EE_OBJS += $(IRX_DIR)/freemtap_irx.o $(IRX_DIR)/freepad_irx.o $(IRX_DIR)/freesio2_irx.o $(IRX_DIR)/iomanX_irx.o
EE_OBJS += $(IRX_DIR)/fileXio_irx.o $(IRX_DIR)/mcman_irx.o $(IRX_DIR)/mcserv_irx.o $(IRX_DIR)/usbd_irx.o
EE_OBJS += $(IRX_DIR)/usbhdfsd_irx.o $(IRX_DIR)/freesd_irx.o $(IRX_DIR)/audsrv_irx.o $(IRX_DIR)/poweroff_irx.o
# Missing objecst on the PS2SDK
EE_OBJS += ps2/compat_files/ps2_devices.o
EE_OBJS += griffin/griffin.o
EE_CFLAGS = $(CFLAGS)
EE_CXXFLAGS = $(CFLAGS)
EE_LDFLAGS = $(LDFLAGS)
EE_LIBS = $(LIBS)
EE_ASFLAGS = $(ASFLAGS)
EE_INCS = $(INCDIR)
EE_BIN = $(TARGET)
EE_GPVAL = $(GPVAL)
all: irxdir $(EE_BIN)
irxdir:
$(MAKE) -C $(IRX_DIR)
clean:
rm -f $(EE_BIN) $(EE_OBJS)
$(MAKE) -C $(IRX_DIR) clean
prepare:
ps2client -h $(PS2_IP) reset
ps2client -h $(PS2_IP) netdump
run:
ps2client -h $(PS2_IP) execee host:$(EE_BIN)
sim:
PCSX2 --elf=$(PWD)/$(EE_BIN) --nogui
debug: clean all run
package:
ps2-packer $(EE_BIN) $(TARGET_RELEASE)
release: clean all package
#Include preferences
include $(PS2SDK)/samples/Makefile.pref
include $(PS2SDK)/samples/Makefile.eeglobal_cpp

View File

@ -1,207 +0,0 @@
include version.all
#which compiler to build with - GCC or SNC
#set to GCC for debug builds for use with debugger
CELL_BUILD_TOOLS = SNC
CELL_GPU_TYPE = RSX
CELL_PSGL_VERSION = opt
ASSETS_DIR := media/assets
# options
DOWNLOAD_SHADERS = 1
STRIPPING_ENABLE = 0
DEBUG = 0
HAVE_GCMGL = 0
HAVE_LOGGER = 0
HAVE_FREETYPE = 0
WHOLE_ARCHIVE_LINK = 0
CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001
CONTENT_ID = SSNE10000
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
PC_DEVELOPMENT_UDP_PORT = 3490
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
include $(CELL_MK_DIR)/sdk.makedef.mk
PPU_TARGET = retroarch_ps3.elf
SALAMANDER_TARGET = retroarch-salamander_ps3.elf
EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN
CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF
LDDIRS = -L. -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt
INCDIRS = -I. \
-Idefines \
-Ideps \
-Ideps/stb \
-Ideps/rcheevos/include \
-Ilibretro-common/include \
-Ilibretro-common/include/compat/zlib
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc
MAKE_SELF = make_self_npdrm
PYTHON2 = python2
GIT = git
else
PKG_FINALIZE = package_finalize.exe
MAKE_SELF_WC = make_self_wc.exe
MAKE_SELF = make_self_npdrm.exe
PYTHON2 = python2.exe
GIT = git.exe
endif
PPU_SRCS = griffin/griffin.c
DEFINES += -DHAVE_VIDEO_LAYOUT
DEFINES += -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_GFX_WIDGETS -DHAVE_RGUI -DHAVE_XMB -DHAVE_OZONE -DHAVE_LIBRETRODB -DHAVE_MATERIALUI -DHAVE_SHADERPIPELINE -DRARCH_INTERNAL -DHAVE_OVERLAY -DHAVE_CC_RESAMPLER -DHAVE_STB_VORBIS -DHAVE_STB_FONT -DHAVE_RUNAHEAD -DHAVE_DR_MP3 -DHAVE_DR_FLAC
DEFINES += -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS -DHAVE_UPDATE_CORES
ifeq ($(DEX_BUILD), 1)
DEFINES += -DDEX_BUILD
endif
ifeq ($(CEX_BUILD), 1)
DEFINES += -DCEX_BUILD
endif
ifeq ($(ODE_BUILD), 1)
DEFINES += -DODE_BUILD
endif
ifeq ($(HAVE_GCMGL), 1)
DEFINES += -DHAVE_GCMGL
GL_LIBS := -L. -lrgl_ps3
else
GL_LIBS := -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt -lPSGL -lPSGLcgc
endif
ifeq ($(HAVE_FREETYPE), 1)
DEFINES += -DHAVE_FREETYPE
FONT_LIBS := -lfontFT_stub -lfreetype_stub
endif
ifeq ($(CELL_BUILD_TOOLS), SNC)
PPU_CXXLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
PPU_CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
PPU_CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
else ifneq ($(system_platform), win)
PPU_CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
PPU_CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
PPU_CXXLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
PPU_CCLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl, --whole-archive
WHOLE_END := -Wl, --no-whole-archive
endif
PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -lcgc -lgcm_cmdasm -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread
PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_LANGEXTRA -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_7Z -D__CELLOS_LV2__ -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -DHAVE_FILTERS_BUILTIN -DHAVE_CHEEVOS -DRC_DISABLE_LUA
#DEFINES += -DHAVE_IMAGEVIEWER
ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g
else
PPU_OPTIMIZE_LV := -O2 -g
endif
ifeq ($(HAVE_LOGGER), 1)
DEFINES += -DHAVE_LOGGER
endif
PPU_CFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
PPU_CXXFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
EXIST_EBOOT_WILDCARD := $(wildcard $(EBOOT_PATH))
EXIST_CORE_WILDCARD := $(wildcard $(CORE_PATH))
EBOOT_EXISTS = 1
CORE_EXISTS = 1
ifneq ($(strip $(EXIST_EBOOT_WILDCARD)),)
EBOOT_EXISTS = 0
endif
ifneq ($(strip $(EXIST_CORE_WILDCARD)),)
CORE_EXISTS = 0
endif
include $(CELL_MK_DIR)/sdk.target.mk
MAKE_FSELF = $(CELL_SDK)/host-win32/bin/make_fself.exe
MAKE_FSELF_NPDRM = $(CELL_SDK)/host-win32/bin/make_fself_npdrm.exe
MAKE_PACKAGE_NPDRM = $(CELL_SDK)/host-win32/bin/make_package_npdrm.exe
.PHONY: create-npdrm-core create-core create-npdrm-salamander create-shaders clean-selfs create-salamander
create-npdrm-core:
$(MAKE_FSELF_NPDRM) $(PPU_TARGET) $(CORE_PATH)
create-core:
$(MAKE_SELF_WC) $(PPU_TARGET) $(CORE_PATH)
create-npdrm-salamander:
$(MAKE_FSELF_NPDRM) $(SALAMANDER_TARGET) $(EBOOT_PATH)
create-salamander:
$(MAKE_SELF) $(SALAMANDER_TARGET) $(EBOOT_PATH) $(CONTENT_ID_FULL)
copy-media-files:
@cp -r $(ASSETS_DIR)/glui pkg/ps3/USRDIR/cores/assets
@cp -r $(ASSETS_DIR)/xmb pkg/ps3/USRDIR/cores/assets
create-shaders:
make -f Makefile.griffin platform=ps3 shaders-deploy
pkg: $(PPU_TARGET) create-shaders copy-media-files create-npdrm-salamander create-npdrm-core
$(MAKE_PACKAGE_NPDRM) pkg/ps3/package.conf pkg/ps3
pkg-signed: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
pkg-signed-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core
$(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID)
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
pkg-signed-cfw: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
$(PKG_FINALIZE) retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
pkg-signed-cfw-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core
$(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID)
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
$(PKG_FINALIZE) retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
clean-selfs:
ifeq ($(EBOOT_EXISTS),1)
@echo "WARNING: Couldn't find file to delete: [$(EBOOT_PATH)], skipping this step."
else
rm $(EBOOT_PATH)
endif
ifeq ($(CORE_EXISTS),1)
@echo "WARNING: Couldn't find file to delete: [$(CORE_PATH)], skipping this step."
else
rm $(CORE_PATH)
endif

View File

@ -1,196 +0,0 @@
include version.all
#which compiler to build with - GCC or SNC
#set to GCC for debug builds for use with debugger
CELL_BUILD_TOOLS = GCC
CELL_GPU_TYPE = RSX
CELL_PSGL_VERSION = ultra-opt
# options
DOWNLOAD_SHADERS = 1
STRIPPING_ENABLE = 0
DEBUG = 0
HAVE_GCMGL = 1
HAVE_LOGGER = 0
HAVE_FREETYPE = 0
WHOLE_ARCHIVE_LINK = 0
CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001
CONTENT_ID = SSNE10000
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
PC_DEVELOPMENT_UDP_PORT = 3490
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
include $(CELL_MK_DIR)/sdk.makedef.mk
PPU_TARGET = retroarch_ps3.elf
SALAMANDER_TARGET = retroarch-salamander_ps3.elf
EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN
CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF
LDDIRS = -L. -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt
INCDIRS = -I. -Idefines -Ideps -Ideps/stb
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
PKG_FINALIZE = package_finalize
MAKE_SELF_WC = make_self_wc
MAKE_SELF = make_self_npdrm
PYTHON2 = python2
GIT = git
else
PKG_FINALIZE = package_finalize.exe
MAKE_SELF_WC = make_self_wc.exe
MAKE_SELF = make_self_npdrm.exe
PYTHON2 = python2.exe
GIT = git.exe
endif
PPU_SRCS = griffin/griffin.c
DEFINES += -DHAVE_RGUI -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_MENU -DRARCH_INTERNAL
ifeq ($(DEX_BUILD), 1)
DEFINES += -DDEX_BUILD
endif
ifeq ($(CEX_BUILD), 1)
DEFINES += -DCEX_BUILD
endif
ifeq ($(ODE_BUILD), 1)
DEFINES += -DODE_BUILD
endif
ifeq ($(HAVE_GCMGL), 1)
DEFINES += -DHAVE_GCMGL
GL_LIBS := -L. -lrgl_ps3
else
GL_LIBS := -L$(CELL_SDK)/target/ppu/lib/PSGL/RSX/ultra-opt -lPSGL -lPSGLcgc
endif
ifeq ($(HAVE_FREETYPE), 1)
DEFINES += -DHAVE_FREETYPE
FONT_LIBS := -lfontFT_stub -lfreetype_stub
endif
ifeq ($(CELL_BUILD_TOOLS), SNC)
PPU_CXXLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
PPU_CXX = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
PPU_CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
else ifneq($(system_platform), win)
PPU_CXX = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-g++.exe
PPU_CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
PPU_CXXLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
PPU_CCLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl, --whole-archive
WHOLE_END := -Wl, --no-whole-archive
endif
PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -lcgc -lgcm_cmdasm -lgcm_sys_stub -lresc_stub -lm -lio_stub -lfs_stub -lsysutil_stub -lsysutil_game_stub -lsysutil_screenshot_stub -lsysutil_np_stub -lpngdec_stub -ljpgdec_stub -lsysmodule_stub -laudio_stub -lnet_stub -lnetctl_stub -lpthread
PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe
#DEFINES += -DHAVE_VIDEO_LAYOUT
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -D__CELLOS_LV2__ -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DHAVE_MOUSE -DHAVE_GRIFFIN=1 -DHAVE_MULTIMAN=0 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -DHAVE_STB_VORBIS
ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g
else
PPU_OPTIMIZE_LV := -O3 -g
endif
ifeq ($(HAVE_LOGGER), 1)
DEFINES += -DHAVE_LOGGER
endif
PPU_CFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
PPU_CXXFLAGS := $(PPU_OPTIMIZE_LV) $(INCDIRS) $(DEFINES)
EXIST_EBOOT_WILDCARD := $(wildcard $(EBOOT_PATH))
EXIST_CORE_WILDCARD := $(wildcard $(CORE_PATH))
EBOOT_EXISTS = 1
CORE_EXISTS = 1
ifneq ($(strip $(EXIST_EBOOT_WILDCARD)),)
EBOOT_EXISTS = 0
endif
ifneq ($(strip $(EXIST_CORE_WILDCARD)),)
CORE_EXISTS = 0
endif
include $(CELL_MK_DIR)/sdk.target.mk
MAKE_FSELF = $(CELL_SDK)/host-win32/bin/make_fself.exe
MAKE_FSELF_NPDRM = $(CELL_SDK)/host-win32/bin/make_fself_npdrm.exe
MAKE_PACKAGE_NPDRM = $(CELL_SDK)/host-win32/bin/make_package_npdrm.exe
.PHONY: create-npdrm-core create-core create-npdrm-salamander create-shaders clean-selfs create-salamander
create-npdrm-core:
$(MAKE_FSELF_NPDRM) $(PPU_TARGET) $(CORE_PATH)
create-core:
$(MAKE_SELF_WC) $(PPU_TARGET) $(CORE_PATH)
create-npdrm-salamander:
$(MAKE_FSELF_NPDRM) $(SALAMANDER_TARGET) $(EBOOT_PATH)
create-salamander:
$(MAKE_SELF) $(SALAMANDER_TARGET) $(EBOOT_PATH) $(CONTENT_ID_FULL)
copy-media-files:
@cp -r $(ASSETS_DIR)/glui pkg/ps3/USRDIR/cores/assets
@cp -r $(ASSETS_DIR)/xmb pkg/ps3/USRDIR/cores/assets
create-shaders:
make -f Makefile.shaders deploy-ps3
pkg: $(PPU_TARGET) create-shaders copy-media-files create-npdrm-salamander create-npdrm-core
$(MAKE_PACKAGE_NPDRM) pkg/ps3/package.conf pkg/ps3
pkg-signed: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
pkg-signed-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core
$(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID)
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
pkg-signed-cfw: $(PPU_TARGET) create-shaders copy-media-files create-salamander create-core
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
$(PKG_FINALIZE) retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
pkg-signed-cfw-standalone: $(PPU_TARGET) create-shaders copy-media-files create-core
$(MAKE_SELF) $(PPU_TARGET) $(EBOOT_PATH) $(CONTENT_ID)
$(PYTHON2) $(PKG_SCRIPT) --contentid $(CONTENT_ID_FULL) pkg/ps3 retroarch-ps3-cfw-$(PACKAGE_VERSION).pkg
$(PKG_FINALIZE) retroarch-ps3-cfw-$(PACKAGE_VERSION)-kmeaw.pkg
clean-selfs:
ifeq ($(EBOOT_EXISTS),1)
@echo "WARNING: Couldn't find file to delete: [$(EBOOT_PATH)], skipping this step."
else
rm $(EBOOT_PATH)
endif
ifeq ($(CORE_EXISTS),1)
@echo "WARNING: Couldn't find file to delete: [$(CORE_PATH)], skipping this step."
else
rm $(CORE_PATH)
endif

View File

@ -1,91 +0,0 @@
CELL_BUILD_TOOLS = GCC
CELL_SDK ?= /usr/local/cell
HAVE_LOGGER = 0
CELL_MK_DIR ?= $(CELL_SDK)/samples/mk
include $(CELL_MK_DIR)/sdk.makedef.mk
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g
else
PPU_OPTIMIZE_LV := -O2 -DNDEBUG
endif
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
INCFLAGS = -I. -Idefines -Ilibretro-common/include -Ilibretro-common/include/compat/zlib
DEFINES = -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
ifeq ($(DEX_BUILD), 1)
DEFINES += -DDEX_BUILD
endif
ifeq ($(CEX_BUILD), 1)
DEFINES += -DCEX_BUILD
endif
ifeq ($(ODE_BUILD), 1)
DEFINES += -DODE_BUILD
endif
PPU_CFLAGS := $(PPU_OPTIMIZE_LV) $(INCFLAGS) $(DEFINES)
PPU_CXXFLAGS := $(PPU_OPTIMIZE_LV) $(INCFLAGS) $(DEFINES)
PPU_SRCS = frontend/frontend_salamander.c \
frontend/frontend_driver.c \
frontend/drivers/platform_ps3.c \
libretro-common/file/file_path.c \
libretro-common/file/file_path_io.c \
libretro-common/lists/dir_list.c \
libretro-common/lists/string_list.c \
libretro-common/file/retro_dirent.c \
libretro-common/hash/rhash.c \
libretro-common/string/stdstring.c \
libretro-common/encodings/encoding_utf.c \
libretro-common/compat/compat_strl.c \
libretro-common/compat/compat_strcasestr.c \
libretro-common/compat/fopen_utf8.c \
libretro-common/streams/file_stream.c \
libretro-common/vfs/vfs_implementation.c \
libretro-common/file/config_file.c \
file_path_str.c \
verbosity.c
ifeq ($(HAVE_LOGGER), 1)
PPU_CFLAGS += -DHAVE_LOGGER
PPU_SRCS += network/net_logger.c \
libretro-common/net/net_compat.c \
libretro-common/net/net_socket.c
endif
PPU_TARGET = retroarch-salamander_ps3.elf
ifeq ($(CELL_BUILD_TOOLS),SNC)
PPU_CFLAGS += -Xbranchless=1 -Xfastmath=1 -Xassumecorrectsign=1 -Xassumecorrectalignment=1 -Xunroll=1 -Xautovecreg=1
PPU_CXXFLAGS += -Xbranchless=1 -Xfastmath=1 -Xassumecorrectsign=1 -Xassumecorrectalignment=1 -Xunroll=1 -Xautovecreg=1
PPU_CXXLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
PPU_CLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
PPU_CC = $(CELL_SDK)/host-win32/sn/bin/ps3ppusnc.exe
else
PPU_CFLAGS += -std=gnu99
PPU_CC = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-gcc.exe
PPU_CLD = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ld.exe
PPU_CXXLD = $(CELL_SDK)/host-win32/sn/bin/ps3ppuld.exe
endif
PPU_LDLIBS += -lm -lnet_stub -lnetctl_stub -lio_stub -lsysmodule_stub -lsysutil_stub -lsysutil_game_stub -lfs_stub -lsysutil_np_stub
MAKE_FSELF = $(CELL_SDK)/host-win32/bin/make_fself.exe
include $(CELL_MK_DIR)/sdk.target.mk

View File

@ -1,97 +0,0 @@
#-------------------------------------------------------------------------------
# Clear the implicit built in rules
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
ifeq ($(strip $(PSL1GHT)),)
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
endif
include $(PSL1GHT)/ppu_rules
include version.all
DEBUG = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 1
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
PC_DEVELOPMENT_UDP_PORT = 3490
CONTENTID = UP0001-SSNE10001_00-0000000000000001
APPID = SSNE10001
TITLE = Retroarch PSL1GHT
PACKAGE_BASENAME := retroarch_psl1ght
ELF_TARGET := retroarch_psl1ght.elf
SELF_TARGET := $(ELF_TARGET:.elf=.self)
CORE_PATH = pkg/psl1ght/pkg/USRDIR/cores/CORE.SELF
INCLUDE += -I. -Ips3/gcmgl/include/export -Ips3/include -Ideps -Ideps/stb -Ilibretro-common/include/compat/zlib -Ilibretro-common/include $(LIBPSL1GHT_INC) -Iinclude
LIBDIRS += -L.
MACHDEP := -D__CELLOS_LV2__ -D__PSL1GHT__ -mcpu=cell
CFLAGS += -Wall $(MACHDEP) $(INCLUDE)
LDFLAGS := $(MACHDEP)
LIBS := -lretro_psl1ght -laudio -lrsx -lgcm_sys -lnet -lio -lsysutil -lsysmodule -lm -ljpgdec -lpngdec -llv2 -lnet -lnetctl
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
GIT = git
else
GIT = git.exe
endif
OBJ = griffin/griffin.o
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
SHARED_FLAGS :=
SHARED_FLAGS += -DHAVE_VIDEO_LAYOUT
SHARED_FLAGS += -DHAVE_MENU -DHAVE_CONFIGFILE -DRARCH_CONSOLE -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_GCMGL -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_GRIFFIN=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts -DHAVE_CC_RESAMPLER -DRARCH_INTERNAL -DHAVE_MULTIMAN -DHAVE_RGUI
CFLAGS += -std=gnu99 $(SHARED_FLAGS)
CXXFLAGS += $(SHARED_FLAGS)
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3 -g
CXXFLAGS += -03 -g
endif
all: $(SELF_TARGET)
$(ELF_TARGET): $(OBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
create-core: $(SELF_TARGET)
cp $(SELF_TARGET) $(CORE_PATH)
pkg: create-core
$(PKG) --contentid $(CONTENTID) pkg/psl1ght/pkg/ $(PACKAGE_BASENAME).pkg
# cp $(PACKAGE_BASENAME).pkg $(PACKAGE_BASENAME).gnpdrm.pkg
# $(PACKAGE_FINALIZE) $(PACKAGE_BASENAME).gnpdrm.pkg
clean:
rm -f $(ELF_TARGET)
rm -f $(OBJ)
.PHONY: clean

View File

@ -1,119 +0,0 @@
#-------------------------------------------------------------------------------
# Clear the implicit built in rules
#-------------------------------------------------------------------------------
.SUFFIXES:
#-------------------------------------------------------------------------------
ifeq ($(strip $(PSL1GHT)),)
$(error "Please set PSL1GHT in your environment. export PSL1GHT=<path>")
endif
include $(PSL1GHT)/ppu_rules
include version.all
DEBUG = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 1
PC_DEVELOPMENT_IP_ADDRESS = "192.168.1.7"
PC_DEVELOPMENT_UDP_PORT = 3490
CONTENTID = UP0001-SSNE10001_00-0000000000000001
APPID = SSNE10001
TITLE = Retroarch PSL1GHT
PACKAGE_BASENAME := retroarch_psl1ght
ELF_TARGET := retroarch_psl1ght_salamander.elf
ELF_TARGET_NONSTRIPPED := retroarch_psl1ght_salamander_nonstripped.elf
EBOOT_PATH = pkg/psl1ght/pkg/USRDIR/EBOOT.BIN
INCLUDE += -I. -Ips3/gcmgl/include/export -Ips3/include -Ideps -Ideps/stb -Ilibretro-common/include/compat/zlib -Ilibretro-common/include $(LIBPSL1GHT_INC) -Iinclude
LIBDIRS += -L.
MACHDEP := -D__CELLOS_LV2__ -D__PSL1GHT__ -mcpu=cell -mhard-float -fmodulo-sched -ffunction-sections -fdata-sections
CFLAGS += -Wall $(MACHDEP) $(INCLUDE)
LDFLAGS := $(MACHDEP)
LIBS := -lgcm_sys -lrsx -lsysutil -lio -lnet -lsysmodule -lrt -llv2 -lm
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PKG_SCRIPT = tools/ps3/ps3py/pkg.py
ifeq ($(shell uname), Linux)
GIT = git
else
GIT = git.exe
endif
OBJ = frontend/frontend_salamander.o \
frontend/frontend_driver.o \
frontend/drivers/platform_ps3.o \
libretro-common/file/file_path.o \
libretro-common/file/file_path_io.o \
libretro-common/lists/dir_list.o \
libretro-common/lists/string_list.o \
libretro-common/file/retro_dirent.o \
libretro-common/hash/rhash.o \
libretro-common/string/stdstring.o \
libretro-common/encodings/encoding_utf.o \
libretro-common/compat/compat_strl.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/compat/fopen_utf8.o \
libretro-common/streams/file_stream.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/file/config_file.o \
file_path_str.o \
verbosity.o
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
SHARED_FLAGS :=
SHARED_FLAGS += -DHAVE_VIDEO_LAYOUT
SHARED_FLAGS += -DHAVE_MENU -DHAVE_CONFIGFILE -DRARCH_CONSOLE -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_GCMGL -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_GRIFFIN=1 -DHAVE_NETWORKING=1 -DHAVE_SOCKET_LEGACY=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts -DHAVE_CC_RESAMPLER -DHAVE_MULTIMAN -DHAVE_RGUI -DIS_SALAMANDER
CFLAGS += -std=gnu99 $(SHARED_FLAGS)
CXXFLAGS += $(SHARED_FLAGS)
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3 -g
CXXFLAGS += -03 -g
endif
all: create-salamander
$(ELF_TARGET_NONSTRIPPED): $(OBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
$(ELF_TARGET): $(ELF_TARGET_NONSTRIPPED)
$(STRIP) $< -o $@
$(SPRX) $@
create-salamander: $(ELF_TARGET)
$(SELF_NPDRM) $(ELF_TARGET) $(EBOOT_PATH) $(CONTENTID)
pkg: create-salamander
$(PKG) --contentid $(CONTENTID) pkg/psl1ght/pkg/ $(PACKAGE_BASENAME).pkg
# cp $(PACKAGE_BASENAME).pkg $(PACKAGE_BASENAME).gnpdrm.pkg
# $(PACKAGE_FINALIZE) $(PACKAGE_BASENAME).gnpdrm.pkg
clean:
rm -f $(ELF_TARGET)
rm -f $(OBJ)
.PHONY: clean

View File

@ -1,75 +0,0 @@
BUILD_PRX = 0
PSP_LARGE_MEMORY = 1
DEBUG = 0
HAVE_KERNEL_PRX = 1
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
HAVE_THREADS = 1
BIG_STACK = 0
WHOLE_ARCHIVE_LINK = 0
TARGET = retroarchpsp
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
else
OPTIMIZE_LV := -O3
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
INCDIR = deps deps/stb deps/7zip deps/pthreads deps/pthreads/platform/psp deps/pthreads/platform/helper libretro-common/include libretro-common/include/compat/zlib
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math -fsingle-precision-constant
ASFLAGS = $(CFLAGS)
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX -DHAVE_LANGEXTRA -DHAVE_ZLIB -DHAVE_AUDIOMIXER -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
LIBDIR =
LDFLAGS =
LIBS = $(WHOLE_START) -lretro_psp1 $(WHOLE_END) -lstdc++ -lpspgu -lpspgum -lm -lpspaudio -lpspfpu -lpsppower -lpsprtc
ifeq ($(HAVE_THREADS), 1)
RARCH_DEFINES += -DHAVE_THREADS
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
ifeq ($(HAVE_KERNEL_PRX), 1)
CFLAGS += -DHAVE_KERNEL_PRX
endif
ifeq ($(BIG_STACK), 1)
CFLAGS += -DBIG_STACK
endif
CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch PSP1
PSP_OBJECTS = griffin/griffin.o bootstrap/psp1/kernel_functions.o
OBJS = $(PSP_OBJECTS)
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak
pspsh-debug:
pspsh -e reset
read -p "Start debugger in VSCode and press any key to continue... \n" -n1 -s
pspsh -e debug ./retroarchpsp.prx
pspsh
pspsh-run:
pspsh -e reset
pspsh -e ./retroarchpsp.prx
pspsh
debug: clean all pspsh-debug
run: clean all pspsh-run

View File

@ -1,57 +0,0 @@
BUILD_PRX = 0
PSP_LARGE_MEMORY = 1
HAVE_FILE_LOGGER = 0
DEBUG = 0
TARGET = retroarchpsp_salamander
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
else
OPTIMIZE_LV := -O2
endif
INCDIR = $(PSPPATH)/include libretro-common/include
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
ASFLAGS = $(CFLAGS)
RARCH_DEFINES = -DPSP -DIS_SALAMANDER -DRARCH_CONSOLE
LIBDIR =
LDFLAGS =
LIBS = -lstdc++ -lm -lpsppower
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
CFLAGS += $(RARCH_DEFINES)
EXTRA_TARGETS = EBOOT.PBP
PSP_EBOOT_TITLE = RetroArch
PSP_EBOOT_ICON = pkg/psp1/ICON0.PNG
PSP_EBOOT_PIC1 = pkg/psp1/PIC1.PNG
OBJS = frontend/frontend_salamander.o \
frontend/frontend_driver.o \
frontend/drivers/platform_psp.o \
libretro-common/file/file_path.o \
libretro-common/file/file_path_io.o \
libretro-common/string/stdstring.o \
libretro-common/lists/string_list.o \
libretro-common/lists/dir_list.o \
libretro-common/file/retro_dirent.o \
libretro-common/encodings/encoding_utf.o \
libretro-common/compat/fopen_utf8.o \
libretro-common/compat/compat_strl.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/file/config_file.o \
libretro-common/streams/file_stream.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/hash/rhash.o \
file_path_str.o \
verbosity.o \
bootstrap/psp1/kernel_functions.o
PSPSDK=$(shell psp-config --pspsdk-path)
include $(PSPSDK)/lib/build.mak

View File

@ -1,73 +0,0 @@
TARGET := retroarch_switch
DEBUG ?= 0
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
OBJ :=
DEFINES := -DSWITCH=1 -U__linux__ -U__linux -DRARCH_INTERNAL -DHAVE_DYNAMIC
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_NEON -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA
DEFINES += -DHAVE_RUNAHEAD -DHAVE_DYNAMIC
DEFINES += -DHAVE_CONFIGFILE
else
HAVE_AUDIOMIXER = 1
HAVE_CC_RESAMPLER = 1
HAVE_MENU_COMMON = 1
HAVE_RTGA = 1
HAVE_RPNG = 1
HAVE_RJPEG = 1
HAVE_RBMP = 1
HAVE_RGUI = 1
HAVE_ZLIB = 1
HAVE_BUILTINZLIB = 1
HAVE_LIBRETRODB = 1
HAVE_MATERIALUI = 0 # enable later?
HAVE_XMB = 0
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_MENU = 1
HAVE_CONFIGFILE = 1
HAVE_RUNAHEAD = 1
HAVE_DYNAMIC = 1
include Makefile.common
CFLAGS += $(DEF_FLAGS)
BLACKLIST :=
BLACKLIST += input/input_overlay.o
BLACKLIST += tasks/task_overlay.o
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
endif
ifeq ($(strip $(LIBTRANSISTOR_HOME)),)
$(error "Please set LIBTRANSISTOR_HOME in your environment. export LIBTRANSISTOR_HOME=<path/to/libtransistor/dist/>")
endif
include $(LIBTRANSISTOR_HOME)/libtransistor.mk
INCDIRS := -I. -Ideps -Ilibretro-common/include -Ilibretro-common/include/compat/zlib -Ideps/stb -I$(LIBTRANSISTOR_HOME)/build/sdl2_install/include/SDL2/
LIBDIRS := -L.
TARGETS := $(TARGET).nro
CFLAGS += $(INCDIRS) $(DEFINES) -Wno-unused-command-line-argument -Werror-implicit-function-declaration
all: $(TARGETS)
$(TARGET).nro.so: $(OBJ) libretro_switch.a fs.squashfs.o $(LIBTRANSISTOR_NRO_LIB) $(LIBTRANSISTOR_COMMON_LIBS)
$(LD) $(LD_FLAGS) --allow-multiple-definition -o $@ $(OBJ) libretro_switch.a fs.squashfs.o $(LIBTRANSISTOR_NRO_LDFLAGS) -lm
%.squashfs.o: %.squashfs
$(LD) -s -r -b binary -m aarch64elf -T $(LIBTRANSISTOR_HOME)/fs.T -o $@ $<
fs.squashfs: fs/*
mksquashfs $^ $@ -comp lz4 -nopad -noappend
clean:
rm -f $(OBJ) $(TARGET).nro.so $(TARGET).nro
.PHONY: clean all

View File

@ -1,192 +0,0 @@
TARGET := retroarch_vita
DEBUG ?= 0
HAVE_FILE_LOGGER = 1
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
VITA_TITLE_ID := RETROARCH
VITA_TITLE_NAME := RetroArch
PC_DEVELOPMENT_IP_ADDRESS =
PC_DEVELOPMENT_UDP_PORT =
OBJ :=
DEFINES := -DHAVE_ONLINE_UPDATER -DHAVE_UPDATE_ASSETS
INCDIRS :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1
DEFINES += -DHAVE_NEON -DHAVE_MENU -DHAVE_CONFIGFILE -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB DEFINES -DHAVE_KEYMAPPER
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_CC_RESAMPLER
ifeq ($(DEBUG), 1)
DEFINES += -DHAVE_NETLOGGER
endif
INCDIRS += -I. -Ideps/7zip -Ilibretro-common/include -Ilibretro-common/include/compat/zlib -Ideps/stb
else
HAVE_UPDATE_ASSETS := 1
HAVE_ONLINE_UPDATER := 1
HAVE_NEON := 1
HAVE_MATH_NEON := 1
HAVE_FILTERS_BUILTIN := 1
HAVE_LANGEXTRA := 1
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_ZLIB := 1
HAVE_7ZIP := 1
HAVE_VITA2D := 1
HAVE_VITAGL := 1
HAVE_NETWORKING := 1
HAVE_SOCKET_LEGACY := 1
HAVE_MENU := 1
HAVE_MENU_COMMON := 1
HAVE_GFX_WIDGETS := 1
HAVE_CONFIGFILE := 1
HAVE_OVERLAY := 1
HAVE_VIDEO_LAYOUT := 0
HAVE_MATERIALUI := 1
HAVE_XMB := 1
HAVE_RGUI := 1
HAVE_STB_FONT := 1
HAVE_THREADS := 1
HAVE_LIBRETRODB := 1
HAVE_CC_RESAMPLER := 1
HAVE_CHEEVOS := 1
HAVE_RUNAHEAD := 1
RARCH_CONSOLE := 1
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
HAVE_AUDIOMIXER := 1
ifeq ($(DEBUG), 1)
HAVE_NETLOGGER = 1
endif
include Makefile.common
CFLAGS += $(DEF_FLAGS)
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
INCDIRS += $(INCLUDE_DIRS)
endif
ifeq ($(strip $(VITASDK)),)
$(error "Please set VITASDK in your environment. export VITASDK=<path to>vitasdk")
endif
export PATH := $(PATH):$(VITASDK)/bin
PREFIX := arm-vita-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CC)
LIBDIRS := -L.
ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA
CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls -O2
ifeq ($(DEBUG), 1)
CFLAGS += -g
endif
ASFLAGS := $(CFLAGS)
LDFLAGS := -Wl,-q
CFLAGS += -Wall -ffast-math -g
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),)
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS='"$(PC_DEVELOPMENT_IP_ADDRESS)"'
endif
ifneq ($(PC_DEVELOPMENT_UDP_PORT),)
CFLAGS += -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
endif
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
CXXFLAGS := $(CFLAGS) -fno-rtti -fno-exceptions
VITA_LIBS := -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub \
-lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceTouch_stub -lSceAudio_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -lstdc++ -lpthread -lpng -lz
LIBS := $(WHOLE_START) -lretro_vita $(WHOLE_END) $(VITA_LIBS) -lm -lc
TARGETS := $(TARGET).vpk
DEPFLAGS = -MT $@ -MMD -MP -MF $*.Tdepend
POSTCOMPILE = mv -f $*.Tdepend $*.depend
all: $(TARGETS)
%.o: %.cpp
%.o: %.cpp %.depend
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.c
%.o: %.c %.depend
$(CC) -c -o $@ $< $(CFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.S
%.o: %.S %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.o: %.s
%.o: %.s %.depend
$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
$(POSTCOMPILE)
%.depend: ;
$(TARGET).elf: $(OBJ) libretro_vita.a
$(LD) $(OBJ) $(LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
%.velf: %.elf
cp $< $<.unstripped.elf
$(PREFIX)strip -g $<
vita-elf-create $< $@
%.self: %.velf
vita-make-fself -c -s $< $@
%.vpk: %.self
vita-mksfoex -s TITLE_ID=$(VITA_TITLE_ID) "$(VITA_TITLE_NAME)" -d ATTRIBUTE2=12 param.sfo
vita-pack-vpk -s param.sfo -b $< $@
clean:
rm -f $(OBJ) $(TARGET).elf $(TARGET).elf.unstripped.elf $(TARGET).velf $(TARGET).self param.sfo $(TARGET).vpk
rm -f $(OBJ:.o=.depend)
# Useful for developers
vpksend: $(TARGET).vpk
curl -T $< ftp://$(PSVITAIP):1337/ux0:/
send: $(TARGET).self
curl -T $< ftp://$(PSVITAIP):1337/ux0:/app/$(VITA_TITLE_ID)/eboot.bin
launch: $(TARGET).self
curl -T $< ftp://$(PSVITAIP):1337/ux0:/app/$(VITA_TITLE_ID)/eboot.bin
echo "launch $(VITA_TITLE_ID)" | nc ${PSVITAIP} 1338
.PHONY: clean all send vpksend
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend)

View File

@ -1,85 +0,0 @@
HAVE_FILE_LOGGER = 0
DEBUG = 0
TARGET = retroarchvita_salamander
TITLE_ID = RETROVITA
ifeq ($(DEBUG), 1)
OPTIMIZE_LV := -O0 -g
else
OPTIMIZE_LV := -O2
endif
PREFIX = arm-vita-eabi
CC = $(PREFIX)-gcc
INCDIR = libretro-common/include
CFLAGS = -Wl,-q $(OPTIMIZE_LV) -I$(INCDIR) -std=gnu99 -mfloat-abi=hard -ffast-math -fsingle-precision-constant -mword-relocations
ASFLAGS = $(CFLAGS)
RARCH_DEFINES = -DVITA -DIS_SALAMANDER -DRARCH_CONSOLE
LIBDIR =
LDFLAGS =
LIBS = -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub -lSceAppUtil_stub\
-lSceSysmodule_stub -lSceCtrl_stub -lSceHid_stub -lSceAudio_stub -lSceFiber_stub\
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub -lSceMotion_stub \
-lSceMotion_stub -lSceAppMgr_stub -lfreetype -lpng -lm -lc
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
CFLAGS += $(RARCH_DEFINES)
OBJS = frontend/frontend_salamander.o \
frontend/frontend_driver.o \
frontend/drivers/platform_psp.o \
libretro-common/file/file_path.o \
libretro-common/file/file_path_io.o \
libretro-common/string/stdstring.o \
libretro-common/lists/string_list.o \
libretro-common/lists/dir_list.o \
libretro-common/file/retro_dirent.o \
libretro-common/encodings/encoding_utf.o \
libretro-common/compat/compat_strl.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/compat/fopen_utf8.o \
libretro-common/file/config_file.o \
libretro-common/streams/file_stream.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/hash/rhash.o \
file_path_str.o \
verbosity.o
all: $(TARGET).vpk
%.vpk: eboot.bin
vita-mksfoex -s TITLE_ID=$(TITLE_ID) "$(TARGET)" -d ATTRIBUTE2=12 param.sfo
vita-pack-vpk -s param.sfo -b eboot.bin $@
eboot.bin: $(TARGET).velf
vita-make-fself $< $@
%.velf: %.elf
vita-elf-create $< $@
$(TARGET).elf: $(OBJS)
$(CC) $(CFLAGS) $^ $(LIBS) -o $@
%.o: %.png
$(PREFIX)-ld -r -b binary -o $@ $^
clean:
@rm -rf $(TARGET).vpk $(TARGET).velf $(TARGET).elf $(OBJS) \
eboot.bin param.sfo
vpksend: $(TARGET).vpk
curl -T $(TARGET).vpk ftp://$(PSVITAIP):1337/ux0:/
@echo "Sent."
PSVITAIP = 192.168.1.15
send: eboot.bin
curl -T eboot.bin ftp://$(PSVITAIP):1337/ux0:/app/$(TITLE_ID)/
@echo "Sent."

View File

@ -1,141 +0,0 @@
###
##
# Makefile for RetroArch Wii.
##
DEBUG = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
EXTERNAL_LIBOGC = 0
# system platform
system_platform = unix
ifeq ($(shell uname -a),)
EXE_EXT = .exe
system_platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
system_platform = osx
else ifneq ($(findstring MINGW,$(shell uname -a)),)
system_platform = win
endif
PC_DEVELOPMENT_IP_ADDRESS = 255.255.255.255
PC_DEVELOPMENT_UDP_PORT = 3490
CC = $(DEVKITPPC)/bin/powerpc-eabi-gcc$(EXE_EXT)
CXX = $(DEVKITPPC)/bin/powerpc-eabi-g++$(EXE_EXT)
LD = $(DEVKITPPC)/bin/powerpc-eabi-ld$(EXE_EXT)
ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT)
DOL_TARGET := retroarch-salamander_wii.dol
ELF_TARGET := retroarch-salamander_wii.elf
INCLUDE := -I. -Ilibretro-common/include -Ilibretro-common/include/compat/zlib
ifeq ($(EXTERNAL_LIBOGC), 1)
INCLUDE += -I$(DEVKITPRO)/libogc/include
LIBDIRS := -L$(DEVKITPRO)/libogc/lib/wii -L.
else
INCLUDE += -Iwii/libogc/include
LIBDIRS := -Lwii/libogc/libs/wii -L.
endif
MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
CFLAGS += -Wall -std=gnu99 $(MACHDEP) $(INCLUDE)
LDFLAGS := $(MACHDEP) -Wl,-Map,$(notdir $(ELF_TARGET)).map
ifeq ($(EXTERNAL_LIBOGC), 1)
LIBS := -lfat
endif
LIBS += -lwiiuse -logc -lbte
APP_BOOTER_DIR = wii/app_booter
OBJ = frontend/frontend_salamander.o \
frontend/frontend_driver.o \
frontend/drivers/platform_gx.o \
frontend/drivers/platform_wii.o \
libretro-common/file/file_path.o \
libretro-common/file/file_path_io.o \
libretro-common/hash/rhash.o \
libretro-common/string/stdstring.o \
libretro-common/lists/string_list.o \
libretro-common/lists/dir_list.o \
libretro-common/streams/file_stream.o \
libretro-common/vfs/vfs_implementation.o \
libretro-common/file/retro_dirent.o \
libretro-common/encodings/encoding_utf.o \
libretro-common/compat/compat_strl.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/compat/fopen_utf8.o \
libretro-common/file/config_file.o \
file_path_str.o \
verbosity.o \
$(APP_BOOTER_DIR)/app_booter.binobj
ifeq ($(EXTERNAL_LIBOGC), 1)
else
OBJ += wii/libogc/libfat/cache.o \
wii/libogc/libfat/directory.o \
wii/libogc/libfat/disc.o \
wii/libogc/libfat/fatdir.o \
wii/libogc/libfat/fatfile.o \
wii/libogc/libfat/file_allocation_table.o \
wii/libogc/libfat/filetime.o \
wii/libogc/libfat/libfat.o \
wii/libogc/libfat/lock.o \
wii/libogc/libfat/partition.o
endif
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT)
OBJ += network/net_logger.o \
libretro-common/net/net_compat.o \
libretro-common/net/net_socket.o
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
CFLAGS += -std=gnu99 -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_RARCH_EXEC -DGEKKO -Wno-char-subscripts
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
ifeq ($(USBGECKO), 1)
LIBS += -ldb
CFLAGS += -DUSBGECKO
endif
all: $(DOL_TARGET)
%.dol: %.elf
$(ELF2DOL) $< $@
$(ELF_TARGET): $(OBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
%.binobj: %.bin
$(LD) -r -b binary -o $@ $<
$(APP_BOOTER_DIR)/app_booter.bin:
$(MAKE) -C $(APP_BOOTER_DIR)
pkg: all
cp -r $(DOL_TARGET) pkg/wii/boot.dol
clean:
rm -f $(DOL_TARGET)
rm -f $(ELF_TARGET)
rm -f $(OBJ)
$(MAKE) -C $(APP_BOOTER_DIR) clean
.PHONY: clean

View File

@ -1,335 +0,0 @@
TARGET := retroarch_wiiu
BUILD_HBL_ELF = 1
BUILD_RPX = 1
DEBUG = 0
GRIFFIN_BUILD = 0
SALAMANDER_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
WIIU_HID = 1
HAVE_RUNAHEAD = 1
WIIU_LOG_RPX = 0
BUILD_DIR = objs/wiiu
PC_DEVELOPMENT_TCP_PORT ?=
ifeq ($(SALAMANDER_BUILD),1)
BUILD_DIR := $(BUILD_DIR)-salamander
TARGET := $(TARGET)_salamander
else ifeq ($(GRIFFIN_BUILD),1)
BUILD_DIR := $(BUILD_DIR)-griffin
endif
ifeq ($(DEBUG),1)
BUILD_DIR := $(BUILD_DIR)-debug
endif
ifneq ($(V), 1)
Q := @
endif
DEFINES :=
OBJ :=
INCDIRS :=
#-----------------------------
# Features and object files
OBJ += wiiu/main.o
OBJ += wiiu/system/memory.o
OBJ += wiiu/system/atomic.o
OBJ += wiiu/system/exception_handler.o
OBJ += wiiu/system/missing_libc_functions.o
OBJ += wiiu/fs/sd_fat_devoptab.o
OBJ += wiiu/fs/fs_utils.o
OBJ += wiiu/hbl.o
RPX_OBJ = $(BUILD_DIR)/wiiu/system/stubs_rpl.o
HBL_ELF_OBJ = $(BUILD_DIR)/wiiu/system/dynamic.o \
$(BUILD_DIR)/wiiu/system/stubs_elf.o
ifeq ($(SALAMANDER_BUILD),1)
DEFINES += -DRARCH_CONSOLE -DIS_SALAMANDER
OBJ += frontend/frontend_salamander.o
OBJ += frontend/frontend_driver.o
OBJ += frontend/drivers/platform_wiiu.o
OBJ += libretro-common/encodings/encoding_utf.o
OBJ += libretro-common/compat/compat_strcasestr.o
OBJ += libretro-common/compat/fopen_utf8.o
OBJ += libretro-common/file/file_path.o
OBJ += libretro-common/file/file_path_io.o
OBJ += libretro-common/string/stdstring.o
OBJ += libretro-common/lists/string_list.o
OBJ += libretro-common/lists/dir_list.o
OBJ += libretro-common/file/retro_dirent.o
OBJ += libretro-common/compat/compat_strl.o
OBJ += libretro-common/file/config_file.o
OBJ += libretro-common/streams/file_stream.o
OBJ += libretro-common/vfs/vfs_implementation.o
OBJ += libretro-common/hash/rhash.o
OBJ += file_path_str.o
OBJ += verbosity.o
# $(SALAMANDER_BUILD),0
else
DEFINES += -DRARCH_INTERNAL
DEFINES += -DHAVE_KEYMAPPER
DEFINES += -DHAVE_ONLINE_UPDATER
DEFINES += -DHAVE_UPDATE_ASSETS
DEFINES += -DHAVE_UPDATE_CORES
DEFINES += -DHAVE_FILTERS_BUILTIN
DEFINES += -DHAVE_SLANG
DEFINES += -DHAVE_SHADERPIPELINE
ifeq ($(HAVE_RUNAHEAD),1)
DEFINES += -DHAVE_RUNAHEAD
endif
OBJ += wiiu/shader_utils.o
OBJ += gfx/drivers/gx2_shaders/tex.o
OBJ += gfx/drivers/gx2_shaders/sprite.o
OBJ += gfx/drivers/gx2_shaders/frame.o
OBJ += gfx/drivers/gx2_shaders/ribbon.o
OBJ += gfx/drivers/gx2_shaders/ribbon_simple.o
OBJ += gfx/drivers/gx2_shaders/bokeh.o
OBJ += gfx/drivers/gx2_shaders/snow.o
OBJ += gfx/drivers/gx2_shaders/snow_simple.o
OBJ += gfx/drivers/gx2_shaders/snowflake.o
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o griffin/griffin_cpp.o
INCDIRS += -Ilibretro-common/include/compat/zlib
# for stb, libfat, iosuhax
INCDIRS += -Ideps -Ideps/libfat/include -Ideps/libiosuhax
# pad_functions uses wiiu/input.h
INCDIRS += -Iinput/include
INCDIRS += -Ideps/SPIRV-Cross
DEFINES += -DHAVE_AUDIOMIXER
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_GFX_WIDGETS -DHAVE_CONFIGFILE -DHAVE_RGUI -DHAVE_LIBRETRODB
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_SPIRV_CROSS -DHAVE_SLANG
DEFINES += -DHAVE_STB_FONT -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB -DHAVE_NETWORKING -DHAVE_NETPLAYDISCOVERY
#DEFINES += -DWANT_IFADDRS
#DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
DEFINES += -DHAVE_HID
DEFINES += -DWANT_LIBFAT -DHAVE_LIBFAT -DWANT_IOSUHAX -DHAVE_IOSUHAX
DEFINES += -DSPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
# $(GRIFFIN_BUILD),0
else
HAVE_AUDIOMIXER = 1
HAVE_MENU_COMMON = 1
HAVE_GFX_WIDGETS = 1
HAVE_RTGA = 1
HAVE_RPNG = 1
HAVE_RJPEG = 1
HAVE_RBMP = 1
HAVE_CONFIGFILE = 1
HAVE_MENU = 1
HAVE_RGUI = 1
HAVE_7ZIP = 1
HAVE_ZLIB = 1
HAVE_BUILTINZLIB = 0
HAVE_LIBRETRODB = 1
HAVE_MATERIALUI = 1
HAVE_XMB = 1
HAVE_STB_FONT = 1
#HAVE_FREETYPE = 1
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_NETWORKING = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_CHEEVOS = 1
#WANT_IFADDRS = 1
HAVE_OVERLAY = 1
HAVE_SPIRV_CROSS = 1
HAVE_SLANG = 1
HAVE_VIDEO_LAYOUT = 0
HAVE_STATIC_VIDEO_FILTERS = 1
HAVE_STATIC_AUDIO_FILTERS = 1
WANT_LIBFAT = 1
WANT_IOSUHAX = 1
include Makefile.common
DEFINES += $(DEF_FLAGS)
INCDIRS += $(INCLUDE_DIRS)
endif
endif
OBJ := $(addprefix $(BUILD_DIR)/,$(OBJ))
#-----------------------------
# Compile flags
DEFINES += -DWIIU -D__WUT__ -DHW_WUP -D__wiiu__
DEFINES += -DHAVE_MAIN
DEFINES += -DRARCH_CONSOLE
ifeq ($(WIIU_LOG_RPX),1)
DEFINES += -DWIIU_LOG_RPX
endif
ifneq ($(PC_DEVELOPMENT_TCP_PORT),)
DEFINES += -DPC_DEVELOPMENT_TCP_PORT=$(PC_DEVELOPMENT_TCP_PORT)
endif
INCDIRS += -I.
INCDIRS += -Ilibretro-common/include
INCDIRS += -Iwiiu
INCDIRS += -Iwiiu/include
CFLAGS := -mcpu=750 -meabi -mhard-float
CFLAGS += -ffast-math -Werror=implicit-function-declaration
CFLAGS += -ffunction-sections -fdata-sections
#CFLAGS += -fomit-frame-pointer -mword-relocations
CFLAGS += -Wall
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
ASFLAGS := $(CFLAGS) -mregnames
#-----------------------------
# Linking/library flags
LIBDIRS := -L.
LDFLAGS := $(CFLAGS)
ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_START := -Wl,--whole-archive
WHOLE_END := -Wl,--no-whole-archive
endif
LIBS := $(WHOLE_START) -lretro_wiiu $(WHOLE_END) -lm
# Use portlibs zlib if deps/ isn't being used
ifeq ($(HAVE_ZLIB),1)
ifeq ($(HAVE_BUILTINZLIB),0)
INCDIRS += -I$(DEVKITPRO)/portlibs/ppc/include
LIBDIRS += -L$(DEVKITPRO)/portlibs/ppc/lib
# Bonus: libpng for cores that need it
LIBS += -lpng -lz
endif
endif
LDFLAGS += -Wl,--gc-sections
RPX_LDFLAGS := -pie -fPIE
RPX_LDFLAGS += -z common-page-size=64 -z max-page-size=64
RPX_LDFLAGS += -T wiiu/link_rpl.ld
RPX_LDFLAGS += -nostartfiles
HBL_ELF_LDFLAGS := -T wiiu/link_elf.ld
#-----------------------------
# Compiler setup
ifeq ($(strip $(DEVKITPPC)),)
$(error "Please set DEVKITPPC in your environment. export DEVKITPPC=<path to>devkitPPC")
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitPRO")
endif
export PATH := $(PATH):$(DEVKITPPC)/bin
PREFIX := powerpc-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
AS := $(PREFIX)as
AR := $(PREFIX)ar
OBJCOPY := $(PREFIX)objcopy
STRIP := $(PREFIX)strip
NM := $(PREFIX)nm
LD := $(CXX)
ELF2RPL := wiiu/wut/elf2rpl/elf2rpl
ifneq ($(findstring Linux,$(shell uname -a)),)
else ifneq ($(findstring Darwin,$(shell uname -a)),)
else
ELF2RPL := $(ELF2RPL).exe
endif
#-----------------------------
# Targets and build rules
TARGETS :=
ifeq ($(BUILD_RPX), 1)
TARGETS += $(TARGET).rpx
endif
ifeq ($(BUILD_HBL_ELF), 1)
TARGETS += $(TARGET).elf
endif
DEPFLAGS = -MT $@ -MMD -MP -MF $(BUILD_DIR)/$*.depend
all: $(TARGETS)
%: $(BUILD_DIR)/%
cp $< $@
$(BUILD_DIR)/%.o: %.cpp %.depend
@$(if $(Q), echo CXX $<,)
@mkdir -p $(dir $@)
$(Q)$(CXX) -c -o $@ $< $(CXXFLAGS) $(DEFINES) $(INCDIRS) $(DEPFLAGS)
$(BUILD_DIR)/%.o: %.c %.depend
@$(if $(Q), echo CC $<,)
@mkdir -p $(dir $@)
$(Q)$(CC) -c -o $@ $< $(CFLAGS) $(DEFINES) $(INCDIRS) $(DEPFLAGS)
$(BUILD_DIR)/%.o: %.S %.depend
@$(if $(Q), echo AS $<,)
@mkdir -p $(dir $@)
$(Q)$(CC) -c -o $@ $< $(ASFLAGS) $(DEFINES) $(INCDIRS) $(DEPFLAGS)
$(BUILD_DIR)/%.o: %.s %.depend
@$(if $(Q), echo AS $<,)
@mkdir -p $(dir $@)
$(Q)$(CC) -c -o $@ $< $(ASFLAGS) $(INCDIRS) $(DEPFLAGS)
%.a:
@$(if $(Q), echo AR $<,)
@mkdir -p $(dir $@)
$(Q)$(AR) -rc $@ $^
%.depend: ;
%.last: ;
$(ELF2RPL):
@$(if $(Q), echo MAKE $@,)
$(Q)$(MAKE) -C wiiu/wut/elf2rpl/
$(BUILD_DIR)/$(TARGET).elf: $(OBJ) $(HBL_ELF_OBJ) libretro_wiiu.a wiiu/link_elf.ld .$(TARGET).elf.last
@$(if $(Q), echo LD $@,)
@touch .$(TARGET).elf.last
$(Q)$(LD) $(OBJ) $(HBL_ELF_OBJ) $(LDFLAGS) $(HBL_ELF_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(BUILD_DIR)/$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.ld
@$(if $(Q), echo LD $@,)
$(Q)$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(BUILD_DIR)/$(TARGET).rpx: $(BUILD_DIR)/$(TARGET).rpx.elf $(ELF2RPL) .$(TARGET).rpx.last
@$(if $(Q), echo ELF2RPL $@,)
@touch .$(TARGET).rpx.last
$(Q)-$(ELF2RPL) $< $@
clean:
@$(if $(Q), echo $@,)
$(Q)rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
$(Q)rm -f $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).rpx.elf $(BUILD_DIR)/$(TARGET).rpx
$(Q)rm -f .$(TARGET).elf.last .$(TARGET).rpx.elf.last .$(TARGET).rpx.last
$(Q)rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
.PHONY: clean all
.PRECIOUS: %.depend %.last
-include $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)

View File

@ -1,185 +0,0 @@
TARGET = retroarch.exe
HAVE_AUDIOMIXER = 1
HAVE_DINPUT = 1
HAVE_XAUDIO = 1
HAVE_DSOUND = 1
HAVE_WASAPI = 1
HAVE_OPENGL = 1
HAVE_DYLIB = 1
HAVE_D3D9 = 1
HAVE_NETWORKING = 1
HAVE_NETPLAYDISCOVERY = 1
HAVE_STDIN_CMD = 1
HAVE_COMMAND = 1
HAVE_THREADS = 1
HAVE_MENU = 1
HAVE_CONFIGFILE = 1
HAVE_RGUI = 1
HAVE_MATERIALUI = 1
HAVE_7ZIP = 1
HAVE_PYTHON = 0
DYNAMIC = 1
HAVE_XINPUT = 1
HAVE_WINMM = 1
HAVE_SDL := 0
HAVE_SDL2 := 0
HAVE_RSOUND := 0
HAVE_PYTHON := 0
HAVE_STB_FONT := 1
HAVE_FREETYPE := 1
HAVE_FFMPEG := 0
HAVE_CG := 1
HAVE_ZLIB := 1
HAVE_CC_RESAMPLER := 1
ifeq ($(HAVE_CG), 1)
CG_LIBS := -lcg -lcgGL
endif
ifeq ($(HAVE_FREETYPE), 1)
FREETYPE_CFLAGS := -DHAVE_FREETYPE -Ifreetype2
FREETYPE_LIBS := -lfreetype
endif
ifeq ($(HAVE_SDL), 1)
SDL_LIBS := -lSDL
SDL_CFLAGS := -ISDL -DHAVE_SDL
BSD_LOCAL_INC :=
endif
ifeq ($(HAVE_SDL2), 1)
SDL2_LIBS := -lSDL2
SDL2_CFLAGS := -ISDL2 -DHAVE_SDL2
endif
ifeq ($(HAVE_D3D8), 1)
D3D8_LIBS := -ld3d8
ifeq ($(HAVE_D3DX), 1)
D3DX8_LIBS := -ld3dx8
endif
endif
ifeq ($(HAVE_D3D9), 1)
D3D9_LIBS := -ld3d9
ifeq ($(HAVE_D3DX), 1)
D3DX9_LIBS := -ld3dx9
endif
endif
ifeq ($(HAVE_RSOUND), 1)
RSOUND_CFLAGS := -DHAVE_RSOUND
RSOUND_LIBS := -lrsound
endif
ifeq ($(HAVE_PYTHON), 1)
PYTHON_LIBS := -lpython32
PYTHON_CFLAGS := -DHAVE_PYTHON -Ipython
endif
ifeq ($(HAVE_FFMPEG), 1)
AVCODEC_LIBS := -lavcodec
AVUTIL_LIBS := -lavutil
SWSCALE_LIBS := -lswscale
AVFORMAT_LIBS := -lavformat
SWRESAMPLE_LIBS := -lswresample
FFMPEG_LIBS := -lws2_32 -lz
endif
OBJDIR := obj-w32
OS := Win32
OBJ :=
LIBS := -lm
DEFINES :=
DEFINES += -I. -Ilibretro-common/include -Ilibretro-common/include/compat/zlib -DRARCH_INTERNAL -DHAVE_OVERLAY
#DEFINES += -DHAVE_VIDEO_LAYOUT
LDFLAGS := -L. -static-libgcc
include Makefile.common
HEADERS = $(wildcard */*/*.h) $(wildcard */*.h) $(wildcard *.h)
ifneq ($(HOST_PREFIX),)
CC = $(HOST_PREFIX)gcc
CXX = $(HOST_PREFIX)g++
WINDRES = $(HOST_PREFIX)windres
else
CC = gcc
CXX = g++
WINDRES = windres
endif
libretro ?= -lretro
ifeq ($(DYNAMIC), 1)
DEFINES += -DHAVE_DYNAMIC
else
LIBS += $(libretro)
endif
ifneq ($(V), 1)
Q := @
endif
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
CXXFLAGS += -O0 -g
else
CFLAGS += -O3 -ffast-math
CXXFLAGS += -O3 -ffast-math
endif
CFLAGS += $(DEF_FLAGS) -Wall -Wno-unused-result -Wno-unused-variable -I. -Ideps
CXXFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. -Ideps -std=c++98 -D__STDC_CONSTANT_MACROS
ifeq ($(CXX_BUILD), 1)
CFLAGS += -std=c++98 -xc++ -D__STDC_CONSTANT_MACROS
else
ifneq ($(GNU90_BUILD), 1)
CFLAGS += -std=gnu99
endif
endif
RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
all: $(TARGET)
-include $(RARCH_OBJ:.o=.d)
$(TARGET): $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
$(Q)$(CXX) -o $@ $(RARCH_OBJ) $(LIBS) $(LDFLAGS) $(LDCXXFLAGS)
#those mkdir shenanigans are really ugly, but I can't find any better solution
$(OBJDIR)/%.o: %.c
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
.FORCE:
$(OBJDIR)/git_version.o: git_version.c .FORCE
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.cpp | $(dir $@)
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.rc $(HEADERS)
@-mkdir -p $(dir $@) || mkdir $(subst /,\,$(dir $@)) || echo .
@$(if $(Q), $(shell echo echo WINDRES $<),)
$(Q)$(WINDRES) -o $@ $<
clean:
rm -rf $(OBJDIR)
rm -f $(TARGET)
rm -f *.d
.PHONY: all install uninstall clean

View File

@ -1,38 +0,0 @@
# RetroArch OMAP video driver
The OMAP video driver for RetroArch uses the omapfb (OMAP framebuffer) driver from the Linux kernel. omapfb is not to be confused with omapdrm, which is the corresponding DRM driver.
OMAP framebuffer support is available on platforms like the Pandora (OMAP3) handheld console, the Beagleboard (OMAP3) single-board computer or the Pandaboard (OMAP4), which is also a single-board computer.
The OMAP display hardware provides free scaling to native screen dimensions, using a high-quality polyphase filter.
## DSS setup
The DSS is the underlying layer, which manages the OMAP display hardware. Through DSS we can setup which framebuffer device outputs to which display device. For example there are three framebuffer devices (fb0, fb1 and fb2) on the Pandaboard, each one connected to a 'overlay' device. The DSS controls are exported in '/sys/devices/platform/omapdss'. Here we configure fb1 to connect to our HDMI display connected to the board.
First we disable the overlay we want to use and the two displays:
echo -n 0 > overlay1/enabled
echo -n 0 > display0/enabled
echo -n 0 > display1/enabled
Check that 'manager1' (name = tv) is connected to HDMI:
cat manager1/display:
hdmi
The free scaling property mentioned above is not available on all overlays. Here 'overlay1' supports zero-cost scaling.
Now we connect 'overlay1' to 'manager1':
echo -n tv > overlay1/manager
Last but not least enable the overlay and the HDMI display:
echo -n 1 > overlay1/enabled
echo -n 1 > display0/enabled
## Configuration
The video driver name is 'omap'. It honors the following video settings:
- video\_monitor\_index (selects the fb device used, index = 1 -> fb0, index = 2 -> fb1, etc.)
- video\_vsync (use to disable vsync, however this is not recommended)

View File

@ -1,60 +0,0 @@
# RetroArch Exynos-G2D video driver
The Exynos-G2D video driver for RetroArch uses the Exynos DRM layer for presentation and the Exynos G2D block to scale and blit the emulator framebuffer to the screen. The G2D subsystem is a separate functional block on modern Samsung Exynos SoCs (in particular Exynos4412 and Exynos5250) that accelerates various kind of 2D blit operations. It can fill, copy, scale and blend pixel buffers and therefore provides adequate functionality for RetroArch purposes.
## Reasons to use the driver
Hardware accelerated rendering on devices based on an Exynos SoC is usually restricted to the use of the GPU block, which is either a Mali or PowerVR IP. Both GPU types have the problem that interfacing with them requires a proprietary driver stack, comprised of kernel and userspace code. While the kernel code is open source, the userspace code is only available as a binary blob to the enduser.
If you want to use such a device with an upstream kernel, the GPU block will most likely not work for you. Also the chances of Mali or PowerVR kernel code being accepted upstream is very slim. Still, one might want to ask the question if using the GPU block for such trivial operations (basically scale and blend) is the right approach in the first place.
Since the G2D block is present on all modern Exynos SoCs, the natural way of proceeding would be to use it instead of the GPU block. The G2D is still a dedicated piece of hardware, so all operations are offloaded from the CPU. It should be noted though, that using the G2D instead of the GPU removes the possibility to use GPU shaders to enhance the image quality of your emulator core of choice. If the user relies on these enhancements, then he's advised to continue using the GPU, most likely by using the EGL/GLES video driver.
The author uses a Hardkernel ODROID-X2, which is an developer board powered by an Exynos4412 SoC. The vendor supplied kernel, a Linux tree based on the 3.8.y branch, currently offers no way to use the G2D because of issues related to clock setup. However upstreaming work is in progress and a tree based on 3.15.y, with some slight modifications, is available from here:
[odroid-3.15.y repository](https://github.com/tobiasjakobi/linux-odroid)
Please refer to the minimalistic documentation in README-ODROID for setup.
## Performance analysis
Some simple benchmarking was done to evaluate the performance of the G2D block. The test run was done with the snes9x-next emulation core and a game title that uses a native resolution of 256x224 pixels. The output screen was configured to a 1280x720 mode. Scaling to the output screen was done by keeping the native aspect ratio. In this case this would result in an output rectangle of size 822x720.
total memcpy calls: 18795
total g2d calls: 18795
total memcpy time: 8.978532 seconds
total g2d time: 29.703944 seconds
average time per memcpy call: 477.708540 microseconds
average time per g2d call: 1580.417345 microseconds
The average time to display the emulator framebuffer on screen is roughly 2058 microseconds, or around 486 frames per second. Assuming that the time consumption increases linearly with the amount of pixels processed, which is usually a safe assumption, scaling to an output rectangle of size 1920x1080 would yield a average duration of 7207 microseconds, which is still 138 frames per second.
## Configuration
The video driver uses the libdrm API to interface with the DRM. Some patches are still missing in the upstream tree, therefore the user is advised to use the 'exynos' branch of the repository mentioned below.
[libdrm repository](https://github.com/tobiasjakobi/libdrm)
Make sure that the Exynos API support is enabled. If you're building libdrm from source, then use
./configure --enable-exynos-experimental-api
to enable it.
The video driver name is 'exynos'. It honors the following video settings:
- video\_monitor\_index
- video\_fullscreen\_x and video\_fullscreen\_y
The monitor index maps to the DRM connector index. If it is zero, then it just selects the first 'sane' connector, which means that it is connected to a display device and it provides at least one useable mode. If the value is non-zero, it forces the selection of this connector. For example, on the author's ODROID-X2, with an odroid-3.15.y kernel, the HDMI connector has index 1.
The two fullscreen parameters select the mode the DRM should select. If zero, the native connector mode is selected. If non-zero, the DRM tries to select the wanted mode. This might fail if the mode is not available from the connector.
## Issues and TODOs
The driver still suffers from some issues.
- The aspect ratio computation can be improved. In particular the user supplied aspect ratio is currently unused.
- Font rendering and blitting is very inefficient since the backing buffer is cleared every frame. Introduce a invalidation rectangle which covers the region where font glyphs are drawn, and then only clear this region. Also consider converting the buffer to A8 color format and using global color (not sure if this is possible).
- Temporary GEM buffers are used as source for blitting operations. Support for the IOMMU has to be enabled, so that one can use the 'userptr' functionality.
- More TODOs are pointed out in the code itself.

View File

@ -1,88 +0,0 @@
USAGE NOTES
===========
This driver is meant for devices with Allwinner SoCs with Mali400 3D block and a
good fbdev implementation. It is derived from the old Android GLES driver.
It was meant to be used on Cubieboard/Cubieboard2/Cubietruck, but it should not
be used on an Odroid X2/U2/U3 where a superior solution (RetroArch exynos video driver) is available.
Fbdev implementation on Odroid harware is missing WAITFORVSYNC ioctl, so use Exynos driver there.
This driver requires MALI r4p0 binary blobs for fbdev, and a kernel compatible with r4p0 binaries.
So we will use
-This kernel : https://github.com/mireq/linux-sunxi
-This small patch : https://gist.github.com/ssvb/8088519
-Files in this thread : http://forum.odroid.com/viewtopic.php?f=52&t=4956
First we will clone and build the kernel:
git clone https://github.com/mireq/linux-sunxi.git -b sunxi-3.4 --depth 1
Now we edit drivers/video/sunxi/disp/dev_fb.c, and uncomment the line 1074:
// Fb_wait_for_vsync(info);
It is assumed you have a cross-compiler installed, so we configure and build the kernel and modules:
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- sun7i_defconfig
(This is for Cubieboard2, for other Sunxi boards look here: http://linux-sunxi.org/Linux_Kernel#Compilation)
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- menuconfig
(Just in case we want to customize kernel options. It is OK to build with default config)
make -j4 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- uImage modules
make ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- INSTALL_MOD_PATH=<path_to_rootfs_mountpoint> modules_install
cp arch/arm/boot/uImage /<path_to_sd_rootfs_mountpoint>/boot/
Now we should download and extract the EGL/GLES/GLES2 MALI FBDEV blobs from this thread:
http://forum.odroid.com/viewtopic.php?f=52&t=4956
This is the exact link:
http://builder.mdrjr.net/tools/r4p0-mp400-fbdev.tar
Copy these libraries to /usr/lib.
Now we need the headers. We can get them from here:
http://malideveloper.arm.com/develop-for-mali/sdks/opengl-es-sdk-for-linux/#opengl-es-sdk-for-linux-download
Download whatever version you want. We just get the headers from here, not machine-dependant compiled code.
Extract the files and copy the directories inside inc to /usr/include .
Also, copy simple_framework/inc/mali/EGL/fbdev_window.h to /usr/include/EGL .
In the end you should have this on your system:
/usr/include/EGL/
eglext.h
egl.h
eglplatform.h
fbdev_window.h
/usr/include/GLES/
glext.h
gl.h
glplatform.h
/usr/include/GLES2
gl2ext.h
gl2.h
gl2platform.h
/usr/include/GLES3
gl3ext.h
gl3.h
gl3platform.h
To enable mali_fbdev you must configure RetroArch with --enable-gles and --enable-mali_fbdev.
This is an example of what you would use on a CubieBoard2 for a lightweight RetroArch:
./configure --enable-gles --enable-mali_fbdev --disable-x11 --disable-sdl2 --enable-floathard --disable-ffmpeg --disable-netplay --enable-udev --disable-sdl --disable-pulse --disable-oss --disable-freetype --disable-7zip
NOTE: A TTY hack is used to auto-clean the console on exit, and the fbdev ioctls are used to retrieve
current video mode. Both things work good, but they are not exactly ideal solutions.
If you come up with something better, feel free to improve the driver.

325
README.md
View File

@ -1,281 +1,44 @@
[![Build Status](https://travis-ci.org/libretro/RetroArch.svg?branch=master)](https://travis-ci.org/libretro/RetroArch)
[![Coverity Scan Build Status](https://scan.coverity.com/projects/8936/badge.svg)](https://scan.coverity.com/projects/retroarch)
# RetroArch
RetroArch is the reference frontend for the libretro API.
Popular examples of implementations for this API includes video game system emulators and game engines as well as
more generalized 3D programs.
These programs are instantiated as dynamic libraries. We refer to these as "libretro cores".
![XMB menu driver](docs/XMB-main-menu.jpg "XMB menu driver")
![rgui menu driver](docs/rgui-main-menu.jpg "rgui menu driver")
![glui menu driver](docs/glui-main-menu.jpg "glui menu driver")
![ozone menu driver](docs/ozone-main-menu.jpg "ozone menu driver")
## libretro
[libretro](https://www.libretro.com) is an API that exposes generic audio/video/input callbacks.
A frontend for libretro (such as RetroArch) handles video output, audio output, input and application lifecycle.
A libretro core written in portable C or C++ can run seamlessly on many platforms with very little to no porting effort.
While RetroArch is the reference frontend for libretro, several other projects have used the libretro
interface to include support for emulators and/or game engines. libretro is completely open and free for anyone to use.
[libretro API header](https://github.com/libretro/RetroArch/blob/master/libretro-common/include/libretro.h)
## Binaries
Latest binaries are currently hosted on the [buildbot](http://buildbot.libretro.com/).
## Support
To reach developers, either make an issue here on GitHub, make a thread on the [forum](https://www.libretro.com/forums/), chat on [discord](https://discord.gg/C4amCeV), or visit our IRC channel: #retroarch @ irc.freenode.org. You could create a post in [Reddit](https://www.reddit.com/r/RetroArch/) with *Technical Support* flair.
## Documentation
See our [Documentation Center](https://docs.libretro.com/). On Unix, man-pages are provided.
More developer-centric stuff is found [here](https://docs.libretro.com/development/libretro-overview/).
## Related projects
- Cg/HLSL shaders: [common-shaders](https://github.com/libretro/common-shaders)
- slang shaders: [slang-shaders](https://github.com/libretro/slang-shaders)
- GLSL shaders: [glsl-shaders](https://github.com/libretro/glsl-shaders)
- Helper scripts to build libretro implementations: [libretro-super](https://github.com/libretro/libretro-super)
- GitHub mirrors of projects, useful for generating diff files: [libretro-mirrors](https://github.com/libretro-mirrors/)
## Philosophy
RetroArch attempts to be small and lean
while still having all the useful core features expected from an emulator.
It is designed to be very portable and features a gamepad-centric and touchscreen UI.
It also has a full-featured command-line interface.
In some areas, RetroArch goes beyond and emphasizes on not-so-common technical features such as multi-pass shader support,
real-time rewind (Braid-style), video recording (using FFmpeg), run-ahead input latency removal, etc.
RetroArch also emphasizes being easy to integrate into various launcher frontends.
## Platforms
RetroArch has been ported to the following platforms:
- DOS
- Windows
- Linux
- Emscripten (WebAssembly and JavaScript)
- FreeBSD
- NetBSD
- OpenBSD
- Haiku
- Solaris
- macOS (PPC, x86-32 and x86-64)
- PlayStation 2
- PlayStation 3
- PlayStation Portable
- PlayStation Vita
- Original Microsoft Xbox
- Microsoft Xbox 360 (Libxenon/XeXDK)
- Nintendo GameCube
- Nintendo Wii
- Nintendo Wii U
- Nintendo 3DS/2DS
- Nintendo Switch
- Nintendo NES/SNES Classic Edition
- Raspberry Pi
- Android
- iOS
- Blackberry
## Dependencies (PC)
There are no true hard dependencies per se.
On Windows, RetroArch can run with only Win32 as dependency.
On Linux, there are no true dependencies. For optimal usage, the
following dependencies come as recommended:
- GL headers / Vulkan headers
- X11 headers and libs, or EGL/KMS/GBM
OSX port of RetroArch requires latest versions of XCode to build.
RetroArch can utilize these libraries if enabled:
- nvidia-cg-toolkit
- libfreetype2 (TTF font rendering on screen)
RetroArch needs at least one of these audio driver libraries:
- ALSA
- OSS
- RoarAudio
- RSound
- OpenAL
- JACK
- SDL
- PulseAudio
- XAudio2 (Win32, Xbox 360)
- DirectSound (Win32, Xbox 1)
- CoreAudio (OSX, iOS)
To run properly, RetroArch requires a libretro implementation present; however, as it's typically loaded
dynamically, it's not required at build time.
## Dependencies (Console ports, mobile)
Console ports have their own dependencies, but generally do not require
anything other than what the respective SDKs provide.
## Configuring
The default configuration is defined in `config.def.h`.
It is not recommended to change this unless you know what you're doing.
These can later be tweaked by using a config file.
A sample configuration file is installed to `/etc/retroarch.cfg`. This is the system-wide config file.
RetroArch will on startup create a config file in `$XDG\_CONFIG\_HOME/retroarch/retroarch.cfg` if it does not exist.
Users only need to configure a certain option if the desired value deviates from the value defined in config.def.h.
To configure joypads, use the built-in menu or the `retroarch-joyconfig` command-line tool.
## Compiling and installing
Instructions for compiling and installing RetroArch can be found in the [Libretro/RetroArch Documentation Center](https://docs.libretro.com/).
## CRT 15Khz Resolution Switching
CRT SwitchRes will turn on, on the fly. However, you will need to restart RetroArch to disable it. With CRT SwitchRes enable RetroArch will start in 2560 x 480 @ 60.
If you are running Windows, before enabling the CRT SwitchRes options please make sure you have installed CRTEmudriver and installed some modelines. The minimum modelines for all games to switch correctly are:
- 2560 x 192 @ 60.000000
- 2560 x 200 @ 60.000000
- 2560 x 240 @ 60.000000
- 2560 x 224 @ 60.000000
- 2560 x 237 @ 60.000000
- 2560 x 256 @ 50.000000
- 2560 x 254 @ 55.000000
- 2560 x 448 @ 60.000000
- 2560 x 480 @ 60.000000
Install these modelines replacing 2560 with your desired super resolution. The above resolutions are NTSC only so if you would be playing any PAL content please add PAL modelines:
- 2560 x 192 @ 50.000000
- 2560 x 200 @ 50.000000
- 2560 x 240 @ 50.000000
- 2560 x 224 @ 50.000000
- 2560 x 288 @ 50.000000
- 2560 x 237 @ 50.000000
- 2560 x 254 @ 55.000000
- 2560 x 448 @ 50.000000
- 2560 x 480 @ 50.000000
Some games will require higher PAL resolutions which should also be installed:
- 2560 x 512 @ 50.000000
- 2560 x 576 @ 50.000000
Ideally install all these modelines and everything will work great.
## Super Resolutions
The default super resolution is 2560. It is displayed just under the CRT switch option, which can be found in video settings. This can be changed within the retroarch.cfg. The only compatible resolutions are 1920, 2560 and 3840. Any other resolutions will be ignored and native switching will be activated.
## Native Resolutions
If native resolutions are activated you will need a whole new set of modelines:
- 256 x 240 @ 50.006977 SNESpal
- 256 x 448 @ 50.006977 SNESpal
- 512 x 224 @ 50.006977 SNESpal
- 512 x 240 @ 50.006977 SNESpal
- 512 x 448 @ 50.006977 SNESpal
- 256 x 240 @ 60.098812 SNESntsc
- 256 x 448 @ 60.098812 SNESntsc
- 512 x 240 @ 60.098812 SNESntsc
- 512 x 224 @ 60.098812 SNESntsc
- 512 x 448 @ 60.098812 SNESntsc
- 256 x 192 @ 59.922745 MDntsc
- 256 x 224 @ 59.922745 MDntsc
- 320 x 224 @ 59.922745 MDntsc
- 320 x 240 @ 59.922745 MDntsc
- 320 x 448 @ 59.922745 MDntsc
- 320 x 480 @ 59.922745 MDntsc
- 256 x 192 @ 49.701458 MDpal
- 256 x 224 @ 49.701458 MDpal
- 320 x 224 @ 49.701458 MDpal
- 320 x 240 @ 49.701458 MDpal
- 320 x 288 @ 49.701458 MDpal
- 320 x 448 @ 49.701458 MDpal
- 320 x 480 @ 49.701458 MDpal
- 320 x 576 @ 49.701458 MDpal
- 256 x 288 @ 49.701458 MSYSpal
- 256 x 240 @ 60.098812 NESntsc
- 256 x 240 @ 50.006977 NESpal
- 640 x 237 @ 60.130001 N64ntsc
- 640 x 240 @ 60.130001 N64ntsc
- 640 x 480 @ 60.130001 N64ntsc
- 640 x 288 @ 50.000000 N64pal
- 640 x 480 @ 50.000000 N64pal
- 640 x 576 @ 50.000000 N64pal
- 256 x 252 @ 49.759998 PSXpal
- 320 x 252 @ 49.759998 PSXpal
- 384 x 252 @ 49.759998 PSXpal
- 640 x 252 @ 49.759998 PSXpal
- 640 x 540 @ 49.759998 PSXpal
- 384 x 240 @ 59.941002 PSXntsc
- 256 x 480 @ 59.941002 PSXntsc
- 352 x 240 @ 59.820000 Saturn/SGFX_NTSCp
- 704 x 240 @ 59.820000 SaturnNTSCp
- 352 x 480 @ 59.820000 SaturnNTSCi
- 704 x 480 @ 59.820000 SaturnNTSCi
- 352 x 288 @ 49.701458 SaturnPALp
- 704 x 288 @ 49.701458 SaturnPALp
- 352 x 576 @ 49.701458 SaturnPALi
- 704 x 576 @ 49.701458 SaturnPALi
- 240 x 160 @ 59.730000 GBA
- 320 x 200 @ 60.000000 Doom
// Arcade
- 400 x 254 @ 54.706841 MK
- 384 x 224 @ 59.637405 CPS1
These modelines are more accurate giving exact hz. However, some games may have unwanted results. This is due to mid-scanline resolution changes on the original hardware. For the best results super resolutions are the way to go.
## CRT resolution switching & MAME
Some arcade resolutions can be very different from consumer CRTs. There is resolution detection to ensure MAME games will be displayed in the closest available resolution but drawn at their native resolution within this resolution. Meaning that the MAME game will look just like the original hardware.
MAME ROMs that run in a vertical aspect like DoDonPachi need to be rotated within MAME before resolution switching and aspect correction will work. Do this before enabling CRT SwitchRes so that RetroArch will run in your desktop resolution. Once you have rotated any games that may need it turn CRT SwitchRes on.
## Socials
The links below belong to our official channels. Links other than this may have been created by fans, independent members or followers. We seriously recommend using our original resources.
- [Website](https://www.retroarch.com/)
- [Blog](https://libretro.com/)
- [Facebook](https://www.facebook.com/libretro)
- [Twitter](https://twitter.com/libretro)
- [Reddit](https://www.reddit.com/r/RetroArch/)
- [YouTube](https://www.youtube.com/Libretro)
- [Google Post](https://posts.google.com/share/55Nhs2jG)
- [Steam](https://store.steampowered.com/app/1118310/RetroArch/)
- [YouTube Topic](https://www.youtube.com/channel/UC5q007PYyQPgin0HHbzF0zQ)
- [Patreon](https://www.patreon.com/libretro)
- [BOUNTYSOURCE](https://www.bountysource.com/teams/libretro/issues)
- [Discord](https://discord.gg/27Xxm2h)
- [Teespring](https://teespring.com/stores/retroarch)
- [Documentation](https://docs.libretro.com/)
- [Forum](https://forums.libretro.com/)
# vitaGL
vitaGL is a wrapper between openGL and sceGxm. It allows to use a subset of openGL functions with fully hardware acceleration by translating the code to sceGxm equivalent.
# Build Instructions
In order to build vitaGL use the following command: `make HAVE_SBRK=1 install`.
If you already have a newlib sbrk replacement in your app (eg. RetroArch), use instead this command: `make install`.
# Samples
You can find samples in the *samples* folder in this repository.
# Help and Troubleshooting
If you plan to use vitaGL for one of your projects, you can find an official channel to get help with it on Vita Nuova discord server: https://discord.gg/PyCaBx9
# Projects actually using vitaGL
Here you can find a list of projects using vitaGL:
Direct OpenGL Usage:<br>
[vitaQuake](https://vitadb.rinnegatamante.it/#/info/10) - Port of Quake I and mission packs<br>
[vitaQuakeII](https://vitadb.rinnegatamante.it/#/info/278) -Port of Quake II and mission packs<br>
[vitaQuakeIII](https://vitadb.rinnegatamante.it/#/info/375) - Port of ioquake3 (Quake III: Arena, Quake III: Team Arena, OpenArena, Urban Terror)<br>
[vitaRTCW](https://vitadb.rinnegatamante.it/#/info/459) - Port of iortcw (Return to Castle Wolfenstein)<br>
[vitaHexenII](https://vitadb.rinnegatamante.it/#/info/196) - Port of Hexen II<br>
[vitaXash3D](https://vitadb.rinnegatamante.it/#/info/365) - Port of Xash3D (Half Life, Counter Strike 1.6)<br>
[Fade to Black](https://vitadb.rinnegatamante.it/#/info/367) - Port of Fade to Black<br>
[vitaVoyager](https://vitadb.rinnegatamante.it/#/info/367) - Port of lilium-voyager (Star Trek Voyager: Elite Force)<br>
[Daedalus X64](https://github.com/Rinnegatamante/daedalusx64-vitagl) - Port of Daedalus X64 (N64 Emulator)<br>
[RetroArch](https://github.com/libretro/RetroArch) - Vita's GL1 video driver of RetroArch<br>
[vitaET](https://github.com/Rinnegatamante/vitaET) - Port of ET:Legacy (Wolfenstein: Enemy Territory)<br>
Libraries:<br>
[sdl12_gl](https://github.com/Rinnegatamante/SDL-Vita/tree/sdl12_gl/src) - SDL 1.2 Vita port adapted to work with vitaGL as renderer<br>
[imgui_vita](https://github.com/Rinnegatamante/imgui-vita) - Port of dear imGui <br>
sdl12_gl Apps:<br>
[SuperMarioWar](https://vitadb.rinnegatamante.it/#/info/422) - Port of Super Mario War<br>
[ZeldaOLB](https://vitadb.rinnegatamante.it/#/info/265) - Port of Zelda: Oni Link Begins<br>
[ZeldaROTH](https://vitadb.rinnegatamante.it/#/info/109) - Port of Zelda: Return of the Hylian<br>
[Zelda3T](https://vitadb.rinnegatamante.it/#/info/334) - Port of Zelda: Time to Triumph<br>
[ZeldaNSQ](https://vitadb.rinnegatamante.it/#/info/350) - Port of Zelda: Navi's Quest<br>
[vitaWolfen](https://vitadb.rinnegatamante.it/#/info/31) - Port of Wolf4SDL<br>
[meritous](https://vitadb.rinnegatamante.it/#/info/411) - Port of meritous<br>

View File

@ -1,42 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2016 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RETROARCH_ACCESSIBILITY_H
#define __RETROARCH_ACCESSIBILITY_H
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <stdlib.h>
#include <boolean.h>
#include <retro_inline.h>
#include <retro_common_api.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
RETRO_BEGIN_DECLS
bool is_accessibility_enabled(void);
bool accessibility_speak_priority(const char* speak_text, int priority);
RETRO_END_DECLS
#endif

View File

@ -1,88 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __AUDIO_DEFINES__H
#define __AUDIO_DEFINES__H
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
#define AUDIO_CHUNK_SIZE_BLOCKING 512
/* So we don't get complete line-noise when fast-forwarding audio. */
#define AUDIO_CHUNK_SIZE_NONBLOCKING 2048
#define AUDIO_MAX_RATIO 16
#define AUDIO_MIXER_MAX_STREAMS 16
#define AUDIO_MIXER_MAX_SYSTEM_STREAMS (AUDIO_MIXER_MAX_STREAMS + 4)
/* do not define more than (MAX_SYSTEM_STREAMS - MAX_STREAMS) */
enum audio_mixer_system_slot
{
AUDIO_MIXER_SYSTEM_SLOT_OK = AUDIO_MIXER_MAX_STREAMS,
AUDIO_MIXER_SYSTEM_SLOT_CANCEL,
AUDIO_MIXER_SYSTEM_SLOT_NOTICE,
AUDIO_MIXER_SYSTEM_SLOT_BGM
};
enum audio_action
{
AUDIO_ACTION_NONE = 0,
AUDIO_ACTION_RATE_CONTROL_DELTA,
AUDIO_ACTION_MIXER_MUTE_ENABLE,
AUDIO_ACTION_MUTE_ENABLE,
AUDIO_ACTION_VOLUME_GAIN,
AUDIO_ACTION_MIXER_VOLUME_GAIN,
AUDIO_ACTION_MIXER
};
enum audio_mixer_slot_selection_type
{
AUDIO_MIXER_SLOT_SELECTION_AUTOMATIC = 0,
AUDIO_MIXER_SLOT_SELECTION_MANUAL
};
enum audio_mixer_stream_type
{
AUDIO_STREAM_TYPE_NONE = 0,
AUDIO_STREAM_TYPE_USER,
AUDIO_STREAM_TYPE_SYSTEM
};
enum audio_mixer_state
{
AUDIO_STREAM_STATE_NONE = 0,
AUDIO_STREAM_STATE_STOPPED,
AUDIO_STREAM_STATE_PLAYING,
AUDIO_STREAM_STATE_PLAYING_LOOPED,
AUDIO_STREAM_STATE_PLAYING_SEQUENTIAL
};
typedef struct audio_statistics
{
float average_buffer_saturation;
float std_deviation_percentage;
float close_to_underrun;
float close_to_blocking;
unsigned samples;
} audio_statistics_t;
RETRO_END_DECLS
#endif

View File

@ -1,325 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <queues/fifo_queue.h>
#include <rthreads/rthreads.h>
#include "audio_thread_wrapper.h"
#include "../verbosity.h"
typedef struct audio_thread
{
const audio_driver_t *driver;
void *driver_data;
sthread_t *thread;
slock_t *lock;
scond_t *cond;
bool alive;
bool stopped;
bool stopped_ack;
bool is_paused;
bool is_shutdown;
bool use_float;
int inited;
/* Initialization options. */
const char *device;
unsigned *new_rate;
unsigned out_rate;
unsigned latency;
unsigned block_frames;
} audio_thread_t;
static void audio_thread_loop(void *data)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return;
thr->driver_data = thr->driver->init(
thr->device, thr->out_rate, thr->latency,
thr->block_frames, thr->new_rate);
slock_lock(thr->lock);
thr->inited = thr->driver_data ? 1 : -1;
if (thr->inited > 0 && thr->driver->use_float)
thr->use_float = thr->driver->use_float(thr->driver_data);
scond_signal(thr->cond);
slock_unlock(thr->lock);
if (thr->inited < 0)
return;
/* Wait until we start to avoid calling
* stop immediately after initialization. */
slock_lock(thr->lock);
while (thr->stopped)
scond_wait(thr->cond, thr->lock);
slock_unlock(thr->lock);
for (;;)
{
slock_lock(thr->lock);
if (!thr->alive)
{
scond_signal(thr->cond);
thr->stopped_ack = true;
slock_unlock(thr->lock);
break;
}
if (thr->stopped)
{
thr->driver->stop(thr->driver_data);
while (thr->stopped)
{
/* If we stop right after start,
* we might not be able to properly ack.
* Signal in the loop instead. */
thr->stopped_ack = true;
scond_signal(thr->cond);
scond_wait(thr->cond, thr->lock);
}
thr->driver->start(thr->driver_data, thr->is_shutdown);
}
slock_unlock(thr->lock);
audio_driver_callback();
}
thr->driver->free(thr->driver_data);
}
static void audio_thread_block(audio_thread_t *thr)
{
if (!thr)
return;
if (thr->stopped)
return;
slock_lock(thr->lock);
thr->stopped_ack = false;
thr->stopped = true;
scond_signal(thr->cond);
/* Wait until audio driver actually goes to sleep. */
while (!thr->stopped_ack)
scond_wait(thr->cond, thr->lock);
slock_unlock(thr->lock);
}
static void audio_thread_unblock(audio_thread_t *thr)
{
if (!thr)
return;
slock_lock(thr->lock);
thr->stopped = false;
scond_signal(thr->cond);
slock_unlock(thr->lock);
}
static void audio_thread_free(void *data)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return;
if (thr->thread)
{
slock_lock(thr->lock);
thr->stopped = false;
thr->alive = false;
scond_signal(thr->cond);
slock_unlock(thr->lock);
sthread_join(thr->thread);
}
if (thr->lock)
slock_free(thr->lock);
if (thr->cond)
scond_free(thr->cond);
free(thr);
}
static bool audio_thread_alive(void *data)
{
bool alive = false;
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return false;
audio_thread_block(thr);
alive = !thr->is_paused;
audio_thread_unblock(thr);
return alive;
}
static bool audio_thread_stop(void *data)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return false;
audio_thread_block(thr);
thr->is_paused = true;
audio_driver_disable_callback();
return true;
}
static bool audio_thread_start(void *data, bool is_shutdown)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return false;
audio_driver_enable_callback();
thr->is_paused = false;
thr->is_shutdown = is_shutdown;
audio_thread_unblock(thr);
return true;
}
static void audio_thread_set_nonblock_state(void *data, bool state)
{
(void)data;
(void)state;
}
static bool audio_thread_use_float(void *data)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return false;
return thr->use_float;
}
static ssize_t audio_thread_write(void *data, const void *buf, size_t size)
{
ssize_t ret;
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return 0;
ret = thr->driver->write(thr->driver_data, buf, size);
if (ret < 0)
{
slock_lock(thr->lock);
thr->alive = false;
scond_signal(thr->cond);
slock_unlock(thr->lock);
}
return ret;
}
static const audio_driver_t audio_thread = {
NULL,
audio_thread_write,
audio_thread_stop,
audio_thread_start,
audio_thread_alive,
audio_thread_set_nonblock_state,
audio_thread_free,
audio_thread_use_float,
"audio-thread",
NULL, /* No point in using rate control with threaded audio. */
NULL,
};
/**
* audio_init_thread:
* @out_driver : output driver
* @out_data : output audio data
* @device : audio device (optional)
* @out_rate : output audio rate
* @latency : audio latency
* @driver : audio driver
*
* Starts a audio driver in a new thread.
* Access to audio driver will be mediated through this driver.
* This driver interfaces with audio callback and is
* only used in that case.
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool audio_init_thread(const audio_driver_t **out_driver,
void **out_data, const char *device, unsigned audio_out_rate,
unsigned *new_rate, unsigned latency,
unsigned block_frames, const audio_driver_t *drv)
{
audio_thread_t *thr = (audio_thread_t*)calloc(1, sizeof(*thr));
if (!thr)
return false;
thr->driver = (const audio_driver_t*)drv;
thr->device = device;
thr->out_rate = audio_out_rate;
thr->new_rate = new_rate;
thr->latency = latency;
thr->block_frames = block_frames;
if (!(thr->cond = scond_new()))
goto error;
if (!(thr->lock = slock_new()))
goto error;
thr->alive = true;
thr->stopped = true;
if (!(thr->thread = sthread_create(audio_thread_loop, thr)))
goto error;
/* Wait until thread has initialized (or failed) the driver. */
slock_lock(thr->lock);
while (!thr->inited)
scond_wait(thr->cond, thr->lock);
slock_unlock(thr->lock);
if (thr->inited < 0) /* Thread failed. */
goto error;
*out_driver = &audio_thread;
*out_data = thr;
return true;
error:
*out_driver = NULL;
*out_data = NULL;
audio_thread_free(thr);
return false;
}

View File

@ -1,45 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef RARCH_AUDIO_THREAD_H__
#define RARCH_AUDIO_THREAD_H__
#include <boolean.h>
#include "../retroarch.h"
/**
* audio_init_thread:
* @out_driver : output driver
* @out_data : output audio data
* @device : audio device (optional)
* @out_rate : output audio rate
* @new_rate : new output audio rate
* @latency : audio latency
* @driver : audio driver
*
* Starts a audio driver in a new thread.
* Access to audio driver will be mediated through this driver.
* This driver interfaces with audio callback and is only used in that case.
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool audio_init_thread(const audio_driver_t **out_driver, void **out_data,
const char *device, unsigned out_rate, unsigned *new_rate, unsigned latency,
unsigned block_frames,
const audio_driver_t *driver);
#endif

View File

@ -1,136 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <encodings/utf.h>
#include <lists/string_list.h>
#include "mmdevice_common.h"
#include "mmdevice_common_inline.h"
void *mmdevice_list_new(void *u)
{
HRESULT hr;
UINT i;
PROPVARIANT prop_var;
union string_list_elem_attr attr;
IMMDeviceEnumerator *enumerator = NULL;
IMMDeviceCollection *collection = NULL;
UINT dev_count = 0;
IMMDevice *device = NULL;
LPWSTR dev_id_wstr = NULL;
IPropertyStore *prop_store = NULL;
bool br = false;
bool prop_var_init = false;
char *dev_id_str = NULL;
char *dev_name_str = NULL;
struct string_list *sl = string_list_new();
if (!sl)
return NULL;
attr.i = 0;
#ifdef __cplusplus
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
IID_IMMDeviceEnumerator, (void **)&enumerator);
#else
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
#endif
if (FAILED(hr))
goto error;
hr = _IMMDeviceEnumerator_EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
if (FAILED(hr))
goto error;
hr = _IMMDeviceCollection_GetCount(collection, &dev_count);
if (FAILED(hr))
goto error;
for (i = 0; i < dev_count; ++i)
{
hr = _IMMDeviceCollection_Item(collection, i, &device);
if (FAILED(hr))
goto error;
hr = _IMMDevice_GetId(device, &dev_id_wstr);
if (FAILED(hr))
goto error;
if (!(dev_id_str = utf16_to_utf8_string_alloc(dev_id_wstr)))
goto error;
hr = _IMMDevice_OpenPropertyStore(device, STGM_READ, &prop_store);
if (FAILED(hr))
goto error;
PropVariantInit(&prop_var);
prop_var_init = true;
hr = _IPropertyStore_GetValue(
prop_store, PKEY_Device_FriendlyName,
&prop_var);
if (FAILED(hr))
goto error;
if (!(dev_name_str = utf16_to_utf8_string_alloc(prop_var.pwszVal)))
goto error;
br = string_list_append(sl, dev_name_str, attr);
if (!br)
goto error;
if (dev_id_str)
sl->elems[sl->size-1].userdata = dev_id_str;
PropVariantClear(&prop_var);
prop_var_init = false;
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
if (dev_name_str)
free(dev_name_str);
dev_name_str = NULL;
dev_id_wstr = NULL;
IFACE_RELEASE(prop_store);
IFACE_RELEASE(device);
}
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
return sl;
error:
if (dev_id_str)
free(dev_id_str);
if (dev_name_str)
free(dev_name_str);
dev_id_str = NULL;
dev_name_str = NULL;
if (prop_var_init)
PropVariantClear(&prop_var);
IFACE_RELEASE(prop_store);
if (dev_id_wstr)
CoTaskMemFree(dev_id_wstr);
dev_id_wstr = NULL;
IFACE_RELEASE(device);
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
if (sl)
string_list_free(sl);
return NULL;
}

View File

@ -1,27 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MMDEVICE_COMMON_H
#define _MMDEVICE_COMMON_H
#include <stdlib.h>
RETRO_BEGIN_DECLS
void *mmdevice_list_new(void *u);
RETRO_END_DECLS
#endif

View File

@ -1,114 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MMDEVICE_COMMON_INLINE_H
#define _MMDEVICE_COMMON_INLINE_H
#include <stdlib.h>
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winerror.h>
#include <propidl.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <mmreg.h>
#include <audioclient.h>
#include <retro_common_api.h>
#ifdef _MSC_VER
DEFINE_GUID(IID_IAudioClient, 0x1CB9AD4C, 0xDBFA, 0x4C32, 0xB1, 0x78, 0xC2, 0xF5, 0x68, 0xA7, 0x03, 0xB2);
DEFINE_GUID(IID_IAudioRenderClient, 0xF294ACFC, 0x3146, 0x4483, 0xA7, 0xBF, 0xAD, 0xDC, 0xA7, 0xC2, 0x60, 0xE2);
DEFINE_GUID(IID_IMMDeviceEnumerator, 0xA95664D2, 0x9614, 0x4F35, 0xA7, 0x46, 0xDE, 0x8D, 0xB6, 0x36, 0x17, 0xE6);
DEFINE_GUID(CLSID_MMDeviceEnumerator, 0xBCDE0395, 0xE52F, 0x467C, 0x8E, 0x3D, 0xC4, 0x57, 0x92, 0x91, 0x69, 0x2E);
#undef KSDATAFORMAT_SUBTYPE_IEEE_FLOAT
DEFINE_GUID(KSDATAFORMAT_SUBTYPE_IEEE_FLOAT, 0x00000003, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);
#endif
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); /* DEVPROP_TYPE_STRING */
#ifdef __cplusplus
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->Item(nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->Start() )
#define _IAudioClient_Stop(This) ( (This)->Stop() )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->GetCurrentPadding(pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->GetBuffer(NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->ReleaseBuffer(NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->GetService(riid,ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->SetEventHandle(eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->GetBufferSize(pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->GetStreamLatency(phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->GetDevicePeriod(phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->Activate(iid,(dwClsCtx),pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->EnumAudioEndpoints(dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->GetDefaultAudioEndpoint(dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->OpenPropertyStore(stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) ((This)->GetId(ppstrId))
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->GetValue(key,pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->GetCount(cProps) )
#else
#define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice)
#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) )
#define _IAudioClient_Stop(This) ( (This)->lpVtbl -> Stop(This) )
#define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \
( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) )
#define _IAudioRenderClient_GetBuffer(This,NumFramesRequested,ppData) \
( (This)->lpVtbl -> GetBuffer(This,NumFramesRequested,ppData) )
#define _IAudioRenderClient_ReleaseBuffer(This,NumFramesWritten,dwFlags) \
( (This)->lpVtbl -> ReleaseBuffer(This,NumFramesWritten,dwFlags) )
#define _IAudioClient_GetService(This,riid,ppv) ( (This)->lpVtbl -> GetService(This,&(riid),ppv) )
#define _IAudioClient_SetEventHandle(This,eventHandle) ( (This)->lpVtbl -> SetEventHandle(This,eventHandle) )
#define _IAudioClient_GetBufferSize(This,pNumBufferFrames) ( (This)->lpVtbl -> GetBufferSize(This,pNumBufferFrames) )
#define _IAudioClient_GetStreamLatency(This,phnsLatency) ( (This)->lpVtbl -> GetStreamLatency(This,phnsLatency) )
#define _IAudioClient_GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) ( (This)->lpVtbl -> GetDevicePeriod(This,phnsDefaultDevicePeriod,phnsMinimumDevicePeriod) )
#define _IMMDevice_Activate(This,iid,dwClsCtx,pActivationParams,ppv) ((This)->lpVtbl->Activate(This,&(iid),dwClsCtx,pActivationParams,ppv))
#define _IMMDeviceEnumerator_EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices) (This)->lpVtbl->EnumAudioEndpoints(This,dataFlow,dwStateMask,ppDevices)
#define _IMMDeviceEnumerator_GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint) (This)->lpVtbl->GetDefaultAudioEndpoint(This,dataFlow,role,ppEndpoint)
#define _IMMDevice_OpenPropertyStore(This,stgmAccess,ppProperties) (This)->lpVtbl->OpenPropertyStore(This,stgmAccess,ppProperties)
#define _IMMDevice_GetId(This,ppstrId) (This)->lpVtbl->GetId(This,ppstrId)
#define _IPropertyStore_GetValue(This,key,pv) ( (This)->lpVtbl -> GetValue(This,&(key),pv) )
#define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->lpVtbl -> GetCount(This,cProps) )
#endif
#ifdef __cplusplus
#ifndef IFACE_RELEASE
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->Release(); \
iface = NULL; \
}
#endif
#else
#ifndef IFACE_RELEASE
#define IFACE_RELEASE(iface) \
if (iface) \
{ \
iface->lpVtbl->Release(iface);\
iface = NULL; \
}
#endif
#endif
#endif

View File

@ -1,431 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <lists/string_list.h>
#include <string/stdstring.h>
#include <alsa/asoundlib.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct alsa
{
snd_pcm_t *pcm;
size_t buffer_size;
bool nonblock;
unsigned int frame_bits;
bool has_float;
bool can_pause;
bool is_paused;
} alsa_t;
static bool alsa_use_float(void *data)
{
alsa_t *alsa = (alsa_t*)data;
return alsa->has_float;
}
static bool find_float_format(snd_pcm_t *pcm, void *data)
{
snd_pcm_hw_params_t *params = (snd_pcm_hw_params_t*)data;
if (snd_pcm_hw_params_test_format(pcm, params, SND_PCM_FORMAT_FLOAT) == 0)
{
RARCH_LOG("[ALSA]: Using floating point format.\n");
return true;
}
RARCH_LOG("[ALSA]: Using signed 16-bit format.\n");
return false;
}
static void *alsa_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
snd_pcm_format_t format;
snd_pcm_uframes_t buffer_size;
snd_pcm_hw_params_t *params = NULL;
snd_pcm_sw_params_t *sw_params = NULL;
unsigned latency_usec = latency * 1000;
unsigned channels = 2;
unsigned periods = 4;
unsigned orig_rate = rate;
const char *alsa_dev = "default";
alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
if (!alsa)
return NULL;
if (device)
alsa_dev = device;
if (snd_pcm_open(
&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, SND_PCM_NONBLOCK) < 0)
goto error;
if (snd_pcm_hw_params_malloc(&params) < 0)
goto error;
alsa->has_float = find_float_format(alsa->pcm, params);
format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16;
if (snd_pcm_hw_params_any(alsa->pcm, params) < 0)
goto error;
if (snd_pcm_hw_params_set_access(
alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED) < 0)
goto error;
/* channels hardcoded to 2 for now */
alsa->frame_bits = snd_pcm_format_physical_width(format) * 2;
if (snd_pcm_hw_params_set_format(alsa->pcm, params, format) < 0)
goto error;
if (snd_pcm_hw_params_set_channels(alsa->pcm, params, channels) < 0)
goto error;
/* Don't allow rate resampling when probing for the default rate (but ignore if this call fails) */
snd_pcm_hw_params_set_rate_resample(alsa->pcm, params, 0 );
if (snd_pcm_hw_params_set_rate_near(alsa->pcm, params, &rate, 0) < 0)
goto error;
if (rate != orig_rate)
*new_rate = rate;
if (snd_pcm_hw_params_set_buffer_time_near(
alsa->pcm, params, &latency_usec, NULL) < 0)
goto error;
if (snd_pcm_hw_params_set_periods_near(
alsa->pcm, params, &periods, NULL) < 0)
goto error;
if (snd_pcm_hw_params(alsa->pcm, params) < 0)
goto error;
/* Shouldn't have to bother with this,
* but some drivers are apparently broken. */
if (snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL))
snd_pcm_hw_params_get_period_size_min(params, &buffer_size, NULL);
RARCH_LOG("[ALSA]: Period size: %d frames\n", (int)buffer_size);
if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size))
snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size);
RARCH_LOG("[ALSA]: Buffer size: %d frames\n", (int)buffer_size);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->can_pause = snd_pcm_hw_params_can_pause(params);
RARCH_LOG("[ALSA]: Can pause: %s.\n", alsa->can_pause ? "yes" : "no");
if (snd_pcm_sw_params_malloc(&sw_params) < 0)
goto error;
if (snd_pcm_sw_params_current(alsa->pcm, sw_params) < 0)
goto error;
if (snd_pcm_sw_params_set_start_threshold(
alsa->pcm, sw_params, buffer_size / 2) < 0)
goto error;
if (snd_pcm_sw_params(alsa->pcm, sw_params) < 0)
goto error;
snd_pcm_hw_params_free(params);
snd_pcm_sw_params_free(sw_params);
return alsa;
error:
RARCH_ERR("[ALSA]: Failed to initialize...\n");
if (params)
snd_pcm_hw_params_free(params);
if (sw_params)
snd_pcm_sw_params_free(sw_params);
if (alsa)
{
if (alsa->pcm)
{
snd_pcm_close(alsa->pcm);
snd_config_update_free_global();
}
free(alsa);
}
return NULL;
}
#define BYTES_TO_FRAMES(bytes, frame_bits) ((bytes) * 8 / frame_bits)
#define FRAMES_TO_BYTES(frames, frame_bits) ((frames) * frame_bits / 8)
static bool alsa_start(void *data, bool is_shutdown);
static ssize_t alsa_write(void *data, const void *buf_, size_t size_)
{
alsa_t *alsa = (alsa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
snd_pcm_sframes_t written = 0;
snd_pcm_sframes_t size = BYTES_TO_FRAMES(size_, alsa->frame_bits);
size_t frames_size = alsa->has_float ? sizeof(float) : sizeof(int16_t);
/* Workaround buggy menu code.
* If a write happens while we're paused, we might never progress. */
if (alsa->is_paused)
if (!alsa_start(alsa, false))
return -1;
if (alsa->nonblock)
{
while (size)
{
snd_pcm_sframes_t frames = snd_pcm_writei(alsa->pcm, buf, size);
if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE)
{
if (snd_pcm_recover(alsa->pcm, frames, 1) < 0)
return -1;
break;
}
else if (frames == -EAGAIN)
break;
else if (frames < 0)
return -1;
written += frames;
buf += (frames << 1) * frames_size;
size -= frames;
}
}
else
{
bool eagain_retry = true;
while (size)
{
snd_pcm_sframes_t frames;
int rc = snd_pcm_wait(alsa->pcm, -1);
if (rc == -EPIPE || rc == -ESTRPIPE || rc == -EINTR)
{
if (snd_pcm_recover(alsa->pcm, rc, 1) < 0)
return -1;
continue;
}
frames = snd_pcm_writei(alsa->pcm, buf, size);
if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE)
{
if (snd_pcm_recover(alsa->pcm, frames, 1) < 0)
return -1;
break;
}
else if (frames == -EAGAIN)
{
/* Definitely not supposed to happen. */
if (eagain_retry)
{
eagain_retry = false;
continue;
}
break;
}
else if (frames < 0)
return -1;
written += frames;
buf += (frames << 1) * frames_size;
size -= frames;
}
}
return written;
}
static bool alsa_alive(void *data)
{
alsa_t *alsa = (alsa_t*)data;
if (!alsa)
return false;
return !alsa->is_paused;
}
static bool alsa_stop(void *data)
{
alsa_t *alsa = (alsa_t*)data;
if (alsa->is_paused)
return true;
if (alsa->can_pause
&& !alsa->is_paused)
{
int ret = snd_pcm_pause(alsa->pcm, 1);
if (ret < 0)
return false;
alsa->is_paused = true;
}
return true;
}
static void alsa_set_nonblock_state(void *data, bool state)
{
alsa_t *alsa = (alsa_t*)data;
alsa->nonblock = state;
}
static bool alsa_start(void *data, bool is_shutdown)
{
alsa_t *alsa = (alsa_t*)data;
if (!alsa->is_paused)
return true;
if (alsa->can_pause
&& alsa->is_paused)
{
int ret = snd_pcm_pause(alsa->pcm, 0);
if (ret < 0)
{
RARCH_ERR("[ALSA]: Failed to unpause: %s.\n",
snd_strerror(ret));
return false;
}
alsa->is_paused = false;
}
return true;
}
static void alsa_free(void *data)
{
alsa_t *alsa = (alsa_t*)data;
if (alsa)
{
if (alsa->pcm)
{
snd_pcm_drop(alsa->pcm);
snd_pcm_close(alsa->pcm);
snd_config_update_free_global();
}
free(alsa);
}
}
static size_t alsa_write_avail(void *data)
{
alsa_t *alsa = (alsa_t*)data;
snd_pcm_sframes_t avail = snd_pcm_avail(alsa->pcm);
if (avail < 0)
return alsa->buffer_size;
return FRAMES_TO_BYTES(avail, alsa->frame_bits);
}
static size_t alsa_buffer_size(void *data)
{
alsa_t *alsa = (alsa_t*)data;
return alsa->buffer_size;
}
static void *alsa_device_list_new(void *data)
{
void **hints, **n;
union string_list_elem_attr attr;
struct string_list *s = string_list_new();
if (!s)
return NULL;
attr.i = 0;
if (snd_device_name_hint(-1, "pcm", &hints) != 0)
goto error;
n = hints;
while (*n)
{
char *name = snd_device_name_get_hint(*n, "NAME");
char *io = snd_device_name_get_hint(*n, "IOID");
char *desc = snd_device_name_get_hint(*n, "DESC");
/* description of device IOID - input / output identifcation
* ("Input" or "Output"), NULL means both) */
if (!io || (string_is_equal(io, "Output")))
string_list_append(s, name, attr);
if (name)
free(name);
if (io)
free(io);
if (desc)
free(desc);
n++;
}
/* free hint buffer too */
snd_device_name_free_hint(hints);
return s;
error:
string_list_free(s);
return NULL;
}
static void alsa_device_list_free(void *data, void *array_list_data)
{
struct string_list *s = (struct string_list*)array_list_data;
if (!s)
return;
string_list_free(s);
}
audio_driver_t audio_alsa = {
alsa_init,
alsa_write,
alsa_stop,
alsa_start,
alsa_alive,
alsa_set_nonblock_state,
alsa_free,
alsa_use_float,
"alsa",
alsa_device_list_new,
alsa_device_list_free,
alsa_write_avail,
alsa_buffer_size,
};

View File

@ -1,382 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#include <sys/asoundlib.h>
#include <retro_math.h>
#include "../../retroarch.h"
#define MAX_FRAG_SIZE 3072
#define DEFAULT_RATE 48000
#define CHANNELS 2
typedef struct alsa
{
uint8_t **buffer;
uint8_t *buffer_chunk;
unsigned buffer_index;
unsigned buffer_ptr;
volatile unsigned buffered_blocks;
snd_pcm_t *pcm;
bool nonblock;
bool has_float;
bool can_pause;
bool is_paused;
unsigned buf_size;
unsigned buf_count;
} alsa_qsa_t;
typedef long snd_pcm_sframes_t;
static void *alsa_qsa_init(const char *device,
unsigned rate, unsigned latency, unsigned block_frames,
unsigned *new_rate)
{
int err, card, dev, i;
snd_pcm_channel_info_t pi;
snd_pcm_channel_params_t params = {0};
snd_pcm_channel_setup_t setup = {0};
alsa_qsa_t *alsa = (alsa_qsa_t*)calloc(1, sizeof(alsa_qsa_t));
if (!alsa)
return NULL;
(void)device;
(void)rate;
(void)latency;
if ((err = snd_pcm_open_preferred(&alsa->pcm, &card, &dev,
SND_PCM_OPEN_PLAYBACK)) < 0)
{
RARCH_ERR("[ALSA QSA]: Audio open error: %s\n",
snd_strerror(err));
goto error;
}
if((err = snd_pcm_nonblock_mode(alsa->pcm, 1)) < 0)
{
RARCH_ERR("[ALSA QSA]: Can't set blocking mode: %s\n",
snd_strerror(err));
goto error;
}
memset(&pi, 0, sizeof(pi));
pi.channel = SND_PCM_CHANNEL_PLAYBACK;
if ((err = snd_pcm_channel_info(alsa->pcm, &pi)) < 0)
{
RARCH_ERR("[ALSA QSA]: snd_pcm_channel_info failed: %s\n",
snd_strerror(err));
goto error;
}
memset(&params, 0, sizeof(params));
params.channel = SND_PCM_CHANNEL_PLAYBACK;
params.mode = SND_PCM_MODE_BLOCK;
params.format.interleave = 1;
params.format.format = SND_PCM_SFMT_S16_LE;
params.format.rate = DEFAULT_RATE;
params.format.voices = 2;
params.start_mode = SND_PCM_START_FULL;
params.stop_mode = SND_PCM_STOP_STOP;
params.buf.block.frag_size = pi.max_fragment_size;
params.buf.block.frags_min = 2;
params.buf.block.frags_max = 8;
RARCH_LOG("Fragment size: %d\n", params.buf.block.frag_size);
RARCH_LOG("Min Fragment size: %d\n", params.buf.block.frags_min);
RARCH_LOG("Max Fragment size: %d\n", params.buf.block.frags_max);
if ((err = snd_pcm_channel_params(alsa->pcm, &params)) < 0)
{
RARCH_ERR("[ALSA QSA]: Channel Parameter Error: %s\n",
snd_strerror(err));
goto error;
}
setup.channel = SND_PCM_CHANNEL_PLAYBACK;
if ((err = snd_pcm_channel_setup(alsa->pcm, &setup)) < 0)
{
RARCH_ERR("[ALSA QSA]: Channel Parameter Read Back Error: %s\n",
snd_strerror(err));
goto error;
}
if (block_frames)
alsa->buf_size = block_frames * 4;
else
alsa->buf_size = next_pow2(32 * latency);
RARCH_LOG("[ALSA QSA]: buffer size: %u bytes\n", alsa->buf_size);
alsa->buf_count = (latency * 4 * rate + 500) / 1000;
alsa->buf_count = (alsa->buf_count + alsa->buf_size / 2) / alsa->buf_size;
if ((err = snd_pcm_channel_prepare(alsa->pcm,
SND_PCM_CHANNEL_PLAYBACK)) < 0)
{
RARCH_ERR("[ALSA QSA]: Channel Prepare Error: %s\n",
snd_strerror(err));
goto error;
}
alsa->buffer = (uint8_t**)calloc(sizeof(uint8_t*), alsa->buf_count);
if (!alsa->buffer)
goto error;
alsa->buffer_chunk = (uint8_t*)calloc(alsa->buf_count, alsa->buf_size);
if (!alsa->buffer_chunk)
goto error;
for (i = 0; i < alsa->buf_count; i++)
alsa->buffer[i] = alsa->buffer_chunk + i * alsa->buf_size;
alsa->has_float = false;
alsa->can_pause = true;
RARCH_LOG("[ALSA QSA]: Can pause: %s.\n",
alsa->can_pause ? "yes" : "no");
return alsa;
error:
return (void*)-1;
}
static int check_pcm_status(void *data, int channel_type)
{
snd_pcm_channel_status_t status;
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
int ret = EOK;
memset(&status, 0, sizeof (status));
status.channel = channel_type;
if ((ret = snd_pcm_channel_status(alsa->pcm, &status)) == 0)
{
if (status.status == SND_PCM_STATUS_UNSECURE)
{
RARCH_ERR("check_pcm_status got SND_PCM_STATUS_UNSECURE, aborting playback\n");
ret = -EPROTO;
}
else if (status.status == SND_PCM_STATUS_UNDERRUN)
{
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_UNDERRUN.\n");
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
{
RARCH_ERR("Invalid state detected for underrun on snd_pcm_channel_prepare: %s\n",
snd_strerror(ret));
ret = -EPROTO;
}
}
else if (status.status == SND_PCM_STATUS_OVERRUN)
{
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_OVERRUN.\n");
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
{
RARCH_ERR("Invalid state detected for overrun on snd_pcm_channel_prepare: %s\n",
snd_strerror(ret));
ret = -EPROTO;
}
}
else if (status.status == SND_PCM_STATUS_CHANGE)
{
RARCH_LOG("check_pcm_status: SNDP_CM_STATUS_CHANGE.\n");
if ((ret = snd_pcm_channel_prepare(alsa->pcm, channel_type)) < 0)
{
RARCH_ERR("Invalid state detected for change on snd_pcm_channel_prepare: %s\n",
snd_strerror(ret));
ret = -EPROTO;
}
}
}
else
{
RARCH_ERR("check_pcm_status failed: %s\n", snd_strerror(ret));
if (ret == -ESRCH)
ret = -EBADF;
}
return ret;
}
static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
snd_pcm_sframes_t written = 0;
while (size)
{
size_t avail_write = MIN(alsa->buf_size - alsa->buffer_ptr, size);
if (avail_write)
{
memcpy(alsa->buffer[alsa->buffer_index] +
alsa->buffer_ptr, buf, avail_write);
alsa->buffer_ptr += avail_write;
buf = (void*)((uint8_t*)buf + avail_write);
size -= avail_write;
written += avail_write;
}
if (alsa->buffer_ptr >= alsa->buf_size)
{
snd_pcm_sframes_t frames = snd_pcm_write(alsa->pcm,
alsa->buffer[alsa->buffer_index], alsa->buf_size);
alsa->buffer_index = (alsa->buffer_index + 1) % alsa->buf_count;
alsa->buffer_ptr = 0;
if (frames <= 0)
{
int ret;
if (frames == -EAGAIN)
continue;
ret = check_pcm_status(alsa, SND_PCM_CHANNEL_PLAYBACK);
if (ret == -EPROTO || ret == -EBADF)
return -1;
}
}
}
return written;
}
static bool alsa_qsa_stop(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
if (alsa->can_pause && !alsa->is_paused)
{
int ret = snd_pcm_playback_pause(alsa->pcm);
if (ret < 0)
return false;
alsa->is_paused = true;
}
return true;
}
static bool alsa_qsa_alive(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
if (alsa)
return !alsa->is_paused;
return false;
}
static bool alsa_qsa_start(void *data, bool is_shutdown)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
if (alsa->can_pause && alsa->is_paused)
{
int ret = snd_pcm_playback_resume(alsa->pcm);
if (ret < 0)
{
RARCH_ERR("[ALSA QSA]: Failed to unpause: %s.\n",
snd_strerror(ret));
return false;
}
alsa->is_paused = false;
}
return true;
}
static void alsa_qsa_set_nonblock_state(void *data, bool state)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
int err;
if((err = snd_pcm_nonblock_mode(alsa->pcm, state)) < 0)
{
RARCH_ERR("Can't set blocking mode to %d: %s\n", state,
snd_strerror(err));
return;
}
alsa->nonblock = state;
}
static bool alsa_qsa_use_float(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
return alsa->has_float;
}
static void alsa_qsa_free(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
if (alsa)
{
if (alsa->pcm)
{
snd_pcm_close(alsa->pcm);
alsa->pcm = NULL;
}
free(alsa->buffer);
free(alsa->buffer_chunk);
free(alsa);
}
}
static size_t alsa_qsa_write_avail(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
size_t avail = (alsa->buf_count -
(int)alsa->buffered_blocks - 1) * alsa->buf_size +
(alsa->buf_size - (int)alsa->buffer_ptr);
return avail;
}
static size_t alsa_qsa_buffer_size(void *data)
{
alsa_qsa_t *alsa = (alsa_qsa_t*)data;
return alsa->buf_size * alsa->buf_count;
}
audio_driver_t audio_alsa = {
alsa_qsa_init,
alsa_qsa_write,
alsa_qsa_stop,
alsa_qsa_start,
alsa_qsa_alive,
alsa_qsa_set_nonblock_state,
alsa_qsa_free,
alsa_qsa_use_float,
"alsa",
NULL,
NULL,
alsa_qsa_write_avail,
alsa_qsa_buffer_size,
};

View File

@ -1,420 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2012-2015 - Michael Lelli
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <lists/string_list.h>
#include <alsa/asoundlib.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#include <string/stdstring.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#define TRY_ALSA(x) if (x < 0) \
goto error;
typedef struct alsa_thread
{
snd_pcm_t *pcm;
bool nonblock;
bool is_paused;
bool has_float;
volatile bool thread_dead;
size_t buffer_size;
size_t period_size;
snd_pcm_uframes_t period_frames;
fifo_buffer_t *buffer;
sthread_t *worker_thread;
slock_t *fifo_lock;
scond_t *cond;
slock_t *cond_lock;
} alsa_thread_t;
static void alsa_worker_thread(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
uint8_t *buf = (uint8_t *)calloc(1, alsa->period_size);
if (!buf)
{
RARCH_ERR("failed to allocate audio buffer");
goto end;
}
while (!alsa->thread_dead)
{
size_t avail;
size_t fifo_size;
snd_pcm_sframes_t frames;
slock_lock(alsa->fifo_lock);
avail = fifo_read_avail(alsa->buffer);
fifo_size = MIN(alsa->period_size, avail);
fifo_read(alsa->buffer, buf, fifo_size);
scond_signal(alsa->cond);
slock_unlock(alsa->fifo_lock);
/* If underrun, fill rest with silence. */
memset(buf + fifo_size, 0, alsa->period_size - fifo_size);
frames = snd_pcm_writei(alsa->pcm, buf, alsa->period_frames);
if (frames == -EPIPE || frames == -EINTR ||
frames == -ESTRPIPE)
{
if (snd_pcm_recover(alsa->pcm, frames, 1) < 0)
{
RARCH_ERR("[ALSA]: (#2) Failed to recover from error (%s)\n",
snd_strerror(frames));
break;
}
continue;
}
else if (frames < 0)
{
RARCH_ERR("[ALSA]: Unknown error occurred (%s).\n",
snd_strerror(frames));
break;
}
}
end:
slock_lock(alsa->cond_lock);
alsa->thread_dead = true;
scond_signal(alsa->cond);
slock_unlock(alsa->cond_lock);
free(buf);
}
static bool alsa_thread_use_float(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
return alsa->has_float;
}
static bool alsathread_find_float_format(snd_pcm_t *pcm,
snd_pcm_hw_params_t *params)
{
if (snd_pcm_hw_params_test_format(pcm, params, SND_PCM_FORMAT_FLOAT) == 0)
{
RARCH_LOG("ALSA: Using floating point format.\n");
return true;
}
RARCH_LOG("ALSA: Using signed 16-bit format.\n");
return false;
}
static void alsa_thread_free(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
if (alsa)
{
if (alsa->worker_thread)
{
slock_lock(alsa->cond_lock);
alsa->thread_dead = true;
slock_unlock(alsa->cond_lock);
sthread_join(alsa->worker_thread);
}
if (alsa->buffer)
fifo_free(alsa->buffer);
if (alsa->cond)
scond_free(alsa->cond);
if (alsa->fifo_lock)
slock_free(alsa->fifo_lock);
if (alsa->cond_lock)
slock_free(alsa->cond_lock);
if (alsa->pcm)
{
snd_pcm_drop(alsa->pcm);
snd_pcm_close(alsa->pcm);
}
free(alsa);
}
}
static void *alsa_thread_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
snd_pcm_uframes_t buffer_size;
snd_pcm_format_t format;
snd_pcm_hw_params_t *params = NULL;
snd_pcm_sw_params_t *sw_params = NULL;
const char *alsa_dev = device ? device : "default";
unsigned latency_usec = latency * 1000 / 2;
unsigned channels = 2;
unsigned periods = 4;
alsa_thread_t *alsa = (alsa_thread_t*)
calloc(1, sizeof(alsa_thread_t));
if (!alsa)
return NULL;
TRY_ALSA(snd_pcm_open(&alsa->pcm, alsa_dev, SND_PCM_STREAM_PLAYBACK, 0));
TRY_ALSA(snd_pcm_hw_params_malloc(&params));
alsa->has_float = alsathread_find_float_format(alsa->pcm, params);
format = alsa->has_float ? SND_PCM_FORMAT_FLOAT : SND_PCM_FORMAT_S16;
TRY_ALSA(snd_pcm_hw_params_any(alsa->pcm, params));
TRY_ALSA(snd_pcm_hw_params_set_access(
alsa->pcm, params, SND_PCM_ACCESS_RW_INTERLEAVED));
TRY_ALSA(snd_pcm_hw_params_set_format(alsa->pcm, params, format));
TRY_ALSA(snd_pcm_hw_params_set_channels(alsa->pcm, params, channels));
TRY_ALSA(snd_pcm_hw_params_set_rate(alsa->pcm, params, rate, 0));
TRY_ALSA(snd_pcm_hw_params_set_buffer_time_near(
alsa->pcm, params, &latency_usec, NULL));
TRY_ALSA(snd_pcm_hw_params_set_periods_near(
alsa->pcm, params, &periods, NULL));
TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params));
/* Shouldn't have to bother with this,
* but some drivers are apparently broken. */
if (snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL))
snd_pcm_hw_params_get_period_size_min(
params, &alsa->period_frames, NULL);
RARCH_LOG("ALSA: Period size: %d frames\n", (int)alsa->period_frames);
if (snd_pcm_hw_params_get_buffer_size(params, &buffer_size))
snd_pcm_hw_params_get_buffer_size_max(params, &buffer_size);
RARCH_LOG("ALSA: Buffer size: %d frames\n", (int)buffer_size);
alsa->buffer_size = snd_pcm_frames_to_bytes(alsa->pcm, buffer_size);
alsa->period_size = snd_pcm_frames_to_bytes(alsa->pcm, alsa->period_frames);
TRY_ALSA(snd_pcm_sw_params_malloc(&sw_params));
TRY_ALSA(snd_pcm_sw_params_current(alsa->pcm, sw_params));
TRY_ALSA(snd_pcm_sw_params_set_start_threshold(
alsa->pcm, sw_params, buffer_size / 2));
TRY_ALSA(snd_pcm_sw_params(alsa->pcm, sw_params));
snd_pcm_hw_params_free(params);
snd_pcm_sw_params_free(sw_params);
alsa->fifo_lock = slock_new();
alsa->cond_lock = slock_new();
alsa->cond = scond_new();
alsa->buffer = fifo_new(alsa->buffer_size);
if (!alsa->fifo_lock || !alsa->cond_lock || !alsa->cond || !alsa->buffer)
goto error;
alsa->worker_thread = sthread_create(alsa_worker_thread, alsa);
if (!alsa->worker_thread)
{
RARCH_ERR("error initializing worker thread");
goto error;
}
return alsa;
error:
RARCH_ERR("ALSA: Failed to initialize...\n");
if (params)
snd_pcm_hw_params_free(params);
if (sw_params)
snd_pcm_sw_params_free(sw_params);
alsa_thread_free(alsa);
return NULL;
}
static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
if (alsa->thread_dead)
return -1;
if (alsa->nonblock)
{
size_t avail;
size_t write_amt;
slock_lock(alsa->fifo_lock);
avail = fifo_write_avail(alsa->buffer);
write_amt = MIN(avail, size);
fifo_write(alsa->buffer, buf, write_amt);
slock_unlock(alsa->fifo_lock);
return write_amt;
}
else
{
size_t written = 0;
while (written < size && !alsa->thread_dead)
{
size_t avail;
slock_lock(alsa->fifo_lock);
avail = fifo_write_avail(alsa->buffer);
if (avail == 0)
{
slock_unlock(alsa->fifo_lock);
slock_lock(alsa->cond_lock);
if (!alsa->thread_dead)
scond_wait(alsa->cond, alsa->cond_lock);
slock_unlock(alsa->cond_lock);
}
else
{
size_t write_amt = MIN(size - written, avail);
fifo_write(alsa->buffer,
(const char*)buf + written, write_amt);
slock_unlock(alsa->fifo_lock);
written += write_amt;
}
}
return written;
}
}
static bool alsa_thread_alive(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
if (!alsa)
return false;
return !alsa->is_paused;
}
static bool alsa_thread_stop(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
if (alsa)
alsa->is_paused = true;
return true;
}
static void alsa_thread_set_nonblock_state(void *data, bool state)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
alsa->nonblock = state;
}
static bool alsa_thread_start(void *data, bool is_shutdown)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
if (alsa)
alsa->is_paused = false;
return true;
}
static size_t alsa_thread_write_avail(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
size_t val;
if (alsa->thread_dead)
return 0;
slock_lock(alsa->fifo_lock);
val = fifo_write_avail(alsa->buffer);
slock_unlock(alsa->fifo_lock);
return val;
}
static size_t alsa_thread_buffer_size(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
return alsa->buffer_size;
}
static void *alsa_thread_device_list_new(void *data)
{
void **hints, **n;
union string_list_elem_attr attr;
struct string_list *s = string_list_new();
if (!s)
return NULL;
attr.i = 0;
if (snd_device_name_hint(-1, "pcm", &hints) != 0)
goto error;
n = hints;
while (*n)
{
char *name = snd_device_name_get_hint(*n, "NAME");
char *io = snd_device_name_get_hint(*n, "IOID");
char *desc = snd_device_name_get_hint(*n, "DESC");
/* description of device IOID - input / output identifcation
* ("Input" or "Output"), NULL means both) */
if (!io || string_is_equal(io,"Output"))
string_list_append(s, name, attr);
if (name)
free(name);
if (io)
free(io);
if (desc)
free(desc);
n++;
}
/* free hint buffer too */
snd_device_name_free_hint(hints);
return s;
error:
string_list_free(s);
return NULL;
}
static void alsa_thread_device_list_free(void *data, void *array_list_data)
{
struct string_list *s = (struct string_list*)array_list_data;
if (!s)
return;
string_list_free(s);
}
audio_driver_t audio_alsathread = {
alsa_thread_init,
alsa_thread_write,
alsa_thread_stop,
alsa_thread_start,
alsa_thread_alive,
alsa_thread_set_nonblock_state,
alsa_thread_free,
alsa_thread_use_float,
"alsathread",
alsa_thread_device_list_new,
alsa_thread_device_list_free,
alsa_thread_write_avail,
alsa_thread_buffer_size,
};

View File

@ -1,212 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <errno.h>
#include <sys/audioio.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../../retroarch.h"
#include "../../verbosity.h"
#define DEFAULT_DEV "/dev/audio"
static void *audioio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_out_rate)
{
int *fd = (int*)calloc(1, sizeof(int));
const char *audiodev = device ? device : DEFAULT_DEV;
struct audio_info info;
if (!fd)
return NULL;
AUDIO_INITINFO(&info);
#ifdef AUMODE_PLAY_ALL
info.mode = AUMODE_PLAY_ALL;
#elif defined(AUMODE_PLAY)
info.mode = AUMODE_PLAY;
#endif
info.play.sample_rate = rate;
info.play.channels = 2;
info.play.precision = 16;
#ifdef AUDIO_ENCODING_SLINEAR
info.play.encoding = AUDIO_ENCODING_SLINEAR;
#else
info.play.encoding = AUDIO_ENCODING_LINEAR;
#endif
if ((*fd = open(audiodev, O_WRONLY)) < 0)
{
free(fd);
perror("open");
return NULL;
}
if (ioctl(*fd, AUDIO_SETINFO, &info) < 0)
goto error;
if (ioctl(*fd, AUDIO_GETINFO, &info) < 0)
goto error;
*new_out_rate = info.play.sample_rate;
return fd;
error:
close(*fd);
free(fd);
perror("ioctl");
return NULL;
}
static ssize_t audioio_write(void *data, const void *buf, size_t size)
{
ssize_t ret;
int *fd = (int*)data;
if (size == 0)
return 0;
if ((ret = write(*fd, buf, size)) < 0)
{
if (errno == EAGAIN && (fcntl(*fd, F_GETFL) & O_NONBLOCK))
return 0;
return -1;
}
return ret;
}
static bool audioio_stop(void *data)
{
struct audio_info info;
int *fd = (int*)data;
#ifdef AUDIO_FLUSH
if (ioctl(*fd, AUDIO_FLUSH, NULL) < 0)
return false;
#endif
if (ioctl(*fd, AUDIO_GETINFO, &info) < 0)
return false;
info.play.pause = true;
return ioctl(*fd, AUDIO_SETINFO, &info) == 0;
}
static bool audioio_start(void *data, bool is_shutdown)
{
struct audio_info info;
int *fd = (int*)data;
#ifdef AUDIO_FLUSH
if (ioctl(*fd, AUDIO_FLUSH, NULL) < 0)
return false;
#endif
if (ioctl(*fd, AUDIO_GETINFO, &info) < 0)
return false;
info.play.pause = false;
return ioctl(*fd, AUDIO_SETINFO, &info) == 0;
}
static bool audioio_alive(void *data)
{
struct audio_info info;
int *fd = (int*)data;
if (ioctl(*fd, AUDIO_GETINFO, &info) < 0)
return false;
return !info.play.pause;
}
static void audioio_set_nonblock_state(void *data, bool state)
{
int rc;
int *fd = (int*)data;
if (state)
rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) | O_NONBLOCK);
else
rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) & (~O_NONBLOCK));
if (rc != 0)
RARCH_WARN("Could not set nonblocking on audio file descriptor. Will not be able to fast-forward.\n");
}
static void audioio_free(void *data)
{
int *fd = (int*)data;
#ifdef AUDIO_FLUSH
(void)ioctl(*fd, AUDIO_FLUSH, NULL);
#endif
close(*fd);
free(fd);
}
static size_t audioio_buffer_size(void *data)
{
struct audio_info info;
int *fd = (int*)data;
if (ioctl(*fd, AUDIO_GETINFO, &info) < 0)
return false;
return info.play.buffer_size;
}
static size_t audioio_write_avail(void *data)
{
return audioio_buffer_size(data);
}
static bool audioio_use_float(void *data)
{
(void)data;
return false;
}
audio_driver_t audio_audioio = {
audioio_init,
audioio_write,
audioio_stop,
audioio_start,
audioio_alive,
audioio_set_nonblock_state,
audioio_free,
audioio_use_float,
"audioio",
NULL,
NULL,
audioio_write_avail,
audioio_buffer_size,
};

View File

@ -1,470 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2014 - Chris Moeller
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#if TARGET_OS_IPHONE
#include <AudioToolbox/AudioToolbox.h>
#else
#include <CoreAudio/CoreAudio.h>
#endif
#include <CoreAudio/CoreAudioTypes.h>
#include <AudioUnit/AudioUnit.h>
#include <AudioUnit/AUComponent.h>
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <rthreads/rthreads.h>
#include <retro_endianness.h>
#include <string/stdstring.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct coreaudio
{
slock_t *lock;
scond_t *cond;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
ComponentInstance dev;
#else
AudioComponentInstance dev;
#endif
bool dev_alive;
bool is_paused;
fifo_buffer_t *buffer;
bool nonblock;
size_t buffer_size;
} coreaudio_t;
#if TARGET_OS_IOS
static bool g_interrupted;
#endif
static void coreaudio_free(void *data)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (!dev)
return;
if (dev->dev_alive)
{
AudioOutputUnitStop(dev->dev);
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
CloseComponent(dev->dev);
#else
AudioComponentInstanceDispose(dev->dev);
#endif
}
if (dev->buffer)
fifo_free(dev->buffer);
slock_free(dev->lock);
scond_free(dev->cond);
free(dev);
}
static OSStatus audio_write_cb(void *userdata,
AudioUnitRenderActionFlags *action_flags,
const AudioTimeStamp *time_stamp, UInt32 bus_number,
UInt32 number_frames, AudioBufferList *io_data)
{
unsigned write_avail;
void *outbuf = NULL;
coreaudio_t *dev = (coreaudio_t*)userdata;
(void)time_stamp;
(void)bus_number;
(void)number_frames;
if (!io_data || io_data->mNumberBuffers != 1)
return noErr;
write_avail = io_data->mBuffers[0].mDataByteSize;
outbuf = io_data->mBuffers[0].mData;
slock_lock(dev->lock);
if (fifo_read_avail(dev->buffer) < write_avail)
{
*action_flags = kAudioUnitRenderAction_OutputIsSilence;
/* Seems to be needed. */
memset(outbuf, 0, write_avail);
slock_unlock(dev->lock);
/* Technically possible to deadlock without. */
scond_signal(dev->cond);
return noErr;
}
fifo_read(dev->buffer, outbuf, write_avail);
slock_unlock(dev->lock);
scond_signal(dev->cond);
return noErr;
}
#if TARGET_OS_IPHONE
static void coreaudio_interrupt_listener(void *data, UInt32 interrupt_state)
{
(void)data;
#if TARGET_OS_IOS
g_interrupted = (interrupt_state == kAudioSessionBeginInterruption);
#endif
}
#else
static void choose_output_device(coreaudio_t *dev, const char* device)
{
unsigned i;
UInt32 deviceCount;
AudioObjectPropertyAddress propaddr;
AudioDeviceID *devices = NULL;
UInt32 size = 0;
propaddr.mSelector = kAudioHardwarePropertyDevices;
#if MAC_OS_X_VERSION_10_12
propaddr.mScope = kAudioObjectPropertyScopeOutput;
#else
propaddr.mScope = kAudioObjectPropertyScopeGlobal;
#endif
propaddr.mElement = kAudioObjectPropertyElementMaster;
if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
&propaddr, 0, 0, &size) != noErr)
return;
deviceCount = size / sizeof(AudioDeviceID);
devices = (AudioDeviceID*)malloc(size);
if (!devices || AudioObjectGetPropertyData(kAudioObjectSystemObject,
&propaddr, 0, 0, &size, devices) != noErr)
goto done;
#if MAC_OS_X_VERSION_10_12
#else
propaddr.mScope = kAudioDevicePropertyScopeOutput;
#endif
propaddr.mSelector = kAudioDevicePropertyDeviceName;
for (i = 0; i < deviceCount; i ++)
{
char device_name[1024];
device_name[0] = 0;
size = 1024;
if (AudioObjectGetPropertyData(devices[i],
&propaddr, 0, 0, &size, device_name) == noErr
&& string_is_equal(device_name, device))
{
AudioUnitSetProperty(dev->dev, kAudioOutputUnitProperty_CurrentDevice,
kAudioUnitScope_Global, 0, &devices[i], sizeof(AudioDeviceID));
goto done;
}
}
done:
free(devices);
}
#endif
static void *coreaudio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
size_t fifo_size;
UInt32 i_size;
AudioStreamBasicDescription real_desc;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
Component comp;
#else
AudioComponent comp;
#endif
#ifndef TARGET_OS_IPHONE
AudioChannelLayout layout = {0};
#endif
AURenderCallbackStruct cb = {0};
AudioStreamBasicDescription stream_desc = {0};
bool component_unavailable = false;
static bool session_initialized = false;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
ComponentDescription desc = {0};
#else
AudioComponentDescription desc = {0};
#endif
coreaudio_t *dev = (coreaudio_t*)
calloc(1, sizeof(*dev));
if (!dev)
return NULL;
(void)session_initialized;
(void)device;
dev->lock = slock_new();
dev->cond = scond_new();
#if TARGET_OS_IOS
if (!session_initialized)
{
session_initialized = true;
AudioSessionInitialize(0, 0, coreaudio_interrupt_listener, 0);
AudioSessionSetActive(true);
}
#endif
/* Create AudioComponent */
desc.componentType = kAudioUnitType_Output;
#if TARGET_OS_IPHONE
desc.componentSubType = kAudioUnitSubType_RemoteIO;
#else
desc.componentSubType = kAudioUnitSubType_HALOutput;
#endif
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
comp = FindNextComponent(NULL, &desc);
#else
comp = AudioComponentFindNext(NULL, &desc);
#endif
if (!comp)
goto error;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr);
#else
component_unavailable = (AudioComponentInstanceNew(comp, &dev->dev) != noErr);
#endif
if (component_unavailable)
goto error;
#if !TARGET_OS_IPHONE
if (device)
choose_output_device(dev, device);
#endif
dev->dev_alive = true;
/* Set audio format */
stream_desc.mSampleRate = rate;
stream_desc.mBitsPerChannel = sizeof(float) * CHAR_BIT;
stream_desc.mChannelsPerFrame = 2;
stream_desc.mBytesPerPacket = 2 * sizeof(float);
stream_desc.mBytesPerFrame = 2 * sizeof(float);
stream_desc.mFramesPerPacket = 1;
stream_desc.mFormatID = kAudioFormatLinearPCM;
stream_desc.mFormatFlags = kAudioFormatFlagIsFloat |
kAudioFormatFlagIsPacked | (is_little_endian() ?
0 : kAudioFormatFlagIsBigEndian);
if (AudioUnitSetProperty(dev->dev, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &stream_desc, sizeof(stream_desc)) != noErr)
goto error;
/* Check returned audio format. */
i_size = sizeof(real_desc);
if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat,
kAudioUnitScope_Input, 0, &real_desc, &i_size) != noErr)
goto error;
if (real_desc.mChannelsPerFrame != stream_desc.mChannelsPerFrame)
goto error;
if (real_desc.mBitsPerChannel != stream_desc.mBitsPerChannel)
goto error;
if (real_desc.mFormatFlags != stream_desc.mFormatFlags)
goto error;
if (real_desc.mFormatID != stream_desc.mFormatID)
goto error;
RARCH_LOG("[CoreAudio]: Using output sample rate of %.1f Hz\n",
(float)real_desc.mSampleRate);
*new_rate = real_desc.mSampleRate;
/* Set channel layout (fails on iOS). */
#ifndef TARGET_OS_IPHONE
layout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
if (AudioUnitSetProperty(dev->dev, kAudioUnitProperty_AudioChannelLayout,
kAudioUnitScope_Input, 0, &layout, sizeof(layout)) != noErr)
goto error;
#endif
/* Set callbacks and finish up. */
cb.inputProc = audio_write_cb;
cb.inputProcRefCon = dev;
if (AudioUnitSetProperty(dev->dev, kAudioUnitProperty_SetRenderCallback,
kAudioUnitScope_Input, 0, &cb, sizeof(cb)) != noErr)
goto error;
if (AudioUnitInitialize(dev->dev) != noErr)
goto error;
fifo_size = (latency * (*new_rate)) / 1000;
fifo_size *= 2 * sizeof(float);
dev->buffer_size = fifo_size;
dev->buffer = fifo_new(fifo_size);
if (!dev->buffer)
goto error;
RARCH_LOG("[CoreAudio]: Using buffer size of %u bytes: (latency = %u ms)\n",
(unsigned)fifo_size, latency);
if (AudioOutputUnitStart(dev->dev) != noErr)
goto error;
return dev;
error:
RARCH_ERR("[CoreAudio]: Failed to initialize driver ...\n");
coreaudio_free(dev);
return NULL;
}
static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
{
coreaudio_t *dev = (coreaudio_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
#if TARGET_OS_IOS
while (!g_interrupted && size > 0)
#else
while (size > 0)
#endif
{
size_t write_avail;
slock_lock(dev->lock);
write_avail = fifo_write_avail(dev->buffer);
if (write_avail > size)
write_avail = size;
fifo_write(dev->buffer, buf, write_avail);
buf += write_avail;
written += write_avail;
size -= write_avail;
if (dev->nonblock)
{
slock_unlock(dev->lock);
break;
}
#if TARGET_OS_IOS
if (write_avail == 0 && !scond_wait_timeout(
dev->cond, dev->lock, 3000000))
g_interrupted = true;
#else
if (write_avail == 0)
scond_wait(dev->cond, dev->lock);
#endif
slock_unlock(dev->lock);
}
return written;
}
static void coreaudio_set_nonblock_state(void *data, bool state)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (dev)
dev->nonblock = state;
}
static bool coreaudio_alive(void *data)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (!dev)
return false;
return !dev->is_paused;
}
static bool coreaudio_stop(void *data)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (!dev)
return false;
dev->is_paused = (AudioOutputUnitStop(dev->dev) == noErr) ? true : false;
return dev->is_paused ? true : false;
}
static bool coreaudio_start(void *data, bool is_shutdown)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (!dev)
return false;
dev->is_paused = (AudioOutputUnitStart(dev->dev) == noErr) ? false : true;
return dev->is_paused ? false : true;
}
static bool coreaudio_use_float(void *data)
{
(void)data;
return true;
}
static size_t coreaudio_write_avail(void *data)
{
size_t avail;
coreaudio_t *dev = (coreaudio_t*)data;
slock_lock(dev->lock);
avail = fifo_write_avail(dev->buffer);
slock_unlock(dev->lock);
return avail;
}
static size_t coreaudio_buffer_size(void *data)
{
coreaudio_t *dev = (coreaudio_t*)data;
return dev->buffer_size;
}
static void *coreaudio_device_list_new(void *data)
{
/* TODO/FIXME */
return NULL;
}
static void coreaudio_device_list_free(void *data, void *array_list_data)
{
/* TODO/FIXME */
}
audio_driver_t audio_coreaudio = {
coreaudio_init,
coreaudio_write,
coreaudio_stop,
coreaudio_start,
coreaudio_alive,
coreaudio_set_nonblock_state,
coreaudio_free,
coreaudio_use_float,
"coreaudio",
coreaudio_device_list_new,
coreaudio_device_list_free,
coreaudio_write_avail,
coreaudio_buffer_size,
};

View File

@ -1,392 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2019 - Stuart Carnie
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#import <Foundation/Foundation.h>
#import <AudioToolbox/AudioToolbox.h>
#import <AVFoundation/AVFoundation.h>
#include <stdio.h>
#include <stdatomic.h>
#include <stdlib.h>
#include <memory.h>
#include "../../retroarch.h"
#pragma mark - ringbuffer
typedef struct ringbuffer
{
float *buffer;
size_t cap;
atomic_int len;
size_t writePtr;
size_t readPtr;
} ringbuffer_t;
typedef ringbuffer_t * ringbuffer_h;
static inline size_t rb_len(ringbuffer_h r)
{
return atomic_load_explicit(&r->len, memory_order_relaxed);
}
static inline size_t rb_cap(ringbuffer_h r)
{
return (r->readPtr + r->cap - r->writePtr) % r->cap;
}
static inline size_t rb_avail(ringbuffer_h r)
{
return r->cap - rb_len(r);
}
static inline void rb_advance_write(ringbuffer_h r)
{
r->writePtr = (r->writePtr + 1) % r->cap;
}
static inline void rb_advance_write_n(ringbuffer_h r, size_t n)
{
r->writePtr = (r->writePtr + n) % r->cap;
}
static inline void rb_advance_read(ringbuffer_h r)
{
r->readPtr = (r->readPtr + 1) % r->cap;
}
static inline void rb_len_add(ringbuffer_h r, int n)
{
atomic_fetch_add(&r->len, n);
}
static inline void rb_len_sub(ringbuffer_h r, int n)
{
atomic_fetch_sub(&r->len, n);
}
static void rb_init(ringbuffer_h r, size_t cap)
{
r->buffer = malloc(cap * sizeof(float));
r->cap = cap;
atomic_init(&r->len, 0);
r->writePtr = 0;
r->readPtr = 0;
}
static void rb_free(ringbuffer_h r)
{
free(r->buffer);
memset(r, 0, sizeof(*r));
}
#define UNLIKELY(x) __builtin_expect((x), 0)
#define LIKELY(x) __builtin_expect((x), 1)
static void rb_write_data(ringbuffer_h r, const float *data, size_t len)
{
size_t avail = rb_avail(r);
size_t n = MIN(len, avail);
size_t first_write = n;
size_t rest_write = 0;
if (r->writePtr + n > r->cap)
{
first_write = r->cap - r->writePtr;
rest_write = n - first_write;
}
memcpy(r->buffer + r->writePtr, data, first_write*sizeof(float));
memcpy(r->buffer, data + first_write, rest_write*sizeof(float));
rb_advance_write_n(r, n);
rb_len_add(r, (int)n);
}
static void rb_read_data(ringbuffer_h r,
float *d0, float *d1, size_t len)
{
size_t need = len * 2;
do {
size_t have = rb_len(r);
size_t n = MIN(have, need);
int i = 0;
for (; i < n/2; i++)
{
d0[i] = r->buffer[r->readPtr];
rb_advance_read(r);
d1[i] = r->buffer[r->readPtr];
rb_advance_read(r);
}
need -= n;
rb_len_sub(r, (int)n);
if (UNLIKELY(need > 0))
{
const float quiet = 0.0f;
size_t fill;
/* we got more data */
if (rb_len(r) > 0)
continue;
/* underflow */
fill = (need/2)*sizeof(float);
memset_pattern4(&d0[i], &quiet, fill);
memset_pattern4(&d1[i], &quiet, fill);
}
} while (0);
}
#pragma mark - CoreAudio3
static bool g_interrupted;
@interface CoreAudio3 : NSObject {
ringbuffer_t _rb;
dispatch_semaphore_t _sema;
AUAudioUnit *_au;
size_t _bufferSize;
BOOL _nonBlock;
}
@property (nonatomic, readwrite) BOOL nonBlock;
@property (nonatomic, readonly) BOOL paused;
@property (nonatomic, readonly) size_t writeAvailableInBytes;
@property (nonatomic, readonly) size_t bufferSizeInBytes;
- (instancetype)initWithRate:(NSUInteger)rate
latency:(NSUInteger)latency;
- (ssize_t)writeFloat:(const float *)data samples:(size_t)samples;
- (void)start;
- (void)stop;
@end
@implementation CoreAudio3
- (instancetype)initWithRate:(NSUInteger)rate
latency:(NSUInteger)latency {
if (self = [super init])
{
NSError *err;
AUAudioUnit *au;
AudioComponentDescription desc;
AVAudioFormat *format, *renderFormat;
_sema = dispatch_semaphore_create(0);
_bufferSize = (latency * rate) / 1000;
_bufferSize *= 2; /* stereo */
rb_init(&_rb, _bufferSize);
desc.componentType = kAudioUnitType_Output;
desc.componentSubType = kAudioUnitSubType_DefaultOutput;
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
au = [[AUAudioUnit alloc] initWithComponentDescription:desc error:&err];
if (err != nil)
return nil;
format = au.outputBusses[0].format;
if (format.channelCount != 2)
return nil;
renderFormat = [[AVAudioFormat alloc] initStandardFormatWithSampleRate:rate channels:2];
[au.inputBusses[0] setFormat:renderFormat error:&err];
if (err != nil)
return nil;
ringbuffer_h rb = &_rb;
__block dispatch_semaphore_t sema = _sema;
au.outputProvider = ^AUAudioUnitStatus(AudioUnitRenderActionFlags * actionFlags, const AudioTimeStamp * timestamp, AUAudioFrameCount frameCount, NSInteger inputBusNumber, AudioBufferList * inputData)
{
rb_read_data(rb, inputData->mBuffers[0].mData, inputData->mBuffers[1].mData, frameCount);
dispatch_semaphore_signal(sema);
return 0;
};
[au allocateRenderResourcesAndReturnError:&err];
if (err != nil)
return nil;
_au = au;
RARCH_LOG("[CoreAudio3]: Using buffer size of %u bytes: (latency = %u ms)\n", (unsigned)self.bufferSizeInBytes, latency);
[self start];
}
return self;
}
- (void)dealloc {
rb_free(&_rb);
}
- (BOOL)paused {
return !_au.running;
}
- (size_t)bufferSizeInBytes {
return _bufferSize * sizeof(float);
}
- (size_t)writeAvailableInBytes {
return rb_avail(&_rb) * sizeof(float);
}
- (void)start {
NSError *err;
[_au startHardwareAndReturnError:&err];
}
- (void)stop {
[_au stopHardware];
}
- (ssize_t)writeFloat:(const float *)data samples:(size_t)samples {
size_t written = 0;
while (!g_interrupted && samples > 0)
{
size_t write_avail = rb_avail(&_rb);
if (write_avail > samples)
write_avail = samples;
rb_write_data(&_rb, data, write_avail);
data += write_avail;
written += write_avail;
samples -= write_avail;
if (_nonBlock)
break;
if (write_avail == 0)
dispatch_semaphore_wait(_sema, DISPATCH_TIME_FOREVER);
}
return written;
}
@end
static void coreaudio3_free(void *data)
{
CoreAudio3 *dev = (__bridge_transfer CoreAudio3 *)data;
if (dev == nil)
return;
[dev stop];
dev = nil;
}
static void *coreaudio3_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
CoreAudio3 *dev = [[CoreAudio3 alloc] initWithRate:rate
latency:latency];
*new_rate = rate;
return (__bridge_retained void *)dev;
}
static ssize_t coreaudio3_write(void *data,
const void *buf_, size_t size)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
return [dev writeFloat:(const float *)
buf_ samples:size/sizeof(float)] * sizeof(float);
}
static void coreaudio3_set_nonblock_state(void *data, bool state)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return;
dev.nonBlock = state;
}
static bool coreaudio3_alive(void *data)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return NO;
return !dev.paused;
}
static bool coreaudio3_stop(void *data)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return NO;
[dev stop];
return dev.paused;
}
static bool coreaudio3_start(void *data, bool is_shutdown)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return NO;
[dev start];
return !dev.paused;
}
static bool coreaudio3_use_float(void *data)
{
return YES;
}
static size_t coreaudio3_write_avail(void *data)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return 0;
return dev.writeAvailableInBytes;
}
static size_t coreaudio3_buffer_size(void *data)
{
CoreAudio3 *dev = (__bridge CoreAudio3 *)data;
if (dev == nil)
return 0;
return dev.bufferSizeInBytes;
}
audio_driver_t audio_coreaudio3 = {
coreaudio3_init,
coreaudio3_write,
coreaudio3_stop,
coreaudio3_start,
coreaudio3_alive,
coreaudio3_set_nonblock_state,
coreaudio3_free,
coreaudio3_use_float,
"coreaudio3",
NULL, /* device_list_new */
NULL, /* device_list_free */
coreaudio3_write_avail,
coreaudio3_buffer_size,
};

View File

@ -1,305 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <3ds.h>
#include <string.h>
#include <malloc.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include "../../retroarch.h"
typedef struct
{
bool nonblock;
bool playing;
int16_t* l;
int16_t* r;
uint32_t l_paddr;
uint32_t r_paddr;
uint32_t pos;
uint32_t playpos;
uint64_t cpu_ticks_last;
} ctr_csnd_audio_t;
#define CTR_CSND_AUDIO_COUNT (1u << 11u)
#define CTR_CSND_AUDIO_COUNT_MASK (CTR_CSND_AUDIO_COUNT - 1u)
#define CTR_CSND_AUDIO_SIZE (CTR_CSND_AUDIO_COUNT * sizeof(int16_t))
#define CTR_CSND_AUDIO_SIZE_MASK (CTR_CSND_AUDIO_SIZE - 1u)
#define CTR_CSND_AUDIO_RATE 32730
#define CTR_CSND_TICKS_PER_SAMPLE 2048
#define CTR_CSND_CPU_TICKS_PER_SAMPLE (CTR_CSND_TICKS_PER_SAMPLE * 4)
static void ctr_csnd_audio_update_playpos(ctr_csnd_audio_t* ctr)
{
uint64_t current_tick = svcGetSystemTick();
uint32_t samples_played = (current_tick - ctr->cpu_ticks_last)
/ CTR_CSND_CPU_TICKS_PER_SAMPLE;
ctr->playpos = (ctr->playpos + samples_played) & CTR_CSND_AUDIO_COUNT_MASK;
ctr->cpu_ticks_last += samples_played * CTR_CSND_CPU_TICKS_PER_SAMPLE;
}
Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan,
void* data0, void* data1, u32 size)
{
u32 paddr0 = 0;
u32 paddr1 = 0;
int encoding = (flags >> 12) & 3;
int loopMode = (flags >> 10) & 3;
if (!(csndChannels & BIT(chn)))
return 1;
if (!loopMode)
flags |= SOUND_ONE_SHOT;
if (encoding != CSND_ENCODING_PSG)
{
if (data0)
paddr0 = osConvertVirtToPhys(data0);
if (data1)
paddr1 = osConvertVirtToPhys(data1);
if (data0 && encoding == CSND_ENCODING_ADPCM)
{
int adpcmSample = ((s16*)data0)[-2];
int adpcmIndex = ((u8*)data0)[-2];
CSND_SetAdpcmState(chn, 0, adpcmSample, adpcmIndex);
}
}
flags &= ~0xFFFF001F;
flags |= SOUND_ENABLE | SOUND_CHANNEL(chn) | (CTR_CSND_TICKS_PER_SAMPLE << 16);
u32 volumes = CSND_VOL(vol, pan);
CSND_SetChnRegs(flags, paddr0, paddr1, size, volumes, volumes);
if (loopMode == CSND_LOOPMODE_NORMAL && paddr1 > paddr0)
{
/* Now that the first block is playing,
* configure the size of the subsequent blocks */
size -= paddr1 - paddr0;
CSND_SetBlock(chn, 1, paddr1, size);
}
return 0;
}
static void *ctr_csnd_audio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)calloc(1, sizeof(ctr_csnd_audio_t));
if (!ctr)
return NULL;
(void)device;
(void)rate;
(void)latency;
*new_rate = CTR_CSND_AUDIO_RATE;
ctr->l = linearAlloc(CTR_CSND_AUDIO_SIZE);
ctr->r = linearAlloc(CTR_CSND_AUDIO_SIZE);
memset(ctr->l, 0, CTR_CSND_AUDIO_SIZE);
memset(ctr->r, 0, CTR_CSND_AUDIO_SIZE);
ctr->l_paddr = osConvertVirtToPhys(ctr->l);
ctr->r_paddr = osConvertVirtToPhys(ctr->r);
ctr->pos = 0;
GSPGPU_FlushDataCache((void*)ctr->l_paddr, CTR_CSND_AUDIO_SIZE);
GSPGPU_FlushDataCache((void*)ctr->r_paddr, CTR_CSND_AUDIO_SIZE);
csndPlaySound_custom(0x8, SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL)| SOUND_FORMAT(CSND_ENCODING_PCM16),
1.0, -1.0, ctr->l, ctr->l, CTR_CSND_AUDIO_SIZE);
csndPlaySound_custom(0x9, SOUND_LOOPMODE(CSND_LOOPMODE_NORMAL)| SOUND_FORMAT(CSND_ENCODING_PCM16),
1.0, 1.0, ctr->r, ctr->r, CTR_CSND_AUDIO_SIZE);
csndExecCmds(true);
ctr->playpos = 0;
ctr->cpu_ticks_last = svcGetSystemTick();
ctr->playing = true;
return ctr;
}
static void ctr_csnd_audio_free(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
#if 0
csndExit();
#endif
CSND_SetPlayState(0x8, 0);
CSND_SetPlayState(0x9, 0);
csndExecCmds(false);
linearFree(ctr->l);
linearFree(ctr->r);
free(ctr);
}
static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
{
int i;
uint32_t samples_played = 0;
uint64_t current_tick = 0;
const uint16_t *src = buf;
ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)data;
(void)data;
(void)buf;
(void)samples_played;
(void)current_tick;
ctr_csnd_audio_update_playpos(ctr);
if((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) ||
(((ctr->pos - ctr->playpos ) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4)) ||
(((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (size >> 2)))
{
if (ctr->nonblock)
ctr->pos = (ctr->playpos + (CTR_CSND_AUDIO_COUNT >> 1)) & CTR_CSND_AUDIO_COUNT_MASK;
else
{
do{
/* todo: compute the correct sleep period */
retro_sleep(1);
ctr_csnd_audio_update_playpos(ctr);
}while (((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 1)
|| (((ctr->pos - ctr->playpos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 4)));
}
}
for (i = 0; i < (size >> 1); i += 2)
{
ctr->l[ctr->pos] = src[i];
ctr->r[ctr->pos] = src[i + 1];
ctr->pos++;
ctr->pos &= CTR_CSND_AUDIO_COUNT_MASK;
}
GSPGPU_FlushDataCache(ctr->l, CTR_CSND_AUDIO_SIZE);
GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE);
return size;
}
static bool ctr_csnd_audio_stop(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
/* using SetPlayState would make tracking the playback
* position more difficult */
#if 0
CSND_SetPlayState(0x8, 0);
CSND_SetPlayState(0x9, 0);
#endif
/* setting the channel volume to 0 seems to make it
* impossible to set it back to full volume later */
CSND_SetVol(0x8, 0x00000001, 0);
CSND_SetVol(0x9, 0x00010000, 0);
csndExecCmds(false);
ctr->playing = false;
return true;
}
static bool ctr_csnd_audio_alive(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
return ctr->playing;
}
static bool ctr_csnd_audio_start(void *data, bool is_shutdown)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (is_shutdown)
return true;
#if 0
CSND_SetPlayState(0x8, 1);
CSND_SetPlayState(0x9, 1);
#endif
CSND_SetVol(0x8, 0x00008000, 0);
CSND_SetVol(0x9, 0x80000000, 0);
csndExecCmds(false);
ctr->playing = true;
return true;
}
static void ctr_csnd_audio_set_nonblock_state(void *data, bool state)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
if (ctr)
ctr->nonblock = state;
}
static bool ctr_csnd_audio_use_float(void *data)
{
(void)data;
return false;
}
static size_t ctr_csnd_audio_write_avail(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
ctr_csnd_audio_update_playpos(ctr);
return (ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK;
}
static size_t ctr_csnd_audio_buffer_size(void *data)
{
(void)data;
return CTR_CSND_AUDIO_COUNT;
}
audio_driver_t audio_ctr_csnd = {
ctr_csnd_audio_init,
ctr_csnd_audio_write,
ctr_csnd_audio_stop,
ctr_csnd_audio_start,
ctr_csnd_audio_alive,
ctr_csnd_audio_set_nonblock_state,
ctr_csnd_audio_free,
ctr_csnd_audio_use_float,
"csnd",
NULL,
NULL,
ctr_csnd_audio_write_avail,
ctr_csnd_audio_buffer_size
};

View File

@ -1,212 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <3ds.h>
#include <string.h>
#include <malloc.h>
#include "../../retroarch.h"
#include "../../ctr/ctr_debug.h"
typedef struct
{
bool nonblock;
bool playing;
int channel;
ndspWaveBuf dsp_buf;
uint32_t pos;
} ctr_dsp_audio_t;
#define CTR_DSP_AUDIO_COUNT (1u << 11u)
#define CTR_DSP_AUDIO_COUNT_MASK (CTR_DSP_AUDIO_COUNT - 1u)
#define CTR_DSP_AUDIO_SIZE (CTR_DSP_AUDIO_COUNT * sizeof(int16_t) * 2)
#define CTR_DSP_AUDIO_SIZE_MASK (CTR_DSP_AUDIO_SIZE - 1u)
static void *ctr_dsp_audio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
ctr_dsp_audio_t *ctr = NULL;
(void)device;
(void)rate;
(void)latency;
if (ndspInit() < 0)
return NULL;
ctr = (ctr_dsp_audio_t*)calloc(1, sizeof(ctr_dsp_audio_t));
if (!ctr)
return NULL;
*new_rate = 32730;
ctr->channel = 0;
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
ndspSetClippingMode(NDSP_CLIP_SOFT); /* ?? */
ndspSetOutputCount(1);
ndspChnReset(ctr->channel);
ndspChnSetFormat(ctr->channel, NDSP_FORMAT_STEREO_PCM16);
ndspChnSetInterp(ctr->channel, NDSP_INTERP_NONE);
ndspChnSetRate(ctr->channel, 32728.0f);
ndspChnWaveBufClear(ctr->channel);
ctr->dsp_buf.data_pcm16 = linearAlloc(CTR_DSP_AUDIO_SIZE);
memset(ctr->dsp_buf.data_pcm16, 0, CTR_DSP_AUDIO_SIZE);
DSP_FlushDataCache(ctr->dsp_buf.data_pcm16, CTR_DSP_AUDIO_SIZE);
ctr->dsp_buf.looping = true;
ctr->dsp_buf.nsamples = CTR_DSP_AUDIO_COUNT;
ndspChnWaveBufAdd(ctr->channel, &ctr->dsp_buf);
ctr->pos = 0;
ctr->playing = true;
ndspSetMasterVol(1.0);
return ctr;
}
static void ctr_dsp_audio_free(void *data)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
ndspChnWaveBufClear(ctr->channel);
linearFree(ctr->dsp_buf.data_pcm16);
free(ctr);
ndspExit();
}
static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
{
u32 pos;
ctr_dsp_audio_t * ctr = (ctr_dsp_audio_t*)data;
uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel);
if((((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 2)) ||
(((ctr->pos - sample_pos ) & CTR_DSP_AUDIO_COUNT_MASK) < (CTR_DSP_AUDIO_COUNT >> 4)) ||
(((sample_pos - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK) < (size >> 2)))
{
if (ctr->nonblock)
ctr->pos = (sample_pos + (CTR_DSP_AUDIO_COUNT >> 1)) & CTR_DSP_AUDIO_COUNT_MASK;
else
{
do{
svcSleepThread(100000);
sample_pos = ndspChnGetSamplePos(ctr->channel);
}while (((sample_pos - (ctr->pos + (size >>2))) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1)
|| (((ctr->pos - (CTR_DSP_AUDIO_COUNT >> 4) - sample_pos) & CTR_DSP_AUDIO_COUNT_MASK) > (CTR_DSP_AUDIO_COUNT >> 1)));
}
}
pos = ctr->pos << 2;
if((pos + size) > CTR_DSP_AUDIO_SIZE)
{
memcpy(ctr->dsp_buf.data_pcm8 + pos, buf,
(CTR_DSP_AUDIO_SIZE - pos));
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, (CTR_DSP_AUDIO_SIZE - pos));
memcpy(ctr->dsp_buf.data_pcm8, (uint8_t*) buf + (CTR_DSP_AUDIO_SIZE - pos),
(pos + size - CTR_DSP_AUDIO_SIZE));
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8, (pos + size - CTR_DSP_AUDIO_SIZE));
}
else
{
memcpy(ctr->dsp_buf.data_pcm8 + pos, buf, size);
DSP_FlushDataCache(ctr->dsp_buf.data_pcm8 + pos, size);
}
ctr->pos += size >> 2;
ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK;
return size;
}
static bool ctr_dsp_audio_stop(void *data)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
ndspSetMasterVol(0.0);
ctr->playing = false;
return true;
}
static bool ctr_dsp_audio_alive(void *data)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
return ctr->playing;
}
static bool ctr_dsp_audio_start(void *data, bool is_shutdown)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (is_shutdown)
return true;
ndspSetMasterVol(1.0);
ctr->playing = true;
return true;
}
static void ctr_dsp_audio_set_nonblock_state(void *data, bool state)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
if (ctr)
ctr->nonblock = state;
}
static bool ctr_dsp_audio_use_float(void *data)
{
(void)data;
return false;
}
static size_t ctr_dsp_audio_write_avail(void *data)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
return (ndspChnGetSamplePos(ctr->channel) - ctr->pos) & CTR_DSP_AUDIO_COUNT_MASK;
}
static size_t ctr_dsp_audio_buffer_size(void *data)
{
(void)data;
return CTR_DSP_AUDIO_COUNT;
}
audio_driver_t audio_ctr_dsp = {
ctr_dsp_audio_init,
ctr_dsp_audio_write,
ctr_dsp_audio_stop,
ctr_dsp_audio_start,
ctr_dsp_audio_alive,
ctr_dsp_audio_set_nonblock_state,
ctr_dsp_audio_free,
ctr_dsp_audio_use_float,
"dsp",
NULL,
NULL,
ctr_dsp_audio_write_avail,
ctr_dsp_audio_buffer_size
};

View File

@ -1,617 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#ifndef _XBOX
#include <windows.h>
#include <mmsystem.h>
#include <mmreg.h>
#endif
#include <dsound.h>
#include <boolean.h>
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#ifdef HAVE_THREADS
#include <rthreads/rthreads.h>
#endif
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include <string/stdstring.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#ifdef _XBOX
#define DSERR_BUFFERLOST MAKE_DSHRESULT(150)
#define DSERR_INVALIDPARAM E_INVALIDARG
#define DSERR_PRIOLEVELNEEDED MAKE_DSHRESULT(70)
#endif
#if defined(_MSC_VER) && !defined(_XBOX)
#pragma comment(lib, "dsound")
#pragma comment(lib, "dxguid")
#endif
typedef struct dsound
{
LPDIRECTSOUND ds;
LPDIRECTSOUNDBUFFER dsb;
fifo_buffer_t *buffer;
CRITICAL_SECTION crit;
HANDLE event;
#ifdef HAVE_THREADS
sthread_t *thread;
#else
HANDLE thread;
#endif
unsigned buffer_size;
bool nonblock;
bool is_paused;
volatile bool thread_alive;
} dsound_t;
/* Forward declarations */
static void *dsound_list_new(void *u);
static INLINE unsigned write_avail(unsigned read_ptr,
unsigned write_ptr, unsigned buffer_size)
{
return (read_ptr + buffer_size - write_ptr) % buffer_size;
}
#define CHUNK_SIZE 256
struct audio_lock
{
void *chunk1;
void *chunk2;
DWORD size1;
DWORD size2;
};
static bool grab_region(dsound_t *ds, uint32_t write_ptr,
struct audio_lock *region, HRESULT res)
{
if (res == DSERR_BUFFERLOST)
{
#ifdef DEBUG
RARCH_WARN("[DirectSound error]: %s\n", "DSERR_BUFFERLOST");
#endif
if ((res = IDirectSoundBuffer_Restore(ds->dsb)) != DS_OK)
return false;
if ((res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
&region->chunk1, &region->size1, &region->chunk2, &region->size2, 0)) != DS_OK)
return false;
return true;
}
#ifdef DEBUG
switch (res)
{
case DSERR_INVALIDCALL:
RARCH_WARN("[DirectSound error]: %s\n", "DSERR_INVALIDCALL");
break;
case DSERR_INVALIDPARAM:
RARCH_WARN("[DirectSound error]: %s\n", "DSERR_INVALIDPARAM");
break;
case DSERR_PRIOLEVELNEEDED:
RARCH_WARN("[DirectSound error]: %s\n", "DSERR_PRIOLEVELNEEDED");
break;
default:
break;
}
#endif
return false;
}
#ifdef HAVE_THREADS
static void dsound_thread(void *data)
#else
static DWORD CALLBACK dsound_thread(PVOID data)
#endif
{
DWORD write_ptr;
dsound_t *ds = (dsound_t*)data;
SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_TIME_CRITICAL);
IDirectSoundBuffer_GetCurrentPosition(ds->dsb, NULL, &write_ptr);
write_ptr = (write_ptr + ds->buffer_size / 2) % ds->buffer_size;
while (ds->thread_alive)
{
HRESULT res;
bool is_pull = false;
struct audio_lock region;
DWORD read_ptr, avail, fifo_avail;
IDirectSoundBuffer_GetCurrentPosition(ds->dsb, &read_ptr, NULL);
avail = write_avail(read_ptr, write_ptr, ds->buffer_size);
EnterCriticalSection(&ds->crit);
fifo_avail = fifo_read_avail(ds->buffer);
LeaveCriticalSection(&ds->crit);
if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2)))
{
/* No space to write, or we don't have data in our fifo,
* but we can wait some time before it underruns ... */
/* We could opt for using the notification interface,
* but it is not guaranteed to work, so use high
* priority sleeping patterns.
*/
retro_sleep(1);
continue;
}
if ((res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
&region.chunk1, &region.size1, &region.chunk2, &region.size2, 0)) != DS_OK)
{
if (!grab_region(ds, write_ptr, &region, res))
{
ds->thread_alive = false;
SetEvent(ds->event);
break;
}
}
if (fifo_avail < CHUNK_SIZE)
{
/* Got space to write, but nothing in FIFO (underrun),
* fill block with silence. */
memset(region.chunk1, 0, region.size1);
memset(region.chunk2, 0, region.size2);
}
else
{
/* All is good. Pull from it and notify FIFO. */
EnterCriticalSection(&ds->crit);
if (region.chunk1)
fifo_read(ds->buffer, region.chunk1, region.size1);
if (region.chunk2)
fifo_read(ds->buffer, region.chunk2, region.size2);
LeaveCriticalSection(&ds->crit);
is_pull = true;
}
IDirectSoundBuffer_Unlock(ds->dsb, region.chunk1,
region.size1, region.chunk2, region.size2);
write_ptr = (write_ptr + region.size1 + region.size2)
% ds->buffer_size;
if (is_pull)
SetEvent(ds->event);
}
ExitThread(0);
}
static void dsound_stop_thread(dsound_t *ds)
{
if (!ds->thread)
return;
ds->thread_alive = false;
#ifdef HAVE_THREADS
sthread_join(ds->thread);
#else
WaitForSingleObject(ds->thread, INFINITE);
CloseHandle(ds->thread);
#endif
ds->thread = NULL;
}
static bool dsound_start_thread(dsound_t *ds)
{
if (!ds->thread)
{
ds->thread_alive = true;
#ifdef HAVE_THREADS
ds->thread = sthread_create(dsound_thread, ds);
#else
ds->thread = CreateThread(NULL, 0, dsound_thread, ds, 0, NULL);
#endif
if (!ds->thread)
return false;
}
return true;
}
static void dsound_clear_buffer(dsound_t *ds)
{
DWORD size;
void *ptr = NULL;
IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0);
if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &ptr, &size,
NULL, NULL, DSBLOCK_ENTIREBUFFER) == DS_OK)
{
memset(ptr, 0, size);
IDirectSoundBuffer_Unlock(ds->dsb, ptr, size, NULL, 0);
}
}
static void dsound_free(void *data)
{
dsound_t *ds = (dsound_t*)data;
if (!ds)
return;
if (ds->thread)
{
ds->thread_alive = false;
#ifdef HAVE_THREADS
sthread_join(ds->thread);
#else
WaitForSingleObject(ds->thread, INFINITE);
CloseHandle(ds->thread);
#endif
}
DeleteCriticalSection(&ds->crit);
if (ds->dsb)
{
IDirectSoundBuffer_Stop(ds->dsb);
IDirectSoundBuffer_Release(ds->dsb);
}
if (ds->ds)
IDirectSound_Release(ds->ds);
if (ds->event)
CloseHandle(ds->event);
if (ds->buffer)
fifo_free(ds->buffer);
free(ds);
}
static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOID context)
{
union string_list_elem_attr attr;
struct string_list *list = (struct string_list*)context;
attr.i = 0;
string_list_append(list, desc, attr);
if (guid)
{
unsigned i;
LPGUID guid_copy = (LPGUID)malloc(sizeof(GUID) * 1);
guid_copy->Data1 = guid->Data1;
guid_copy->Data2 = guid->Data2;
guid_copy->Data3 = guid->Data3;
for (i = 0; i < 8; i++)
guid_copy->Data4[i] = guid->Data4[i];
list->elems[list->size-1].userdata = guid_copy;
}
return TRUE;
}
static void dsound_set_wavefmt(WAVEFORMATEX *wfx,
unsigned channels, unsigned samplerate)
{
wfx->wFormatTag = WAVE_FORMAT_PCM;
wfx->nBlockAlign = channels * sizeof(int16_t);
wfx->wBitsPerSample = 16;
wfx->nChannels = channels;
wfx->nSamplesPerSec = samplerate;
wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign;
wfx->cbSize = 0;
}
static void *dsound_init(const char *dev, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
LPGUID selected_device = NULL;
WAVEFORMATEX wfx = {0};
DSBUFFERDESC bufdesc = {0};
int32_t idx_found = -1;
struct string_list *list = (struct string_list*)dsound_list_new(NULL);
dsound_t *ds = (dsound_t*)calloc(1, sizeof(*ds));
if (!ds)
goto error;
InitializeCriticalSection(&ds->crit);
if (dev)
{
/* Search for device name first */
if (list && list->elems)
{
if (list->elems)
{
unsigned i;
for (i = 0; i < list->size; i++)
{
if (string_is_equal(dev, list->elems[i].data))
{
idx_found = i;
selected_device = (LPGUID)list->elems[idx_found].userdata;
break;
}
}
/* Index was not found yet based on name string,
* just assume id is a one-character number index. */
if (idx_found == -1 && isdigit(dev[0]))
{
idx_found = strtoul(dev, NULL, 0);
RARCH_LOG("[DirectSound]: Fallback, device index is a single number index instead: %d.\n", idx_found);
if (idx_found != -1)
{
if (idx_found < (int32_t)list->size)
{
RARCH_LOG("[DirectSound]: Corresponding name: %s\n", list->elems[idx_found].data);
selected_device = (LPGUID)list->elems[idx_found].userdata;
}
}
}
}
}
}
if (DirectSoundCreate(selected_device, &ds->ds, NULL) != DS_OK)
goto error;
#ifndef _XBOX
if (IDirectSound_SetCooperativeLevel(ds->ds, GetDesktopWindow(), DSSCL_PRIORITY) != DS_OK)
goto error;
#endif
dsound_set_wavefmt(&wfx, 2, rate);
ds->buffer_size = (latency * wfx.nAvgBytesPerSec) / 1000;
ds->buffer_size /= CHUNK_SIZE;
ds->buffer_size *= CHUNK_SIZE;
if (ds->buffer_size < 4 * CHUNK_SIZE)
ds->buffer_size = 4 * CHUNK_SIZE;
RARCH_LOG("[DirectSound]: Setting buffer size of %u bytes\n", ds->buffer_size);
RARCH_LOG("[DirectSound]: Latency = %u ms\n", (unsigned)((1000 * ds->buffer_size) / wfx.nAvgBytesPerSec));
bufdesc.dwSize = sizeof(DSBUFFERDESC);
bufdesc.dwFlags = 0;
#ifndef _XBOX
bufdesc.dwFlags = DSBCAPS_GETCURRENTPOSITION2 | DSBCAPS_GLOBALFOCUS;
#endif
bufdesc.dwBufferBytes = ds->buffer_size;
bufdesc.lpwfxFormat = &wfx;
ds->event = CreateEvent(NULL, false, false, NULL);
if (!ds->event)
goto error;
ds->buffer = fifo_new(4 * 1024);
if (!ds->buffer)
goto error;
if (IDirectSound_CreateSoundBuffer(ds->ds, &bufdesc, &ds->dsb, 0) != DS_OK)
goto error;
IDirectSoundBuffer_SetVolume(ds->dsb, DSBVOLUME_MAX);
IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0);
dsound_clear_buffer(ds);
if (IDirectSoundBuffer_Play(ds->dsb, 0, 0, DSBPLAY_LOOPING) != DS_OK)
goto error;
if (!dsound_start_thread(ds))
goto error;
string_list_free(list);
return ds;
error:
RARCH_ERR("[DirectSound] Error occurred in init.\n");
if (list)
string_list_free(list);
dsound_free(ds);
return NULL;
}
static bool dsound_stop(void *data)
{
dsound_t *ds = (dsound_t*)data;
dsound_stop_thread(ds);
ds->is_paused = (IDirectSoundBuffer_Stop(ds->dsb) == DS_OK) ? true : false;
return (ds->is_paused) ? true : false;
}
static bool dsound_start(void *data, bool is_shutdown)
{
dsound_t *ds = (dsound_t*)data;
dsound_clear_buffer(ds);
if (!dsound_start_thread(ds))
return false;
ds->is_paused = (IDirectSoundBuffer_Play(
ds->dsb, 0, 0, DSBPLAY_LOOPING) == DS_OK) ? false : true;
return (ds->is_paused) ? false : true;
}
static bool dsound_alive(void *data)
{
dsound_t *ds = (dsound_t*)data;
if (!ds)
return false;
return !ds->is_paused;
}
static void dsound_set_nonblock_state(void *data, bool state)
{
dsound_t *ds = (dsound_t*)data;
if (ds)
ds->nonblock = state;
}
static ssize_t dsound_write(void *data, const void *buf_, size_t size)
{
size_t written = 0;
dsound_t *ds = (dsound_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
if (!ds->thread_alive)
return -1;
if (ds->nonblock)
{
if (size > 0)
{
size_t avail;
EnterCriticalSection(&ds->crit);
avail = fifo_write_avail(ds->buffer);
if (avail > size)
avail = size;
fifo_write(ds->buffer, buf, avail);
LeaveCriticalSection(&ds->crit);
buf += avail;
size -= avail;
written += avail;
}
}
else
{
while (size > 0)
{
size_t avail;
EnterCriticalSection(&ds->crit);
avail = fifo_write_avail(ds->buffer);
if (avail > size)
avail = size;
fifo_write(ds->buffer, buf, avail);
LeaveCriticalSection(&ds->crit);
buf += avail;
size -= avail;
written += avail;
if (!ds->thread_alive)
break;
if (avail == 0)
WaitForSingleObject(ds->event, INFINITE);
}
}
return written;
}
static size_t dsound_write_avail(void *data)
{
size_t avail;
dsound_t *ds = (dsound_t*)data;
EnterCriticalSection(&ds->crit);
avail = fifo_write_avail(ds->buffer);
LeaveCriticalSection(&ds->crit);
return avail;
}
static size_t dsound_buffer_size(void *data)
{
return 4 * 1024;
}
static bool dsound_use_float(void *data)
{
(void)data;
return false;
}
static void *dsound_list_new(void *u)
{
struct string_list *sl = string_list_new();
if (!sl)
return NULL;
#ifndef _XBOX
#ifdef UNICODE
DirectSoundEnumerate((LPDSENUMCALLBACKW)enumerate_cb, sl);
#else
DirectSoundEnumerate((LPDSENUMCALLBACKA)enumerate_cb, sl);
#endif
#endif
return sl;
}
static void dsound_device_list_free(void *u, void *slp)
{
struct string_list *sl = (struct string_list*)slp;
if (sl)
string_list_free(sl);
}
audio_driver_t audio_dsound = {
dsound_init,
dsound_write,
dsound_stop,
dsound_start,
dsound_alive,
dsound_set_nonblock_state,
dsound_free,
dsound_use_float,
"dsound",
dsound_list_new,
dsound_device_list_free,
dsound_write_avail,
dsound_buffer_size,
};

View File

@ -1,239 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#ifdef GEKKO
#include <gccore.h>
#include <ogcsys.h>
#else
#include <cafe/ai.h>
#endif
#include <boolean.h>
#include <retro_inline.h>
#include "../../retroarch.h"
#include "../../defines/gx_defines.h"
typedef struct
{
uint32_t data[BLOCKS][CHUNK_FRAMES];
volatile unsigned dma_busy;
volatile unsigned dma_next;
volatile unsigned dma_write;
size_t write_ptr;
bool nonblock;
bool is_paused;
} gx_audio_t;
static volatile gx_audio_t *gx_audio_data = NULL;
static volatile bool stop_audio = false;
static void dma_callback(void)
{
gx_audio_t *wa = (gx_audio_t*)gx_audio_data;
if (stop_audio)
return;
/* Erase last chunk to avoid repeating audio. */
memset(wa->data[wa->dma_busy], 0, CHUNK_SIZE);
wa->dma_busy = wa->dma_next;
wa->dma_next = (wa->dma_next + 1) & (BLOCKS - 1);
DCFlushRange(wa->data[wa->dma_next], CHUNK_SIZE);
AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE);
}
static void *gx_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
gx_audio_t *wa = (gx_audio_t*)memalign(32, sizeof(*wa));
if (!wa)
return NULL;
gx_audio_data = (gx_audio_t*)wa;
memset(wa, 0, sizeof(*wa));
AIInit(NULL);
AIRegisterDMACallback(dma_callback);
//ranges 0-32000 (default low) and 40000-47999 (in settings going down from 48000) -> set to 32000 hz
if (rate <= 32000 || (rate >= 40000 && rate < 48000))
{
AISetDSPSampleRate(AI_SAMPLERATE_32KHZ);
*new_rate = 32000;
}
else //ranges 32001-39999 (in settings going up from 32000) and 48000-max (default high) -> set to 48000 hz
{
AISetDSPSampleRate(AI_SAMPLERATE_48KHZ);
*new_rate = 48000;
}
wa->dma_write = BLOCKS - 1;
DCFlushRange(wa->data, sizeof(wa->data));
stop_audio = false;
AIInitDMA((uint32_t)wa->data[wa->dma_next], CHUNK_SIZE);
AIStartDMA();
return wa;
}
/* Wii uses silly R, L, R, L interleaving. */
static INLINE void copy_swapped(uint32_t * restrict dst,
const uint32_t * restrict src, size_t size)
{
do
{
uint32_t s = *src++;
*dst++ = (s >> 16) | (s << 16);
}while(--size);
}
static ssize_t gx_audio_write(void *data, const void *buf_, size_t size)
{
size_t frames = size >> 2;
const uint32_t *buf = buf_;
gx_audio_t *wa = data;
while (frames)
{
size_t to_write = CHUNK_FRAMES - wa->write_ptr;
if (frames < to_write)
to_write = frames;
/* FIXME: Nonblocking audio should break out of loop
* when it has nothing to write. */
while ((wa->dma_write == wa->dma_next ||
wa->dma_write == wa->dma_busy) && !wa->nonblock);
copy_swapped(wa->data[wa->dma_write] + wa->write_ptr, buf, to_write);
wa->write_ptr += to_write;
frames -= to_write;
buf += to_write;
if (wa->write_ptr >= CHUNK_FRAMES)
{
wa->write_ptr -= CHUNK_FRAMES;
wa->dma_write = (wa->dma_write + 1) & (BLOCKS - 1);
}
}
return size;
}
static bool gx_audio_stop(void *data)
{
gx_audio_t *wa = (gx_audio_t*)data;
if (!wa)
return false;
AIStopDMA();
memset(wa->data, 0, sizeof(wa->data));
DCFlushRange(wa->data, sizeof(wa->data));
wa->is_paused = true;
return true;
}
static void gx_audio_set_nonblock_state(void *data, bool state)
{
gx_audio_t *wa = (gx_audio_t*)data;
if (wa)
wa->nonblock = state;
}
static bool gx_audio_start(void *data, bool is_shutdown)
{
gx_audio_t *wa = (gx_audio_t*)data;
if (!wa)
return false;
AIStartDMA();
wa->is_paused = false;
return true;
}
static bool gx_audio_alive(void *data)
{
gx_audio_t *wa = (gx_audio_t*)data;
if (!wa)
return false;
return !wa->is_paused;
}
static void gx_audio_free(void *data)
{
gx_audio_t *wa = (gx_audio_t*)data;
if (!wa)
return;
stop_audio = true;
AIStopDMA();
AIRegisterDMACallback(NULL);
free(data);
}
static size_t gx_audio_write_avail(void *data)
{
gx_audio_t *wa = (gx_audio_t*)data;
return ((wa->dma_busy - wa->dma_write + BLOCKS)
& (BLOCKS - 1)) * CHUNK_SIZE;
}
static size_t gx_audio_buffer_size(void *data)
{
(void)data;
return BLOCKS * CHUNK_SIZE;
}
static bool gx_audio_use_float(void *data)
{
/* TODO/FIXME - verify */
(void)data;
return false;
}
audio_driver_t audio_gx = {
gx_audio_init,
gx_audio_write,
gx_audio_stop,
gx_audio_start,
gx_audio_alive,
gx_audio_set_nonblock_state,
gx_audio_free,
gx_audio_use_float,
"gx",
NULL,
NULL,
gx_audio_write_avail,
gx_audio_buffer_size,
};

View File

@ -1,389 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <jack/jack.h>
#include <jack/types.h>
#include <jack/ringbuffer.h>
#include <boolean.h>
#include <rthreads/rthreads.h>
#include "../../configuration.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#define FRAMES(x) (x / (sizeof(float) * 2))
typedef struct jack
{
jack_client_t *client;
jack_port_t *ports[2];
jack_ringbuffer_t *buffer[2];
volatile bool shutdown;
bool nonblock;
bool is_paused;
#ifdef HAVE_THREADS
scond_t *cond;
slock_t *cond_lock;
#endif
size_t buffer_size;
} jack_t;
static int process_cb(jack_nframes_t nframes, void *data)
{
int i;
jack_nframes_t avail[2], min_avail;
jack_t *jd = (jack_t*)data;
if (nframes <= 0)
{
#ifdef HAVE_THREADS
scond_signal(jd->cond);
#endif
return 0;
}
avail[0] = jack_ringbuffer_read_space(jd->buffer[0]);
avail[1] = jack_ringbuffer_read_space(jd->buffer[1]);
min_avail = ((avail[0] < avail[1]) ? avail[0] : avail[1]) / sizeof(jack_default_audio_sample_t);
if (min_avail > nframes)
min_avail = nframes;
for (i = 0; i < 2; i++)
{
jack_nframes_t f;
jack_default_audio_sample_t *out = (jack_default_audio_sample_t*)jack_port_get_buffer(jd->ports[i], nframes);
jack_ringbuffer_read(jd->buffer[i], (char*)out, min_avail * sizeof(jack_default_audio_sample_t));
for (f = min_avail; f < nframes; f++)
out[f] = 0.0f;
}
#ifdef HAVE_THREADS
scond_signal(jd->cond);
#endif
return 0;
}
static void shutdown_cb(void *data)
{
jack_t *jd = (jack_t*)data;
if (!jd)
return;
jd->shutdown = true;
#ifdef HAVE_THREADS
scond_signal(jd->cond);
#endif
}
static int parse_ports(char **dest_ports, const char **jports)
{
int i;
char *save = NULL;
int parsed = 0;
settings_t *settings = config_get_ptr();
char *audio_device_cpy = strdup(settings->arrays.audio_device);
const char *con = strtok_r(audio_device_cpy, ",", &save);
if (con)
dest_ports[parsed++] = strdup(con);
con = strtok_r(NULL, ",", &save);
if (con)
dest_ports[parsed++] = strdup(con);
for (i = parsed; i < 2; i++)
dest_ports[i] = strdup(jports[i]);
free(audio_device_cpy);
return 2;
}
static size_t find_buffersize(jack_t *jd, int latency, unsigned out_rate)
{
jack_latency_range_t range;
int i, buffer_frames, min_buffer_frames;
int jack_latency = 0;
int frames = latency * out_rate / 1000;
for (i = 0; i < 2; i++)
{
jack_port_get_latency_range(jd->ports[i], JackPlaybackLatency, &range);
if ((int)range.max > jack_latency)
jack_latency = range.max;
}
RARCH_LOG("[JACK]: Jack latency is %d frames.\n", jack_latency);
buffer_frames = frames - jack_latency;
min_buffer_frames = jack_get_buffer_size(jd->client) * 2;
RARCH_LOG("[JACK]: Minimum buffer size is %d frames.\n", min_buffer_frames);
if (buffer_frames < min_buffer_frames)
buffer_frames = min_buffer_frames;
return buffer_frames * sizeof(jack_default_audio_sample_t);
}
static void *ja_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
int i;
char *dest_ports[2];
const char **jports = NULL;
size_t bufsize = 0;
int parsed = 0;
jack_t *jd = (jack_t*)calloc(1, sizeof(jack_t));
if (!jd)
return NULL;
#ifdef HAVE_THREADS
jd->cond = scond_new();
jd->cond_lock = slock_new();
#endif
jd->client = jack_client_open("RetroArch", JackNullOption, NULL);
if (!jd->client)
goto error;
*new_rate = jack_get_sample_rate(jd->client);
jack_set_process_callback(jd->client, process_cb, jd);
jack_on_shutdown(jd->client, shutdown_cb, jd);
jd->ports[0] = jack_port_register(jd->client, "left", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
jd->ports[1] = jack_port_register(jd->client, "right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
if (!jd->ports[0] || !jd->ports[1])
{
RARCH_ERR("[JACK]: Failed to register ports.\n");
goto error;
}
jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput);
if (!jports)
{
RARCH_ERR("[JACK]: Failed to get ports.\n");
goto error;
}
bufsize = find_buffersize(jd, latency, *new_rate);
jd->buffer_size = bufsize;
RARCH_LOG("[JACK]: Internal buffer size: %d frames.\n", (int)(bufsize / sizeof(jack_default_audio_sample_t)));
for (i = 0; i < 2; i++)
{
jd->buffer[i] = jack_ringbuffer_create(bufsize);
if (!jd->buffer[i])
{
RARCH_ERR("[JACK]: Failed to create buffers.\n");
goto error;
}
}
parsed = parse_ports(dest_ports, jports);
if (jack_activate(jd->client) < 0)
{
RARCH_ERR("[JACK]: Failed to activate Jack...\n");
goto error;
}
for (i = 0; i < 2; i++)
{
if (jack_connect(jd->client, jack_port_name(jd->ports[i]), dest_ports[i]))
{
RARCH_ERR("[JACK]: Failed to connect to Jack port.\n");
goto error;
}
}
for (i = 0; i < parsed; i++)
free(dest_ports[i]);
jack_free(jports);
return jd;
error:
for (i = 0; i < parsed; i++)
free(dest_ports[i]);
if (jports)
jack_free(jports);
free(jd);
return NULL;
}
static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
{
int i;
size_t j, written = 0;
jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO];
size_t frames = FRAMES(size);
/* Avoid buffer overflow if a DSP plugin generated a huge number of frames. */
if (frames > AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO)
frames = AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO;
for (i = 0; i < 2; i++)
for (j = 0; j < frames; j++)
out_deinterleaved_buffer[i][j] = buf[j * 2 + i];
while (written < frames)
{
size_t avail[2], min_avail, write_frames;
if (jd->shutdown)
return 0;
avail[0] = jack_ringbuffer_write_space(jd->buffer[0]);
avail[1] = jack_ringbuffer_write_space(jd->buffer[1]);
min_avail = avail[0] < avail[1] ? avail[0] : avail[1];
min_avail /= sizeof(float);
write_frames = frames - written > min_avail ? min_avail : frames - written;
if (write_frames > 0)
{
for (i = 0; i < 2; i++)
{
jack_ringbuffer_write(jd->buffer[i], (const char*)&out_deinterleaved_buffer[i][written],
write_frames * sizeof(jack_default_audio_sample_t));
}
written += write_frames;
}
#ifdef HAVE_THREADS
else
{
slock_lock(jd->cond_lock);
scond_wait(jd->cond, jd->cond_lock);
slock_unlock(jd->cond_lock);
}
#endif
if (jd->nonblock)
break;
}
return written * sizeof(float) * 2;
}
static ssize_t ja_write(void *data, const void *buf, size_t size)
{
jack_t *jd = (jack_t*)data;
return write_buffer(jd, (const float*)buf, size);
}
static bool ja_stop(void *data)
{
jack_t *jd = (jack_t*)data;
if (jd)
jd->is_paused = true;
return true;
}
static bool ja_alive(void *data)
{
jack_t *jd = (jack_t*)data;
if (!jd)
return false;
return !jd->is_paused;
}
static void ja_set_nonblock_state(void *data, bool state)
{
jack_t *jd = (jack_t*)data;
if (jd)
jd->nonblock = state;
}
static bool ja_start(void *data, bool is_shutdown)
{
jack_t *jd = (jack_t*)data;
if (jd)
jd->is_paused = false;
return true;
}
static void ja_free(void *data)
{
int i;
jack_t *jd = (jack_t*)data;
jd->shutdown = true;
if (jd->client)
{
jack_deactivate(jd->client);
jack_client_close(jd->client);
}
for (i = 0; i < 2; i++)
if (jd->buffer[i])
jack_ringbuffer_free(jd->buffer[i]);
#ifdef HAVE_THREADS
if (jd->cond_lock)
slock_free(jd->cond_lock);
if (jd->cond)
scond_free(jd->cond);
#endif
free(jd);
}
static bool ja_use_float(void *data)
{
(void)data;
return true;
}
static size_t ja_write_avail(void *data)
{
jack_t *jd = (jack_t*)data;
return jack_ringbuffer_write_space(jd->buffer[0]);
}
static size_t ja_buffer_size(void *data)
{
jack_t *jd = (jack_t*)data;
return jd->buffer_size;
}
audio_driver_t audio_jack = {
ja_init,
ja_write,
ja_stop,
ja_start,
ja_alive,
ja_set_nonblock_state,
ja_free,
ja_use_float,
"jack",
NULL,
NULL,
ja_write_avail,
ja_buffer_size,
};

View File

@ -1,280 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
#ifdef __APPLE__
#include <OpenAL/al.h>
#include <OpenAL/alc.h>
#else
#include <AL/al.h>
#include <AL/alc.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#define BUFSIZE 1024
typedef struct al
{
ALuint source;
ALuint *buffers;
ALuint *res_buf;
size_t res_ptr;
ALenum format;
size_t num_buffers;
int rate;
uint8_t tmpbuf[BUFSIZE];
size_t tmpbuf_ptr;
ALCdevice *handle;
ALCcontext *ctx;
bool nonblock;
bool is_paused;
} al_t;
static void al_free(void *data)
{
al_t *al = (al_t*)data;
if (!al)
return;
alSourceStop(al->source);
alDeleteSources(1, &al->source);
if (al->buffers)
alDeleteBuffers(al->num_buffers, al->buffers);
free(al->buffers);
free(al->res_buf);
alcMakeContextCurrent(NULL);
if (al->ctx)
alcDestroyContext(al->ctx);
if (al->handle)
alcCloseDevice(al->handle);
free(al);
}
static void *al_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
al_t *al;
(void)device;
al = (al_t*)calloc(1, sizeof(al_t));
if (!al)
return NULL;
al->handle = alcOpenDevice(NULL);
if (!al->handle)
goto error;
al->ctx = alcCreateContext(al->handle, NULL);
if (!al->ctx)
goto error;
alcMakeContextCurrent(al->ctx);
al->rate = rate;
/* We already use one buffer for tmpbuf. */
al->num_buffers = (latency * rate * 2 * sizeof(int16_t)) / (1000 * BUFSIZE) - 1;
if (al->num_buffers < 2)
al->num_buffers = 2;
RARCH_LOG("[OpenAL]: Using %u buffers of %u bytes.\n", (unsigned)al->num_buffers, BUFSIZE);
al->buffers = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
al->res_buf = (ALuint*)calloc(al->num_buffers, sizeof(ALuint));
if (!al->buffers || !al->res_buf)
goto error;
alGenSources(1, &al->source);
alGenBuffers(al->num_buffers, al->buffers);
memcpy(al->res_buf, al->buffers, al->num_buffers * sizeof(ALuint));
al->res_ptr = al->num_buffers;
return al;
error:
al_free(al);
return NULL;
}
static bool al_unqueue_buffers(al_t *al)
{
ALint val;
alGetSourcei(al->source, AL_BUFFERS_PROCESSED, &val);
if (val <= 0)
return false;
alSourceUnqueueBuffers(al->source, val, &al->res_buf[al->res_ptr]);
al->res_ptr += val;
return true;
}
static bool al_get_buffer(al_t *al, ALuint *buffer)
{
if (!al->res_ptr)
{
for (;;)
{
if (al_unqueue_buffers(al))
break;
if (al->nonblock)
return false;
/* Must sleep as there is no proper blocking method. */
retro_sleep(1);
}
}
*buffer = al->res_buf[--al->res_ptr];
return true;
}
static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
{
size_t read_size = MIN(BUFSIZE - al->tmpbuf_ptr, size);
memcpy(al->tmpbuf + al->tmpbuf_ptr, buf, read_size);
al->tmpbuf_ptr += read_size;
return read_size;
}
static ssize_t al_write(void *data, const void *buf_, size_t size)
{
al_t *al = (al_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
while (size)
{
ALint val;
ALuint buffer;
size_t rc = al_fill_internal_buf(al, buf, size);
written += rc;
buf += rc;
size -= rc;
if (al->tmpbuf_ptr != BUFSIZE)
break;
if (!al_get_buffer(al, &buffer))
break;
alBufferData(buffer, AL_FORMAT_STEREO16, al->tmpbuf, BUFSIZE, al->rate);
al->tmpbuf_ptr = 0;
alSourceQueueBuffers(al->source, 1, &buffer);
if (alGetError() != AL_NO_ERROR)
return -1;
alGetSourcei(al->source, AL_SOURCE_STATE, &val);
if (val != AL_PLAYING)
alSourcePlay(al->source);
if (alGetError() != AL_NO_ERROR)
return -1;
}
return written;
}
static bool al_stop(void *data)
{
al_t *al = (al_t*)data;
if (al)
al->is_paused = true;
return true;
}
static bool al_alive(void *data)
{
al_t *al = (al_t*)data;
if (!al)
return false;
return !al->is_paused;
}
static void al_set_nonblock_state(void *data, bool state)
{
al_t *al = (al_t*)data;
if (al)
al->nonblock = state;
}
static bool al_start(void *data, bool is_shutdown)
{
al_t *al = (al_t*)data;
if (al)
al->is_paused = false;
return true;
}
static size_t al_write_avail(void *data)
{
al_t *al = (al_t*)data;
al_unqueue_buffers(al);
return al->res_ptr * BUFSIZE + (BUFSIZE - al->tmpbuf_ptr);
}
static size_t al_buffer_size(void *data)
{
al_t *al = (al_t*)data;
return (al->num_buffers + 1) * BUFSIZE; /* Also got tmpbuf. */
}
static bool al_use_float(void *data)
{
(void)data;
return false;
}
audio_driver_t audio_openal = {
al_init,
al_write,
al_stop,
al_start,
al_alive,
al_set_nonblock_state,
al_free,
al_use_float,
"openal",
NULL,
NULL,
al_write_avail,
al_buffer_size,
};

View File

@ -1,320 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <SLES/OpenSLES.h>
#ifdef ANDROID
#include <SLES/OpenSLES_Android.h>
#endif
#include <rthreads/rthreads.h>
#include "../../retroarch.h"
/* Helper macros, COM-style. */
#define SLObjectItf_Realize(a, ...) ((*(a))->Realize(a, __VA_ARGS__))
#define SLObjectItf_GetInterface(a, ...) ((*(a))->GetInterface(a, __VA_ARGS__))
#define SLObjectItf_Destroy(a) ((*(a))->Destroy((a)))
#define SLEngineItf_CreateOutputMix(a, ...) ((*(a))->CreateOutputMix(a, __VA_ARGS__))
#define SLEngineItf_CreateAudioPlayer(a, ...) ((*(a))->CreateAudioPlayer(a, __VA_ARGS__))
#define SLPlayItf_SetPlayState(a, ...) ((*(a))->SetPlayState(a, __VA_ARGS__))
typedef struct sl
{
uint8_t **buffer;
uint8_t *buffer_chunk;
unsigned buffer_index;
unsigned buffer_ptr;
volatile unsigned buffered_blocks;
SLObjectItf engine_object;
SLEngineItf engine;
SLObjectItf output_mix;
SLObjectItf buffer_queue_object;
SLAndroidSimpleBufferQueueItf buffer_queue;
SLPlayItf player;
slock_t *lock;
scond_t *cond;
bool nonblock;
bool is_paused;
unsigned buf_size;
unsigned buf_count;
} sl_t;
static void opensl_callback(SLAndroidSimpleBufferQueueItf bq, void *ctx)
{
sl_t *sl = (sl_t*)ctx;
__sync_fetch_and_sub(&sl->buffered_blocks, 1);
scond_signal(sl->cond);
}
#define GOTO_IF_FAIL(x) do { \
if ((res = (x)) != SL_RESULT_SUCCESS) \
goto error; \
} while(0)
static void sl_free(void *data)
{
sl_t *sl = (sl_t*)data;
if (!sl)
return;
if (sl->player)
SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED);
if (sl->buffer_queue_object)
SLObjectItf_Destroy(sl->buffer_queue_object);
if (sl->output_mix)
SLObjectItf_Destroy(sl->output_mix);
if (sl->engine_object)
SLObjectItf_Destroy(sl->engine_object);
if (sl->lock)
slock_free(sl->lock);
if (sl->cond)
scond_free(sl->cond);
free(sl->buffer);
free(sl->buffer_chunk);
free(sl);
}
static void *sl_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
unsigned i;
SLDataFormat_PCM fmt_pcm = {0};
SLDataSource audio_src = {0};
SLDataSink audio_sink = {0};
SLDataLocator_AndroidSimpleBufferQueue loc_bufq = {0};
SLDataLocator_OutputMix loc_outmix = {0};
SLresult res = 0;
SLInterfaceID id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
SLboolean req = SL_BOOLEAN_TRUE;
sl_t *sl = (sl_t*)calloc(1, sizeof(sl_t));
(void)device;
if (!sl)
goto error;
RARCH_LOG("[OpenSL]: Requested audio latency: %u ms.", latency);
GOTO_IF_FAIL(slCreateEngine(&sl->engine_object, 0, NULL, 0, NULL, NULL));
GOTO_IF_FAIL(SLObjectItf_Realize(sl->engine_object, SL_BOOLEAN_FALSE));
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->engine_object, SL_IID_ENGINE, &sl->engine));
GOTO_IF_FAIL(SLEngineItf_CreateOutputMix(sl->engine, &sl->output_mix, 0, NULL, NULL));
GOTO_IF_FAIL(SLObjectItf_Realize(sl->output_mix, SL_BOOLEAN_FALSE));
if (block_frames)
sl->buf_size = block_frames * 4;
else
sl->buf_size = next_pow2(32 * latency);
sl->buf_count = (latency * 4 * rate + 500) / 1000;
sl->buf_count = (sl->buf_count + sl->buf_size / 2) / sl->buf_size;
if (sl->buf_count < 2)
sl->buf_count = 2;
sl->buffer = (uint8_t**)calloc(sizeof(uint8_t*), sl->buf_count);
if (!sl->buffer)
goto error;
sl->buffer_chunk = (uint8_t*)calloc(sl->buf_count, sl->buf_size);
if (!sl->buffer_chunk)
goto error;
for (i = 0; i < sl->buf_count; i++)
sl->buffer[i] = sl->buffer_chunk + i * sl->buf_size;
RARCH_LOG("[OpenSL]: Setting audio latency: Block size = %u, Blocks = %u, Total = %u ...\n",
sl->buf_size, sl->buf_count, sl->buf_size * sl->buf_count);
fmt_pcm.formatType = SL_DATAFORMAT_PCM;
fmt_pcm.numChannels = 2;
fmt_pcm.samplesPerSec = rate * 1000; /* Samplerate is in milli-Hz. */
fmt_pcm.bitsPerSample = 16;
fmt_pcm.containerSize = 16;
fmt_pcm.channelMask = SL_SPEAKER_FRONT_LEFT | SL_SPEAKER_FRONT_RIGHT;
fmt_pcm.endianness = SL_BYTEORDER_LITTLEENDIAN; /* Android only. */
audio_src.pLocator = &loc_bufq;
audio_src.pFormat = &fmt_pcm;
loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
loc_bufq.numBuffers = sl->buf_count;
loc_outmix.locatorType = SL_DATALOCATOR_OUTPUTMIX;
loc_outmix.outputMix = sl->output_mix;
audio_sink.pLocator = &loc_outmix;
GOTO_IF_FAIL(SLEngineItf_CreateAudioPlayer(sl->engine, &sl->buffer_queue_object,
&audio_src, &audio_sink,
1, &id, &req));
GOTO_IF_FAIL(SLObjectItf_Realize(sl->buffer_queue_object, SL_BOOLEAN_FALSE));
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->buffer_queue_object, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&sl->buffer_queue));
sl->cond = scond_new();
sl->lock = slock_new();
(*sl->buffer_queue)->RegisterCallback(sl->buffer_queue, opensl_callback, sl);
/* Enqueue a bit to get stuff rolling. */
sl->buffered_blocks = sl->buf_count;
sl->buffer_index = 0;
for (i = 0; i < sl->buf_count; i++)
(*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[i], sl->buf_size);
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->buffer_queue_object, SL_IID_PLAY, &sl->player));
GOTO_IF_FAIL(SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_PLAYING));
return sl;
error:
RARCH_ERR("[OpenSL]: Couldn't initialize OpenSL ES driver, error code: [%d].\n", (int)res);
sl_free(sl);
return NULL;
}
static bool sl_stop(void *data)
{
sl_t *sl = (sl_t*)data;
sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED)
== SL_RESULT_SUCCESS) ? true : false;
return sl->is_paused ? true : false;
}
static bool sl_alive(void *data)
{
sl_t *sl = (sl_t*)data;
if (!sl)
return false;
return !sl->is_paused;
}
static void sl_set_nonblock_state(void *data, bool state)
{
sl_t *sl = (sl_t*)data;
if (sl)
sl->nonblock = state;
}
static bool sl_start(void *data, bool is_shutdown)
{
sl_t *sl = (sl_t*)data;
sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_PLAYING)
== SL_RESULT_SUCCESS) ? false : true;
return sl->is_paused ? false : true;
}
static ssize_t sl_write(void *data, const void *buf_, size_t size)
{
sl_t *sl = (sl_t*)data;
size_t written = 0;
const uint8_t *buf = (const uint8_t*)buf_;
while (size)
{
size_t avail_write;
if (sl->nonblock)
{
if (sl->buffered_blocks == sl->buf_count)
break;
}
else
{
slock_lock(sl->lock);
while (sl->buffered_blocks == sl->buf_count)
scond_wait(sl->cond, sl->lock);
slock_unlock(sl->lock);
}
avail_write = MIN(sl->buf_size - sl->buffer_ptr, size);
if (avail_write)
{
memcpy(sl->buffer[sl->buffer_index] + sl->buffer_ptr, buf, avail_write);
sl->buffer_ptr += avail_write;
buf += avail_write;
size -= avail_write;
written += avail_write;
}
if (sl->buffer_ptr >= sl->buf_size)
{
SLresult res = (*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[sl->buffer_index], sl->buf_size);
sl->buffer_index = (sl->buffer_index + 1) % sl->buf_count;
__sync_fetch_and_add(&sl->buffered_blocks, 1);
sl->buffer_ptr = 0;
if (res != SL_RESULT_SUCCESS)
{
RARCH_ERR("[OpenSL]: Failed to write! (Error: 0x%x)\n", (unsigned)res);
return -1;
}
}
}
return written;
}
static size_t sl_write_avail(void *data)
{
sl_t *sl = (sl_t*)data;
size_t avail = (sl->buf_count - (int)sl->buffered_blocks - 1) * sl->buf_size + (sl->buf_size - (int)sl->buffer_ptr);
return avail;
}
static size_t sl_buffer_size(void *data)
{
sl_t *sl = (sl_t*)data;
return sl->buf_size * sl->buf_count;
}
static bool sl_use_float(void *data)
{
(void)data;
return false;
}
audio_driver_t audio_opensl = {
sl_init,
sl_write,
sl_stop,
sl_start,
sl_alive,
sl_set_nonblock_state,
sl_free,
sl_use_float,
"opensl",
NULL,
NULL,
sl_write_avail,
sl_buffer_size,
};

View File

@ -1,215 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <errno.h>
#ifdef HAVE_OSS_BSD
#include <soundcard.h>
#else
#include <sys/soundcard.h>
#endif
#include <retro_endianness.h>
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "../../retroarch.h"
#include "../../verbosity.h"
#ifdef HAVE_OSS_BSD
#define DEFAULT_OSS_DEV "/dev/audio"
#else
#define DEFAULT_OSS_DEV "/dev/dsp"
#endif
static bool oss_is_paused = false;
static void *oss_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_out_rate)
{
int frags, frag, channels, format, new_rate;
int *fd = (int*)calloc(1, sizeof(int));
const char *oss_device = device ? device : DEFAULT_OSS_DEV;
if (!fd)
return NULL;
if ((*fd = open(oss_device, O_WRONLY)) < 0)
{
free(fd);
perror("open");
return NULL;
}
frags = (latency * rate * 4) / (1000 * (1 << 10));
frag = (frags << 16) | 10;
if (ioctl(*fd, SNDCTL_DSP_SETFRAGMENT, &frag) < 0)
RARCH_WARN("Cannot set fragment sizes. Latency might not be as expected ...\n");
channels = 2;
format = is_little_endian() ? AFMT_S16_LE : AFMT_S16_BE;
if (ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0)
goto error;
if (ioctl(*fd, SNDCTL_DSP_SETFMT, &format) < 0)
goto error;
new_rate = rate;
if (ioctl(*fd, SNDCTL_DSP_SPEED, &new_rate) < 0)
goto error;
if (new_rate != (int)rate)
{
RARCH_WARN("Requested sample rate not supported. Adjusting output rate to %d Hz.\n", new_rate);
*new_out_rate = new_rate;
}
return fd;
error:
close(*fd);
free(fd);
perror("ioctl");
return NULL;
}
static ssize_t oss_write(void *data, const void *buf, size_t size)
{
ssize_t ret;
int *fd = (int*)data;
if (size == 0)
return 0;
if ((ret = write(*fd, buf, size)) < 0)
{
if (errno == EAGAIN && (fcntl(*fd, F_GETFL) & O_NONBLOCK))
return 0;
return -1;
}
return ret;
}
static bool oss_stop(void *data)
{
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_RESET, 0) < 0)
return false;
oss_is_paused = true;
return true;
}
static bool oss_start(void *data, bool is_shutdown)
{
(void)data;
oss_is_paused = false;
return true;
}
static bool oss_alive(void *data)
{
(void)data;
return !oss_is_paused;
}
static void oss_set_nonblock_state(void *data, bool state)
{
int rc;
int *fd = (int*)data;
if (state)
rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) | O_NONBLOCK);
else
rc = fcntl(*fd, F_SETFL, fcntl(*fd, F_GETFL) & (~O_NONBLOCK));
if (rc != 0)
RARCH_WARN("Could not set nonblocking on OSS file descriptor. Will not be able to fast-forward.\n");
}
static void oss_free(void *data)
{
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_RESET, 0) < 0)
return;
close(*fd);
free(fd);
}
static size_t oss_write_avail(void *data)
{
audio_buf_info info;
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
{
RARCH_ERR("[OSS]: SNDCTL_DSP_GETOSPACE failed ...\n");
return 0;
}
return info.bytes;
}
static size_t oss_buffer_size(void *data)
{
audio_buf_info info;
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
{
RARCH_ERR("[OSS]: SNDCTL_DSP_GETOSPACE failed ...\n");
return 1; /* Return something non-zero to avoid SIGFPE. */
}
return info.fragsize * info.fragstotal;
}
static bool oss_use_float(void *data)
{
(void)data;
return false;
}
audio_driver_t audio_oss = {
oss_init,
oss_write,
oss_stop,
oss_start,
oss_alive,
oss_set_nonblock_state,
oss_free,
oss_use_float,
"oss",
NULL,
NULL,
oss_write_avail,
oss_buffer_size,
};

View File

@ -1,172 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Francisco Javier Trujillo Mata
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#include <kernel.h>
#include <audsrv.h>
#include "../../retroarch.h"
#define AUDIO_BUFFER 128 * 1024
#define AUDIO_CHANNELS 2
#define AUDIO_BITS 16
typedef struct ps2_audio
{
/* TODO/FIXME - nonblock is not implemented */
bool nonblock;
bool running;
} ps2_audio_t;
static void audioConfigure(ps2_audio_t *ps2, unsigned rate)
{
int err;
struct audsrv_fmt_t format;
format.bits = AUDIO_BITS;
format.freq = rate;
format.channels = AUDIO_CHANNELS;
err = audsrv_set_format(&format);
if (err)
{
printf("set format returned %d\n", err);
printf("audsrv returned error string: %s\n", audsrv_get_error_string());
}
audsrv_set_volume(MAX_VOLUME);
}
static void *ps2_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
ps2_audio_t *ps2 = (ps2_audio_t*)calloc(1, sizeof(ps2_audio_t));
if (!ps2)
return NULL;
audioConfigure(ps2, rate);
return ps2;
}
static void ps2_audio_free(void *data)
{
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (!ps2)
return;
ps2->running = false;
audsrv_stop_audio();
free(ps2);
}
static ssize_t ps2_audio_write(void *data, const void *buf, size_t size)
{
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (!ps2->running)
return -1;
return audsrv_play_audio(buf, size);
}
static bool ps2_audio_alive(void *data)
{
bool alive = false;
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2)
alive = ps2->running;
return alive;
}
static bool ps2_audio_stop(void *data)
{
bool stop = true;
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2)
{
audsrv_stop_audio();
ps2->running = false;
}
return stop;
}
static bool ps2_audio_start(void *data, bool is_shutdown)
{
ps2_audio_t* ps2 = (ps2_audio_t*)data;
bool start = true;
if (ps2)
ps2->running = true;
return start;
}
static void ps2_audio_set_nonblock_state(void *data, bool toggle)
{
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2)
ps2->nonblock = toggle;
}
static bool ps2_audio_use_float(void *data)
{
return false;
}
static size_t ps2_audio_write_avail(void *data)
{
ps2_audio_t* ps2 = (ps2_audio_t*)data;
if (ps2 && ps2->running)
return AUDIO_BUFFER;
return 0;
}
static size_t ps2_audio_buffer_size(void *data)
{
return AUDIO_BUFFER;
}
audio_driver_t audio_ps2 = {
ps2_audio_init,
ps2_audio_write,
ps2_audio_stop,
ps2_audio_start,
ps2_audio_alive,
ps2_audio_set_nonblock_state,
ps2_audio_free,
ps2_audio_use_float,
"ps2",
NULL,
NULL,
ps2_audio_write_avail,
ps2_audio_buffer_size
};

View File

@ -1,253 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <queues/fifo_queue.h>
#include "../../retroarch.h"
#include "../../defines/ps3_defines.h"
#define AUDIO_BLOCKS 8
#define AUDIO_CHANNELS 2
typedef struct
{
uint32_t audio_port;
bool nonblock;
bool started;
volatile bool quit_thread;
fifo_buffer_t *buffer;
sys_ppu_thread_t thread;
sys_lwmutex_t lock;
sys_lwmutex_t cond_lock;
sys_lwcond_t cond;
} ps3_audio_t;
#ifdef __PSL1GHT__
static void event_loop(void *data)
#else
static void event_loop(uint64_t data)
#endif
{
float out_tmp[CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS]
__attribute__((aligned(16)));
sys_event_queue_t id;
sys_ipc_key_t key;
sys_event_t event;
ps3_audio_t *aud = (ps3_audio_t*)(uintptr_t)data;
cellAudioCreateNotifyEventQueue(&id, &key);
cellAudioSetNotifyEventQueue(key);
while (!aud->quit_thread)
{
sys_event_queue_receive(id, &event, SYS_NO_TIMEOUT);
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
if (fifo_read_avail(aud->buffer) >= sizeof(out_tmp))
fifo_read(aud->buffer, out_tmp, sizeof(out_tmp));
else
memset(out_tmp, 0, sizeof(out_tmp));
sys_lwmutex_unlock(&aud->lock);
sys_lwcond_signal(&aud->cond);
cellAudioAddData(aud->audio_port, out_tmp,
CELL_AUDIO_BLOCK_SAMPLES, 1.0);
}
cellAudioRemoveNotifyEventQueue(key);
sys_ppu_thread_exit(0);
}
static void *ps3_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
CellAudioPortParam params;
ps3_audio_t *data = calloc(1, sizeof(*data));
if (!data)
return NULL;
(void)latency;
(void)device;
(void)rate;
cellAudioInit();
params.numChannels = AUDIO_CHANNELS;
params.numBlocks = AUDIO_BLOCKS;
#if 0
#ifdef HAVE_HEADSET
if(global->console.sound.mode == SOUND_MODE_HEADSET)
params.param_attrib = CELL_AUDIO_PORTATTR_OUT_SECONDARY;
else
#endif
#endif
params.param_attrib = 0;
if (cellAudioPortOpen(&params, &data->audio_port) != CELL_OK)
{
cellAudioQuit();
free(data);
return NULL;
}
data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES *
AUDIO_CHANNELS * AUDIO_BLOCKS * sizeof(float));
#ifdef __PSL1GHT__
sys_lwmutex_attr_t lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwmutex_attr_t cond_lock_attr =
{SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"};
sys_lwcond_attribute_t cond_attr = {"\0"};
#else
sys_lwmutex_attribute_t lock_attr;
sys_lwmutex_attribute_t cond_lock_attr;
sys_lwcond_attribute_t cond_attr;
sys_lwmutex_attribute_initialize(lock_attr);
sys_lwmutex_attribute_initialize(cond_lock_attr);
sys_lwcond_attribute_initialize(cond_attr);
#endif
sys_lwmutex_create(&data->lock, &lock_attr);
sys_lwmutex_create(&data->cond_lock, &cond_lock_attr);
sys_lwcond_create(&data->cond, &data->cond_lock, &cond_attr);
cellAudioPortStart(data->audio_port);
data->started = true;
sys_ppu_thread_create(&data->thread, event_loop,
#ifdef __PSL1GHT__
data,
#else
(uint64_t)data,
#endif
1500, 0x1000, SYS_PPU_THREAD_CREATE_JOINABLE, (char*)"sound");
return data;
}
static ssize_t ps3_audio_write(void *data, const void *buf, size_t size)
{
ps3_audio_t *aud = data;
if (aud->nonblock)
{
if (fifo_write_avail(aud->buffer) < size)
return 0;
}
while (fifo_write_avail(aud->buffer) < size)
sys_lwcond_wait(&aud->cond, 0);
sys_lwmutex_lock(&aud->lock, SYS_NO_TIMEOUT);
fifo_write(aud->buffer, buf, size);
sys_lwmutex_unlock(&aud->lock);
return size;
}
static bool ps3_audio_stop(void *data)
{
ps3_audio_t *aud = data;
if (aud->started)
{
cellAudioPortStop(aud->audio_port);
aud->started = false;
}
return true;
}
static bool ps3_audio_start(void *data, bool is_shutdown)
{
ps3_audio_t *aud = data;
if (!aud->started)
{
cellAudioPortStart(aud->audio_port);
aud->started = true;
}
return true;
}
static bool ps3_audio_alive(void *data)
{
ps3_audio_t *aud = data;
if (!aud)
return false;
return aud->started;
}
static void ps3_audio_set_nonblock_state(void *data, bool toggle)
{
ps3_audio_t *aud = data;
if (aud)
aud->nonblock = toggle;
}
static void ps3_audio_free(void *data)
{
uint64_t val;
ps3_audio_t *aud = data;
aud->quit_thread = true;
ps3_audio_start(aud, false);
sys_ppu_thread_join(aud->thread, &val);
ps3_audio_stop(aud);
cellAudioPortClose(aud->audio_port);
cellAudioQuit();
fifo_free(aud->buffer);
sys_lwmutex_destroy(&aud->lock);
sys_lwmutex_destroy(&aud->cond_lock);
sys_lwcond_destroy(&aud->cond);
free(data);
}
static bool ps3_audio_use_float(void *data)
{
(void)data;
return true;
}
static size_t ps3_audio_write_avail(void *data)
{
(void)data;
return 0;
}
audio_driver_t audio_ps3 = {
ps3_audio_init,
ps3_audio_write,
ps3_audio_stop,
ps3_audio_start,
ps3_audio_alive,
ps3_audio_set_nonblock_state,
ps3_audio_free,
ps3_audio_use_float,
"ps3",
NULL,
NULL,
ps3_audio_write_avail,
NULL
};

View File

@ -1,339 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2017 - Ali Bouhlel
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#if defined(VITA) || defined(PSP)
#include <malloc.h>
#endif
#include <stdio.h>
#include <string.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#if defined(VITA)
#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/threadmgr.h>
#include <psp2/kernel/sysmem.h>
#include <psp2/audioout.h>
#elif defined(PSP)
#include <pspkernel.h>
#include <pspaudio.h>
#elif defined(ORBIS)
#include <audioout.h>
#define SCE_AUDIO_OUT_PORT_TYPE_MAIN 0
#define SCE_AUDIO_OUT_MODE_STEREO 1
#define SceUID uint32_t
#endif
#include "../../retroarch.h"
typedef struct psp_audio
{
bool nonblock;
uint32_t* buffer;
uint32_t* zeroBuffer;
SceUID thread;
int rate;
volatile bool running;
volatile uint16_t read_pos;
volatile uint16_t write_pos;
sthread_t *worker_thread;
slock_t *fifo_lock;
scond_t *cond;
slock_t *cond_lock;
} psp_audio_t;
#define AUDIO_OUT_COUNT 512u
#define AUDIO_BUFFER_SIZE (1u<<13u)
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
static void audioMainLoop(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
#if defined(VITA)
int port = sceAudioOutOpenPort(
SCE_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
#elif defined(ORBIS)
int port = sceAudioOutOpen(0xff,
SCE_AUDIO_OUT_PORT_TYPE_MAIN, 0, AUDIO_OUT_COUNT,
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
#else
sceAudioSRCChReserve(AUDIO_OUT_COUNT, psp->rate, 2);
#endif
while (psp->running)
{
bool cond = false;
uint16_t read_pos = psp->read_pos;
uint16_t read_pos_2 = psp->read_pos;
slock_lock(psp->fifo_lock);
cond = ((uint16_t)(psp->write_pos - read_pos) & AUDIO_BUFFER_SIZE_MASK)
< (AUDIO_OUT_COUNT * 2);
if (!cond)
{
read_pos += AUDIO_OUT_COUNT;
read_pos &= AUDIO_BUFFER_SIZE_MASK;
psp->read_pos = read_pos;
}
slock_unlock(psp->fifo_lock);
slock_lock(psp->cond_lock);
scond_signal(psp->cond);
slock_unlock(psp->cond_lock);
#if defined(VITA) || defined(ORBIS)
sceAudioOutOutput(port,
cond ? (psp->zeroBuffer)
: (psp->buffer + read_pos_2));
#else
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
: (psp->buffer + read_pos));
#endif
}
#if defined(VITA)
sceAudioOutReleasePort(port);
#elif defined(ORBIS)
sceAudioOutClose(port);
#else
sceAudioSRCChRelease();
#endif
return;
}
static void *psp_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
psp_audio_t *psp = (psp_audio_t*)calloc(1, sizeof(psp_audio_t));
if (!psp)
return NULL;
(void)device;
(void)latency;
#ifdef ORBIS
psp->buffer = (uint32_t*)
malloc(AUDIO_BUFFER_SIZE * sizeof(uint32_t));
#else
/* Cache aligned, not necessary but helpful. */
psp->buffer = (uint32_t*)
memalign(64, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
#endif
memset(psp->buffer, 0, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
#ifdef ORBIS
psp->zeroBuffer = (uint32_t*)
malloc(AUDIO_OUT_COUNT * sizeof(uint32_t));
#else
psp->zeroBuffer = (uint32_t*)
memalign(64, AUDIO_OUT_COUNT * sizeof(uint32_t));
#endif
memset(psp->zeroBuffer, 0, AUDIO_OUT_COUNT * sizeof(uint32_t));
psp->read_pos = 0;
psp->write_pos = 0;
psp->rate = rate;
psp->fifo_lock = slock_new();
psp->cond_lock = slock_new();
psp->cond = scond_new();
psp->nonblock = false;
psp->running = true;
psp->worker_thread = sthread_create(audioMainLoop, psp);
return psp;
}
static void psp_audio_free(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
if(!psp)
return;
if(psp->running){
if (psp->worker_thread)
{
psp->running = false;
sthread_join(psp->worker_thread);
}
if (psp->cond)
scond_free(psp->cond);
if (psp->fifo_lock)
slock_free(psp->fifo_lock);
if (psp->cond_lock)
slock_free(psp->cond_lock);
}
free(psp->buffer);
psp->worker_thread = NULL;
free(psp->zeroBuffer);
free(psp);
}
static ssize_t psp_audio_write(void *data, const void *buf, size_t size)
{
psp_audio_t* psp = (psp_audio_t*)data;
uint16_t write_pos = psp->write_pos;
uint16_t sampleCount = size / sizeof(uint32_t);
if (!psp->running)
return -1;
if (psp->nonblock)
{
if (AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size)
return 0;
}
slock_lock(psp->cond_lock);
while (AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size)
scond_wait(psp->cond, psp->cond_lock);
slock_unlock(psp->cond_lock);
slock_lock(psp->fifo_lock);
if((write_pos + sampleCount) > AUDIO_BUFFER_SIZE)
{
memcpy(psp->buffer + write_pos, buf,
(AUDIO_BUFFER_SIZE - write_pos) * sizeof(uint32_t));
memcpy(psp->buffer, (uint32_t*) buf +
(AUDIO_BUFFER_SIZE - write_pos),
(write_pos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
}
else
memcpy(psp->buffer + write_pos, buf, size);
write_pos += sampleCount;
write_pos &= AUDIO_BUFFER_SIZE_MASK;
psp->write_pos = write_pos;
slock_unlock(psp->fifo_lock);
return size;
}
static bool psp_audio_alive(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
if (!psp)
return false;
return psp->running;
}
static bool psp_audio_stop(void *data)
{
psp_audio_t* psp = (psp_audio_t*)data;
if (psp){
psp->running = false;
if (!psp->worker_thread)
return true;
sthread_join(psp->worker_thread);
psp->worker_thread = NULL;
}
return true;
}
static bool psp_audio_start(void *data, bool is_shutdown)
{
psp_audio_t* psp = (psp_audio_t*)data;
if(psp && psp->running)
return true;
if (!psp->worker_thread)
{
psp->running = true;
psp->worker_thread = sthread_create(audioMainLoop, psp);
}
return true;
}
static void psp_audio_set_nonblock_state(void *data, bool toggle)
{
psp_audio_t* psp = (psp_audio_t*)data;
if (psp)
psp->nonblock = toggle;
}
static bool psp_audio_use_float(void *data)
{
(void)data;
return false;
}
static size_t psp_write_avail(void *data)
{
size_t val;
psp_audio_t* psp = (psp_audio_t*)data;
if (!psp||!psp->running)
return 0;
slock_lock(psp->fifo_lock);
val = AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK);
slock_unlock(psp->fifo_lock);
return val;
}
static size_t psp_buffer_size(void *data)
{
/* TODO */
return AUDIO_BUFFER_SIZE /** sizeof(uint32_t)*/;
}
audio_driver_t audio_psp = {
psp_audio_init,
psp_audio_write,
psp_audio_stop,
psp_audio_start,
psp_audio_alive,
psp_audio_set_nonblock_state,
psp_audio_free,
psp_audio_use_float,
#if defined(VITA)
"vita",
#elif defined(ORBIS)
"orbis",
#else
"psp",
#endif
NULL,
NULL,
psp_write_avail,
psp_buffer_size
};

View File

@ -1,369 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <string.h>
#include <pulse/pulseaudio.h>
#include <boolean.h>
#include <retro_miscellaneous.h>
#include <retro_endianness.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct
{
pa_threaded_mainloop *mainloop;
pa_context *context;
pa_stream *stream;
size_t buffer_size;
bool nonblock;
bool success;
bool is_paused;
} pa_t;
static void pulse_free(void *data)
{
pa_t *pa = (pa_t*)data;
if (!pa)
return;
if (pa->mainloop)
pa_threaded_mainloop_stop(pa->mainloop);
if (pa->stream)
{
pa_stream_disconnect(pa->stream);
pa_stream_unref(pa->stream);
}
if (pa->context)
{
pa_context_disconnect(pa->context);
pa_context_unref(pa->context);
}
if (pa->mainloop)
pa_threaded_mainloop_free(pa->mainloop);
free(pa);
}
static void stream_success_cb(pa_stream *s, int success, void *data)
{
pa_t *pa = (pa_t*)data;
(void)s;
pa->success = success;
pa_threaded_mainloop_signal(pa->mainloop, 0);
}
static void context_state_cb(pa_context *c, void *data)
{
pa_t *pa = (pa_t*)data;
switch (pa_context_get_state(c))
{
case PA_CONTEXT_READY:
case PA_CONTEXT_TERMINATED:
case PA_CONTEXT_FAILED:
pa_threaded_mainloop_signal(pa->mainloop, 0);
break;
default:
break;
}
}
static void stream_state_cb(pa_stream *s, void *data)
{
pa_t *pa = (pa_t*)data;
switch (pa_stream_get_state(s))
{
case PA_STREAM_READY:
case PA_STREAM_FAILED:
case PA_STREAM_TERMINATED:
pa_threaded_mainloop_signal(pa->mainloop, 0);
break;
default:
break;
}
}
static void stream_request_cb(pa_stream *s, size_t length, void *data)
{
pa_t *pa = (pa_t*)data;
(void)length;
(void)s;
pa_threaded_mainloop_signal(pa->mainloop, 0);
}
static void stream_latency_update_cb(pa_stream *s, void *data)
{
pa_t *pa = (pa_t*)data;
(void)s;
pa_threaded_mainloop_signal(pa->mainloop, 0);
}
static void underrun_update_cb(pa_stream *s, void *data)
{
#if 0
pa_t *pa = (pa_t*)data;
(void)s;
RARCH_LOG("[PulseAudio]: Underrun (Buffer: %u, Writable size: %u).\n",
(unsigned)pa->buffer_size,
(unsigned)pa_stream_writable_size(pa->stream));
#endif
}
static void buffer_attr_cb(pa_stream *s, void *data)
{
pa_t *pa = (pa_t*)data;
const pa_buffer_attr *server_attr = pa_stream_get_buffer_attr(s);
if (server_attr)
pa->buffer_size = server_attr->tlength;
#if 0
RARCH_LOG("[PulseAudio]: Got new buffer size %u.\n", (unsigned)pa->buffer_size);
#endif
}
static void *pulse_init(const char *device, unsigned rate,
unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
pa_sample_spec spec;
pa_buffer_attr buffer_attr = {0};
const pa_buffer_attr *server_attr = NULL;
pa_t *pa = (pa_t*)calloc(1, sizeof(*pa));
memset(&spec, 0, sizeof(spec));
if (!pa)
goto error;
pa->mainloop = pa_threaded_mainloop_new();
if (!pa->mainloop)
goto error;
pa->context = pa_context_new(pa_threaded_mainloop_get_api(pa->mainloop), "RetroArch");
if (!pa->context)
goto error;
pa_context_set_state_callback(pa->context, context_state_cb, pa);
if (pa_context_connect(pa->context, device, PA_CONTEXT_NOFLAGS, NULL) < 0)
goto error;
pa_threaded_mainloop_lock(pa->mainloop);
if (pa_threaded_mainloop_start(pa->mainloop) < 0)
goto error;
pa_threaded_mainloop_wait(pa->mainloop);
if (pa_context_get_state(pa->context) != PA_CONTEXT_READY)
goto unlock_error;
spec.format = is_little_endian() ? PA_SAMPLE_FLOAT32LE : PA_SAMPLE_FLOAT32BE;
spec.channels = 2;
spec.rate = rate;
pa->stream = pa_stream_new(pa->context, "audio", &spec, NULL);
if (!pa->stream)
goto unlock_error;
pa_stream_set_state_callback(pa->stream, stream_state_cb, pa);
pa_stream_set_write_callback(pa->stream, stream_request_cb, pa);
pa_stream_set_latency_update_callback(pa->stream, stream_latency_update_cb, pa);
pa_stream_set_underflow_callback(pa->stream, underrun_update_cb, pa);
pa_stream_set_buffer_attr_callback(pa->stream, buffer_attr_cb, pa);
buffer_attr.maxlength = -1;
buffer_attr.tlength = pa_usec_to_bytes(latency * PA_USEC_PER_MSEC, &spec);
buffer_attr.prebuf = -1;
buffer_attr.minreq = -1;
buffer_attr.fragsize = -1;
if (pa_stream_connect_playback(pa->stream, NULL,
&buffer_attr, PA_STREAM_ADJUST_LATENCY, NULL, NULL) < 0)
goto error;
pa_threaded_mainloop_wait(pa->mainloop);
if (pa_stream_get_state(pa->stream) != PA_STREAM_READY)
goto unlock_error;
server_attr = pa_stream_get_buffer_attr(pa->stream);
if (server_attr)
{
pa->buffer_size = server_attr->tlength;
RARCH_LOG("[PulseAudio]: Requested %u bytes buffer, got %u.\n",
(unsigned)buffer_attr.tlength,
(unsigned)pa->buffer_size);
}
else
pa->buffer_size = buffer_attr.tlength;
pa_threaded_mainloop_unlock(pa->mainloop);
return pa;
unlock_error:
pa_threaded_mainloop_unlock(pa->mainloop);
error:
pulse_free(pa);
return NULL;
}
static bool pulse_start(void *data, bool is_shutdown);
static ssize_t pulse_write(void *data, const void *buf_, size_t size)
{
pa_t *pa = (pa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
/* Workaround buggy menu code.
* If a write happens while we're paused, we might never progress. */
if (pa->is_paused)
if (!pulse_start(pa, false))
return -1;
pa_threaded_mainloop_lock(pa->mainloop);
while (size)
{
size_t writable = MIN(size, pa_stream_writable_size(pa->stream));
if (writable)
{
pa_stream_write(pa->stream, buf, writable, NULL, 0, PA_SEEK_RELATIVE);
buf += writable;
size -= writable;
written += writable;
}
else if (!pa->nonblock)
pa_threaded_mainloop_wait(pa->mainloop);
else
break;
}
pa_threaded_mainloop_unlock(pa->mainloop);
return written;
}
static bool pulse_stop(void *data)
{
bool ret;
pa_t *pa = (pa_t*)data;
if (pa->is_paused)
return true;
RARCH_LOG("[PulseAudio]: Pausing.\n");
pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, true, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = true;
return ret;
}
static bool pulse_alive(void *data)
{
pa_t *pa = (pa_t*)data;
if (!pa)
return false;
return !pa->is_paused;
}
static bool pulse_start(void *data, bool is_shutdown)
{
bool ret;
pa_t *pa = (pa_t*)data;
if (!pa->is_paused)
return true;
RARCH_LOG("[PulseAudio]: Unpausing.\n");
pa->success = true; /* In case of spurious wakeup. Not critical. */
pa_threaded_mainloop_lock(pa->mainloop);
pa_stream_cork(pa->stream, false, stream_success_cb, pa);
pa_threaded_mainloop_wait(pa->mainloop);
ret = pa->success;
pa_threaded_mainloop_unlock(pa->mainloop);
pa->is_paused = false;
return ret;
}
static void pulse_set_nonblock_state(void *data, bool state)
{
pa_t *pa = (pa_t*)data;
if (pa)
pa->nonblock = state;
}
static bool pulse_use_float(void *data)
{
(void)data;
return true;
}
static size_t pulse_write_avail(void *data)
{
size_t length;
pa_t *pa = (pa_t*)data;
pa_threaded_mainloop_lock(pa->mainloop);
length = pa_stream_writable_size(pa->stream);
audio_driver_set_buffer_size(pa->buffer_size); /* Can change spuriously. */
pa_threaded_mainloop_unlock(pa->mainloop);
return length;
}
static size_t pulse_buffer_size(void *data)
{
pa_t *pa = (pa_t*)data;
return pa->buffer_size;
}
audio_driver_t audio_pulse = {
pulse_init,
pulse_write,
pulse_stop,
pulse_start,
pulse_alive,
pulse_set_nonblock_state,
pulse_free,
pulse_use_float,
"pulse",
NULL,
NULL,
pulse_write_avail,
pulse_buffer_size,
};

View File

@ -1,156 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stdlib.h>
#include <errno.h>
#include <roaraudio.h>
#include <boolean.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct
{
roar_vs_t *vss;
bool nonblocking;
bool is_paused;
} roar_t;
static void *ra_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames, unsigned *new_rate)
{
int err;
roar_vs_t *vss = NULL;
roar_t *roar = (roar_t*)calloc(1, sizeof(roar_t));
if (!roar)
return NULL;
(void)latency;
if (!(vss = roar_vs_new_simple(device, "RetroArch", rate, 2, ROAR_CODEC_PCM_S, 16, ROAR_DIR_PLAY, &err)))
{
RARCH_ERR("RoarAudio: \"%s\"\n", roar_vs_strerr(err));
free(roar);
return NULL;
}
roar_vs_role(vss, ROAR_ROLE_GAME, NULL);
roar->vss = vss;
return roar;
}
static ssize_t ra_write(void *data, const void *buf, size_t size)
{
int err;
size_t written = 0;
roar_t *roar = (roar_t*)data;
if (size == 0)
return 0;
while (written < size)
{
ssize_t rc;
size_t write_amt = size - written;
if ((rc = roar_vs_write(roar->vss,
(const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt)
{
if (roar->nonblocking)
return rc;
else if (rc < 0)
return -1;
}
written += rc;
}
return size;
}
static bool ra_stop(void *data)
{
roar_t *roar = (roar_t*)data;
if (roar)
roar->is_paused = true;
return true;
}
static bool ra_alive(void *data)
{
roar_t *roar = (roar_t*)data;
if (!roar)
return false;
return !roar->is_paused;
}
static void ra_set_nonblock_state(void *data, bool state)
{
roar_t *roar = (roar_t*)data;
if (roar_vs_blocking(roar->vss, (state) ? ROAR_VS_FALSE : ROAR_VS_TRUE, NULL) < 0)
{
RARCH_ERR("Can't set nonblocking. Will not be able to fast-forward.\n");
}
roar->nonblocking = state;
}
static bool ra_start(void *data, bool is_shutdown)
{
roar_t *roar = (roar_t*)data;
if (roar)
roar->is_paused = false;
return true;
}
static void ra_free(void *data)
{
roar_t *roar = (roar_t*)data;
roar_vs_close(roar->vss, ROAR_VS_TRUE, NULL);
free(data);
}
static bool ra_use_float(void *data)
{
return false;
}
static size_t ra_write_avail(void *data)
{
(void)data;
return 0;
}
audio_driver_t audio_roar = {
ra_init,
ra_write,
ra_stop,
ra_start,
ra_alive,
ra_set_nonblock_state,
ra_free,
ra_use_float,
"roar",
NULL,
NULL,
ra_write_avail,
NULL
};

View File

@ -1,243 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <rthreads/rthreads.h>
#include "../../retroarch.h"
#include "rsound.h"
typedef struct rsd
{
rsound_t *rd;
bool nonblock;
bool is_paused;
volatile bool has_error;
fifo_buffer_t *buffer;
slock_t *cond_lock;
scond_t *cond;
} rsd_t;
static ssize_t rsound_audio_cb(void *data, size_t bytes, void *userdata)
{
rsd_t *rsd = (rsd_t*)userdata;
size_t avail = fifo_read_avail(rsd->buffer);
size_t write_size = bytes > avail ? avail : bytes;
fifo_read(rsd->buffer, data, write_size);
scond_signal(rsd->cond);
return write_size;
}
static void err_cb(void *userdata)
{
rsd_t *rsd = (rsd_t*)userdata;
rsd->has_error = true;
scond_signal(rsd->cond);
}
static void *rs_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
int channels, format;
rsound_t *rd = NULL;
rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
if (!rsd)
return NULL;
if (rsd_init(&rd) < 0)
goto error;
rsd->cond_lock = slock_new();
rsd->cond = scond_new();
rsd->buffer = fifo_new(1024 * 4);
channels = 2;
format = RSD_S16_NE;
rsd_set_param(rd, RSD_CHANNELS, &channels);
rsd_set_param(rd, RSD_SAMPLERATE, &rate);
rsd_set_param(rd, RSD_LATENCY, &latency);
if (device)
rsd_set_param(rd, RSD_HOST, (void*)device);
rsd_set_param(rd, RSD_FORMAT, &format);
rsd_set_callback(rd, rsound_audio_cb, err_cb, 256, rsd);
if (rsd_start(rd) < 0)
{
free(rsd);
goto error;
}
rsd->rd = rd;
return rsd;
error:
rsd_free(rd);
return NULL;
}
static ssize_t rs_write(void *data, const void *buf, size_t size)
{
rsd_t *rsd = (rsd_t*)data;
if (rsd->has_error)
return -1;
if (rsd->nonblock)
{
size_t avail, write_amt;
rsd_callback_lock(rsd->rd);
avail = fifo_write_avail(rsd->buffer);
write_amt = avail > size ? size : avail;
fifo_write(rsd->buffer, buf, write_amt);
rsd_callback_unlock(rsd->rd);
return write_amt;
}
else
{
size_t written = 0;
while (written < size && !rsd->has_error)
{
size_t avail;
rsd_callback_lock(rsd->rd);
avail = fifo_write_avail(rsd->buffer);
if (avail == 0)
{
rsd_callback_unlock(rsd->rd);
if (!rsd->has_error)
{
slock_lock(rsd->cond_lock);
scond_wait(rsd->cond, rsd->cond_lock);
slock_unlock(rsd->cond_lock);
}
}
else
{
size_t write_amt = size - written > avail ? avail : size - written;
fifo_write(rsd->buffer, (const char*)buf + written, write_amt);
rsd_callback_unlock(rsd->rd);
written += write_amt;
}
}
return written;
}
}
static bool rs_stop(void *data)
{
rsd_t *rsd = (rsd_t*)data;
rsd_stop(rsd->rd);
rsd->is_paused = true;
return true;
}
static void rs_set_nonblock_state(void *data, bool state)
{
rsd_t *rsd = (rsd_t*)data;
rsd->nonblock = state;
}
static bool rs_alive(void *data)
{
rsd_t *rsd = (rsd_t*)data;
if (rsd)
return !rsd->is_paused;
return false;
}
static bool rs_start(void *data, bool is_shutdown)
{
rsd_t *rsd = (rsd_t*)data;
if (rsd_start(rsd->rd) < 0)
return false;
rsd->is_paused = false;
return true;
}
static void rs_free(void *data)
{
rsd_t *rsd = (rsd_t*)data;
rsd_stop(rsd->rd);
rsd_free(rsd->rd);
fifo_free(rsd->buffer);
slock_free(rsd->cond_lock);
scond_free(rsd->cond);
free(rsd);
}
static size_t rs_write_avail(void *data)
{
size_t val;
rsd_t *rsd = (rsd_t*)data;
if (rsd->has_error)
return 0;
rsd_callback_lock(rsd->rd);
val = fifo_write_avail(rsd->buffer);
rsd_callback_unlock(rsd->rd);
return val;
}
static size_t rs_buffer_size(void *data)
{
(void)data;
return 1024 * 4;
}
static bool rs_use_float(void *data)
{
(void)data;
return false;
}
audio_driver_t audio_rsound = {
rs_init,
rs_write,
rs_stop,
rs_start,
rs_alive,
rs_set_nonblock_state,
rs_free,
rs_use_float,
"rsound",
NULL,
NULL,
rs_write_avail,
rs_buffer_size,
};

View File

@ -1,323 +0,0 @@
/* RSound - A PCM audio client/server
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* RSound is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RSound is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RSound.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __RSOUND_H
#define __RSOUND_H
#include <sys/types.h>
#include <unistd.h>
#include <rthreads/rthreads.h>
#include <sys/time.h>
#include <time.h>
#include <stdint.h>
#include <stddef.h>
#include <retro_common_api.h>
#include <queues/fifo_queue.h>
RETRO_BEGIN_DECLS
#ifdef _WIN32
#define RSD_DEFAULT_HOST "127.0.0.1" /* Stupid Windows. */
#else
#define RSD_DEFAULT_HOST "localhost"
#endif
#define RSD_DEFAULT_PORT "12345"
#define RSD_DEFAULT_UNIX_SOCK "/tmp/rsound"
#define RSD_DEFAULT_OBJECT "rsound"
#ifndef RSD_VERSION
#define RSD_VERSION "1.1"
#endif
/* Feature tests */
#define RSD_SAMPLERATE RSD_SAMPLERATE
#define RSD_CHANNELS RSD_CHANNELS
#define RSD_HOST RSD_HOST
#define RSD_PORT RSD_PORT
#define RSD_BUFSIZE RSD_BUFSIZE
#define RSD_LATENCY RSD_LATENCY
#define RSD_FORMAT RSD_FORMAT
#define RSD_IDENTITY RSD_IDENTITY
#define RSD_S16_LE RSD_S16_LE
#define RSD_S16_BE RSD_S16_BE
#define RSD_U16_LE RSD_U16_LE
#define RSD_U16_BE RSD_U16_BE
#define RSD_U8 RSD_U8
#define RSD_S8 RSD_S8
#define RSD_S16_NE RSD_S16_NE
#define RSD_U16_NE RSD_U16_NE
#define RSD_ALAW RSD_ALAW
#define RSD_MULAW RSD_MULAW
#define RSD_S32_LE RSD_S32_LE
#define RSD_S32_BE RSD_S32_BE
#define RSD_S32_NE RSD_S32_NE
#define RSD_U32_LE RSD_U32_LE
#define RSD_U32_BE RSD_U32_BE
#define RSD_U32_NE RSD_U32_NE
#define RSD_DELAY_MS RSD_DELAY_MS
#define RSD_SAMPLESIZE RSD_SAMPLESIZE
#define RSD_EXEC RSD_EXEC
#define RSD_SIMPLE_START RSD_SIMPLE_START
#define RSD_NO_FMT RSD_NO_FMT
#define RSD_USES_OPAQUE_TYPE RSD_USES_OPAQUE_TYPE
#define RSD_USES_SAMPLESIZE_MEMBER RSD_USES_SAMPLESIZE_MEMBER
#define RSD_AUDIO_CALLBACK_T RSD_AUDIO_CALLBACK_T
#define RSD_ERROR_CALLBACK_T RSD_ERROR_CALLBACK_T
#define RSD_SET_CALLBACK RSD_SET_CALLBACK
#define RSD_CALLBACK_LOCK RSD_CALLBACK_LOCK
#define RSD_CALLBACK_UNLOCK RSD_CALLBACK_UNLOCK
/* End feature tests */
/* Defines sample formats available. Defaults to S16_LE should it never be set. */
enum rsd_format
{
RSD_NO_FMT = 0x0000,
RSD_S16_LE = 0x0001,
RSD_S16_BE = 0x0002,
RSD_U16_LE = 0x0004,
RSD_U16_BE = 0x0008,
RSD_U8 = 0x0010,
RSD_S8 = 0x0020,
RSD_S16_NE = 0x0040,
RSD_U16_NE = 0x0080,
RSD_ALAW = 0x0100,
RSD_MULAW = 0x0200,
RSD_S32_LE = 0x0400,
RSD_S32_BE = 0x0800,
RSD_S32_NE = 0x1000,
RSD_U32_LE = 0x2000,
RSD_U32_BE = 0x4000,
RSD_U32_NE = 0x8000
};
/* Defines operations that can be used with rsd_set_param() */
enum rsd_settings
{
RSD_SAMPLERATE = 0,
RSD_CHANNELS,
RSD_HOST,
RSD_PORT,
RSD_BUFSIZE,
RSD_LATENCY,
RSD_FORMAT,
RSD_IDENTITY
};
/* Audio callback for rsd_set_callback. Return -1 to trigger an error in the stream. */
typedef ssize_t (*rsd_audio_callback_t)(void *data, size_t bytes, void *userdata);
/* Error callback. Signals caller that stream has been stopped,
* either by audio callback returning -1 or stream was hung up. */
typedef void (*rsd_error_callback_t)(void *userdata);
/* Defines the main structure for use with the API. */
typedef struct rsound
{
struct
{
volatile int socket;
volatile int ctl_socket;
} conn;
char *host;
char *port;
char *buffer; /* Obsolete, but kept for backwards header compatibility. */
int conn_type;
volatile int buffer_pointer; /* Obsolete, but kept for backwards header compatibility. */
size_t buffer_size;
fifo_buffer_t *fifo_buffer;
volatile int thread_active;
int64_t total_written;
int64_t start_time;
volatile int has_written;
int bytes_in_buffer;
int delay_offset;
int max_latency;
struct
{
uint32_t latency;
uint32_t chunk_size;
} backend_info;
volatile int ready_for_data;
uint32_t rate;
uint32_t channels;
uint16_t format;
int samplesize;
struct
{
sthread_t *thread;
slock_t *mutex;
slock_t *cond_mutex;
scond_t *cond;
} thread;
char identity[256];
rsd_audio_callback_t audio_callback;
rsd_error_callback_t error_callback;
size_t cb_max_size;
void *cb_data;
slock_t *cb_lock;
} rsound_t;
/* -- API --
All functions (except for rsd_write() return 0 for success, and -1 for error. errno is currently not set. */
/* Initializes an rsound_t structure. To make sure no memory leaks occur, you need to rsd_free() it after use.
A typical use of the API is as follows:
rsound_t *rd;
rsd_init(&rd);
rsd_set_param(rd, RSD_HOST, "foohost");
*sets more params*
rsd_start(rd);
rsd_write(rd, buf, size);
rsd_stop(rd);
rsd_free(rd);
*/
int rsd_init (rsound_t **rd);
/* This is a simpler function that initializes an rsound struct, sets params as given,
and starts the stream. Should this function fail, the structure will stay uninitialized.
Should NULL be passed in either host, port or ident, defaults will be used. */
int rsd_simple_start (rsound_t **rd, const char* host, const char* port, const char* ident,
int rate, int channels, enum rsd_format format);
/* Sets params associated with an rsound_t. These options (int options) include:
RSD_HOST: Server to connect to. Expects (char *) in param.
If not set, will default to environmental variable RSD_SERVER or "localhost".
RSD_PORT: Set port. Expects (char *) in param.
If not set, will default to environmental variable RSD_PORT or "12345".
RSD_CHANNELS: Set number of audio channels. Expects (int *) in param. Mandatory.
RSD_SAMPLERATE: Set samplerate of audio stream. Expects (int *) in param. Mandatory.
RSD_BUFSIZE: Sets internal buffersize for the stream.
Might be overridden if too small.
Expects (int *) in param. Optional.
RSD_LATENCY: Sets maximum audio latency in milliseconds,
(must be used with rsd_delay_wait() or this will have no effect).
Most applications do not need this.
Might be overridden if too small.
Expects (int *) in param. Optional.
RSD_FORMAT: Sets sample format.
It defaults to S16_LE, so you probably will not use this.
Expects (int *) in param, with available values found in the format enum.
If invalid format is given, param might be changed to reflect the sample format the library will use.
RSD_IDENTITY: Sets an identity string associated with the client.
Takes a (char *) parameter with the stream name.
Will be truncated if longer than 256 bytes.
*/
int rsd_set_param (rsound_t *rd, enum rsd_settings option, void* param);
/* Enables use of the callback interface. This must be set when stream is not active.
When callback is active, use of the blocking interface is disabled.
Only valid functions to call after rsd_start() is stopping the stream with either rsd_pause() or rsd_stop(). Calling any other function is undefined.
The callback is called at regular intervals and is asynchronous, so thread safety must be ensured by the caller.
If not enough data can be given to the callback, librsound will fill the rest of the callback data with silence.
librsound will attempt to obey latency information given with RSD_LATENCY as given before calling rsd_start().
max_size signifies the maximum size that will ever be requested by librsound. Set this to 0 to let librsound decide the maximum size.
Should an error occur to the stream, err_callback will be called, and the stream will be stopped. The stream can be started again.
Callbacks can be disabled by setting callbacks to NULL. */
void rsd_set_callback (rsound_t *rd, rsd_audio_callback_t callback, rsd_error_callback_t err_callback, size_t max_size, void *userdata);
/* Lock and unlock the callback. When the callback lock is aquired, the callback is guaranteed to not be executing.
The lock has to be unlocked afterwards.
Attemping to call several rsd_callback_lock() in succession might cause a deadlock.
The lock should be held for as short period as possible.
Try to avoid calling code that may block when holding the lock. */
void rsd_callback_lock (rsound_t *rd);
void rsd_callback_unlock (rsound_t *rd);
/* Establishes connection to server. Might fail if connection can't be established or that one of
the mandatory options isn't set in rsd_set_param(). This needs to be called after params have been set
with rsd_set_param(), and before rsd_write(). */
int rsd_start (rsound_t *rd);
/* Shuts down the rsound data structures, but returns the file descriptor associated with the connection.
The control socket will be shut down. If this function returns a negative number, the exec failed,
but the data structures will not be teared down.
Should a valid file descriptor be returned, it will always be blocking.
This call will block until all internal buffers have been sent to the network. */
int rsd_exec (rsound_t *rd);
/* Disconnects from server. All audio data still in network buffer and other buffers will be dropped.
To continue playing, you will need to rsd_start() again. */
int rsd_stop (rsound_t *rd);
/* Writes from buf to the internal buffer. Might fail if no connection is established,
or there was an unexpected error. This function will block until all data has
been written to the buffer. This function will return the number of bytes written to the buffer,
or 0 should it fail (disconnection from server). You will have to restart the stream again should this occur. */
size_t rsd_write (rsound_t *rd, const void* buf, size_t size);
/* Gets the position of the buffer pointer.
Not really interesting for normal applications.
Might be useful for implementing rsound on top of other blocking APIs.
*NOTE* This function is deprecated, it should not be used in new applications. */
size_t rsd_pointer (rsound_t *rd);
/* Aquires how much data can be written to the buffer without blocking */
size_t rsd_get_avail (rsound_t *rd);
/* Aquires the latency at the moment for the audio stream. It is measured in bytes. Useful for syncing video and audio. */
size_t rsd_delay (rsound_t *rd);
/* Utility for returning latency in milliseconds. */
size_t rsd_delay_ms (rsound_t *rd);
/* Returns bytes per sample */
int rsd_samplesize(rsound_t *rd);
/* Will sleep until latency of stream reaches maximum allowed latency defined earlier by rsd_set_param - RSD_LATENCY
Useful for hard headed blocking I/O design where user defined latency is needed. If rsd_set_param hasn't been set
with RSD_LATENCY, this function will do nothing. */
void rsd_delay_wait(rsound_t *rd);
/* Pauses or unpauses a stream. pause -> enable = 1
This function essentially calls on start() and stop(). This behavior might be changed later. */
int rsd_pause (rsound_t *rd, int enable);
/* Frees an rsound_t struct. Make sure that the stream is properly closed down with rsd_stop() before calling rsd_free(). */
int rsd_free (rsound_t *rd);
RETRO_END_DECLS
#endif

View File

@ -1,118 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2015 - Michael Lelli
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <unistd.h>
#include <boolean.h>
#include "../../retroarch.h"
/* forward declarations */
unsigned RWebAudioSampleRate(void);
void *RWebAudioInit(unsigned latency);
ssize_t RWebAudioWrite(const void *buf, size_t size);
bool RWebAudioStop(void);
bool RWebAudioStart(void);
void RWebAudioSetNonblockState(bool state);
void RWebAudioFree(void);
size_t RWebAudioWriteAvail(void);
size_t RWebAudioBufferSize(void);
static bool rwebaudio_is_paused;
static void rwebaudio_free(void *data)
{
RWebAudioFree();
}
static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
void *data = RWebAudioInit(latency);
(void)device;
(void)rate;
if (data)
*new_rate = RWebAudioSampleRate();
return data;
}
static ssize_t rwebaudio_write(void *data, const void *buf, size_t size)
{
(void)data;
return RWebAudioWrite(buf, size);
}
static bool rwebaudio_stop(void *data)
{
(void)data;
rwebaudio_is_paused = true;
return RWebAudioStop();
}
static void rwebaudio_set_nonblock_state(void *data, bool state)
{
(void)data;
RWebAudioSetNonblockState(state);
}
static bool rwebaudio_alive(void *data)
{
(void)data;
return !rwebaudio_is_paused;
}
static bool rwebaudio_start(void *data, bool is_shutdown)
{
(void)data;
rwebaudio_is_paused = false;
return RWebAudioStart();
}
static size_t rwebaudio_write_avail(void *data)
{
(void)data;
return RWebAudioWriteAvail();
}
static size_t rwebaudio_buffer_size(void *data)
{
(void)data;
return RWebAudioBufferSize();
}
static bool rwebaudio_use_float(void *data)
{
(void)data;
return true;
}
audio_driver_t audio_rwebaudio = {
rwebaudio_init,
rwebaudio_write,
rwebaudio_stop,
rwebaudio_start,
rwebaudio_alive,
rwebaudio_set_nonblock_state,
rwebaudio_free,
rwebaudio_use_float,
"rwebaudio",
NULL,
NULL,
rwebaudio_write_avail,
rwebaudio_buffer_size,
};

View File

@ -1,275 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <string.h>
#include <boolean.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#include <retro_inline.h>
#include <retro_math.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "SDL.h"
#include "SDL_audio.h"
typedef struct sdl_audio
{
bool nonblock;
bool is_paused;
#ifdef HAVE_THREADS
slock_t *lock;
scond_t *cond;
#endif
fifo_buffer_t *buffer;
} sdl_audio_t;
static void sdl_audio_cb(void *data, Uint8 *stream, int len)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
size_t avail = fifo_read_avail(sdl->buffer);
size_t write_size = len > (int)avail ? avail : len;
fifo_read(sdl->buffer, stream, write_size);
#ifdef HAVE_THREADS
scond_signal(sdl->cond);
#endif
/* If underrun, fill rest with silence. */
memset(stream + write_size, 0, len - write_size);
}
static INLINE int find_num_frames(int rate, int latency)
{
int frames = (rate * latency) / 1000;
/* SDL only likes 2^n sized buffers. */
return next_pow2(frames);
}
static void *sdl_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
int frames;
size_t bufsize;
SDL_AudioSpec out;
SDL_AudioSpec spec = {0};
void *tmp = NULL;
sdl_audio_t *sdl = NULL;
(void)device;
if (SDL_WasInit(0) == 0)
{
if (SDL_Init(SDL_INIT_AUDIO) < 0)
return NULL;
}
else if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
return NULL;
sdl = (sdl_audio_t*)calloc(1, sizeof(*sdl));
if (!sdl)
return NULL;
/* We have to buffer up some data ourselves, so we let SDL
* carry approximately half of the latency.
*
* SDL double buffers audio and we do as well. */
frames = find_num_frames(rate, latency / 4);
spec.freq = rate;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.samples = frames; /* This is in audio frames, not samples ... :( */
spec.callback = sdl_audio_cb;
spec.userdata = sdl;
if (SDL_OpenAudio(&spec, &out) < 0)
{
RARCH_ERR("[SDL audio]: Failed to open SDL audio: %s\n", SDL_GetError());
goto error;
}
*new_rate = out.freq;
#ifdef HAVE_THREADS
sdl->lock = slock_new();
sdl->cond = scond_new();
#endif
RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n",
latency, (int)(out.samples * 4 * 1000 / (*new_rate)));
/* Create a buffer twice as big as needed and prefill the buffer. */
bufsize = out.samples * 4 * sizeof(int16_t);
tmp = calloc(1, bufsize);
sdl->buffer = fifo_new(bufsize);
if (tmp)
{
fifo_write(sdl->buffer, tmp, bufsize);
free(tmp);
}
SDL_PauseAudio(0);
return sdl;
error:
free(sdl);
return NULL;
}
static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
{
ssize_t ret = 0;
sdl_audio_t *sdl = (sdl_audio_t*)data;
if (sdl->nonblock)
{
size_t avail, write_amt;
SDL_LockAudio();
avail = fifo_write_avail(sdl->buffer);
write_amt = avail > size ? size : avail;
fifo_write(sdl->buffer, buf, write_amt);
SDL_UnlockAudio();
ret = write_amt;
}
else
{
size_t written = 0;
while (written < size)
{
size_t avail;
SDL_LockAudio();
avail = fifo_write_avail(sdl->buffer);
if (avail == 0)
{
SDL_UnlockAudio();
#ifdef HAVE_THREADS
slock_lock(sdl->lock);
scond_wait(sdl->cond, sdl->lock);
slock_unlock(sdl->lock);
#endif
}
else
{
size_t write_amt = size - written > avail ? avail : size - written;
fifo_write(sdl->buffer, (const char*)buf + written, write_amt);
SDL_UnlockAudio();
written += write_amt;
}
}
ret = written;
}
return ret;
}
static bool sdl_audio_stop(void *data)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
sdl->is_paused = true;
SDL_PauseAudio(1);
return true;
}
static bool sdl_audio_alive(void *data)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
if (!sdl)
return false;
return !sdl->is_paused;
}
static bool sdl_audio_start(void *data, bool is_shutdown)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
sdl->is_paused = false;
SDL_PauseAudio(0);
return true;
}
static void sdl_audio_set_nonblock_state(void *data, bool state)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
if (sdl)
sdl->nonblock = state;
}
static void sdl_audio_free(void *data)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO);
if (sdl)
{
fifo_free(sdl->buffer);
#ifdef HAVE_THREADS
slock_free(sdl->lock);
scond_free(sdl->cond);
#endif
}
free(sdl);
}
static bool sdl_audio_use_float(void *data)
{
(void)data;
return false;
}
static size_t sdl_audio_write_avail(void *data)
{
/* stub */
(void)data;
return 0;
}
audio_driver_t audio_sdl = {
sdl_audio_init,
sdl_audio_write,
sdl_audio_stop,
sdl_audio_start,
sdl_audio_alive,
sdl_audio_set_nonblock_state,
sdl_audio_free,
sdl_audio_use_float,
#ifdef HAVE_SDL2
"sdl2",
#else
"sdl",
#endif
NULL,
NULL,
sdl_audio_write_avail,
NULL
};

View File

@ -1,369 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - misson20000
* Copyright (C) 2018 - m4xw
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdint.h>
#include "switch_audio_compat.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#ifdef HAVE_LIBNX
#define BUFFER_COUNT 5
#else
#define BUFFER_COUNT 3
#endif
static const int sample_rate = 48000;
static const int max_num_samples = sample_rate;
static const int num_channels = 2;
#ifndef HAVE_LIBNX
static const size_t sample_buffer_size = ((max_num_samples * num_channels * sizeof(uint16_t)) + 0xfff) & ~0xfff;
#endif
typedef struct
{
bool blocking;
bool is_paused;
uint64_t last_append;
unsigned latency;
compat_audio_out_buffer buffers[BUFFER_COUNT];
compat_audio_out_buffer *current_buffer;
#ifndef HAVE_LIBNX
audio_output_t output;
handle_t event;
#endif
} switch_audio_t;
static uint32_t switch_audio_data_size(void)
{
#ifdef HAVE_LIBNX
static const int framerate = 1000 / 30;
static const int samplecount = (sample_rate / framerate);
return (samplecount * num_channels * sizeof(uint16_t));
#else
return sample_buffer_size;
#endif
}
static size_t switch_audio_buffer_size(void *data)
{
(void) data;
#ifdef HAVE_LIBNX
return (switch_audio_data_size() + 0xfff) & ~0xfff;
#else
return sample_buffer_size;
#endif
}
static ssize_t switch_audio_write(void *data, const void *buf, size_t size)
{
size_t to_write = size;
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa)
return -1;
if (!swa->current_buffer)
{
uint32_t num;
if (switch_audio_ipc_output_get_released_buffer(swa, num) != 0)
{
RARCH_LOG("Failed to get released buffer?\n");
return -1;
}
if (num < 1)
swa->current_buffer = NULL;
if (!swa->current_buffer)
{
/* no buffer, nonblocking... */
if (!swa->blocking)
return 0;
while (!swa->current_buffer)
{
#ifndef HAVE_LIBNX
uint32_t handle_idx = 0;
#endif
num = 0;
#ifdef HAVE_LIBNX
if (audoutWaitPlayFinish(&swa->current_buffer, &num, UINT64_MAX) != 0) { }
#else
svcWaitSynchronization(&handle_idx, &swa->event, 1, 33333333);
svcResetSignal(swa->event);
if (switch_audio_ipc_output_get_released_buffer(swa, num) != 0)
return -1;
#endif
}
}
swa->current_buffer->data_size = 0;
}
if (to_write > switch_audio_buffer_size(NULL) - swa->current_buffer->data_size)
to_write = switch_audio_buffer_size(NULL) - swa->current_buffer->data_size;
#ifndef HAVE_LIBNX
memcpy(((uint8_t*) swa->current_buffer->sample_data) + swa->current_buffer->data_size, buf, to_write);
#else
memcpy(((uint8_t*) swa->current_buffer->buffer) + swa->current_buffer->data_size, buf, to_write);
#endif
swa->current_buffer->data_size += to_write;
swa->current_buffer->buffer_size = switch_audio_buffer_size(NULL);
if (swa->current_buffer->data_size > (48000 * swa->latency) / 1000)
{
if (switch_audio_ipc_output_append_buffer(swa, swa->current_buffer) != 0)
return -1;
swa->current_buffer = NULL;
}
swa->last_append = svcGetSystemTick();
return to_write;
}
static bool switch_audio_stop(void *data)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa)
return false;
/* TODO/FIXME - fix libnx codepath */
#ifndef HAVE_LIBNX
if (!swa->is_paused)
if (switch_audio_ipc_output_stop(swa) != 0)
return false;
swa->is_paused = true;
#endif
return true;
}
static bool switch_audio_start(void *data, bool is_shutdown)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa)
return false;
/* TODO/FIXME - fix libnx codepath */
#ifndef HAVE_LIBNX
if (swa->is_paused)
if (switch_audio_ipc_output_start(swa) != 0)
return false;
swa->is_paused = false;
#endif
return true;
}
static bool switch_audio_alive(void *data)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa)
return false;
return !swa->is_paused;
}
static void switch_audio_free(void *data)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa)
return;
#ifdef HAVE_LIBNX
if (!swa->is_paused)
audoutStopAudioOut();
audoutExit();
int i;
for (i = 0; i < BUFFER_COUNT; i++)
free(swa->buffers[i].buffer);
#else
audio_ipc_output_close(&swa->output);
audio_ipc_finalize();
#endif
free(swa);
}
static bool switch_audio_use_float(void *data)
{
(void) data;
return false; /* force INT16 */
}
static size_t switch_audio_write_avail(void *data)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (!swa || !swa->current_buffer)
return 0;
return swa->current_buffer->buffer_size;
}
static void switch_audio_set_nonblock_state(void *data, bool state)
{
switch_audio_t *swa = (switch_audio_t*) data;
if (swa)
swa->blocking = !state;
}
static void *switch_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
unsigned i;
char names[8][0x20];
#ifndef HAVE_LIBNX
uint32_t num_names = 0;
#endif
switch_audio_t *swa = (switch_audio_t*) calloc(1, sizeof(*swa));
if (!swa)
return NULL;
if (switch_audio_ipc_init() != 0)
goto fail;
#ifdef HAVE_LIBNX
if (audoutStartAudioOut() != 0)
goto fail;
#else
if (audio_ipc_list_outputs(&names[0], 8, &num_names) != 0)
goto fail_audio_ipc;
if (num_names != 1)
{
RARCH_ERR("got back more than one AudioOut\n");
goto fail_audio_ipc;
}
if (audio_ipc_open_output(names[0], &swa->output) != 0)
goto fail_audio_ipc;
if (swa->output.sample_rate != sample_rate)
{
RARCH_ERR("expected sample rate of %d, got sample rate of %d\n",
sample_rate, swa->output.sample_rate);
goto fail_audio_output;
}
if (swa->output.num_channels != num_channels)
{
RARCH_ERR("expected %d channels, got %d\n", num_channels,
swa->output.num_channels);
goto fail_audio_output;
}
if (swa->output.sample_format != PCM_INT16)
{
RARCH_ERR("expected PCM_INT16, got %d\n", swa->output.sample_format);
goto fail_audio_output;
}
if (audio_ipc_output_register_buffer_event(&swa->output, &swa->event) != 0)
goto fail_audio_output;
#endif
for (i = 0; i < BUFFER_COUNT; i++)
{
swa->buffers[i].buffer_size = switch_audio_buffer_size(NULL);
swa->buffers[i].data_size = switch_audio_data_size();
#ifdef HAVE_LIBNX
swa->buffers[i].next = NULL; /* Unused */
swa->buffers[i].data_offset = 0;
swa->buffers[i].buffer = memalign(0x1000, switch_audio_buffer_size(NULL));
if (!swa->buffers[i].buffer)
goto fail_audio_output;
memset(swa->buffers[i].buffer, 0, switch_audio_buffer_size(NULL));
#else
swa->buffers[i].ptr = &swa->buffers[i].sample_data;
swa->buffers[i].unknown = 0;
swa->buffers[i].sample_data = alloc_pages(sample_buffer_size, switch_audio_buffer_size(NULL), NULL);
if (!swa->buffers[i].sample_data)
goto fail_audio_output;
#endif
if (switch_audio_ipc_output_append_buffer(swa, &swa->buffers[i]) != 0)
goto fail_audio_output;
}
#ifdef HAVE_LIBNX
*new_rate = audoutGetSampleRate();
#else
*new_rate = swa->output.sample_rate;
#endif
swa->current_buffer = NULL;
swa->latency = latency;
swa->last_append = svcGetSystemTick();
swa->blocking = block_frames;
swa->is_paused = true;
RARCH_LOG("[Audio]: Audio initialized\n");
return swa;
fail_audio_output:
/* TODO/FIXME - fix libnx codepath */
#ifndef HAVE_LIBNX
audio_ipc_output_close(&swa->output);
fail_audio_ipc:
#endif
/* TODO/FIXME - fix libnx codepath */
#ifndef HAVE_LIBNX
audio_ipc_finalize();
#endif
fail:
if (swa)
free(swa);
return NULL;
}
audio_driver_t audio_switch = {
switch_audio_init,
switch_audio_write,
switch_audio_stop,
switch_audio_start,
switch_audio_alive,
switch_audio_set_nonblock_state,
switch_audio_free,
switch_audio_use_float,
"switch",
NULL, /* device_list_new */
NULL, /* device_list_free */
switch_audio_write_avail,
switch_audio_buffer_size, /* buffer_size */
};

View File

@ -1,97 +0,0 @@
#ifndef _SWITCH_AUDIO_COMPAT_H
#define _SWITCH_AUDIO_COMPAT_H
#ifdef HAVE_LIBNX
#include <switch.h>
#else
#include <libtransistor/nx.h>
#endif
#ifdef HAVE_LIBNX
/* libnx definitions */
/* threading */
typedef Mutex compat_mutex;
typedef Thread compat_thread;
typedef CondVar compat_condvar;
#define compat_thread_create(thread, func, data, stack_size, prio, cpu) \
threadCreate(thread, func, data, NULL, stack_size, prio, cpu)
#define compat_thread_start(thread) \
threadStart(thread)
#define compat_thread_join(thread) \
threadWaitForExit(thread)
#define compat_thread_close(thread) \
threadClose(thread)
#define compat_mutex_create(mutex) \
mutexInit(mutex)
#define compat_mutex_lock(mutex) \
mutexLock(mutex)
#define compat_mutex_unlock(mutex) \
mutexUnlock(mutex)
#define compat_condvar_create(condvar) \
condvarInit(condvar)
#define compat_condvar_wait(condvar, mutex) \
condvarWait(condvar, mutex)
#define compat_condvar_wake_all(condvar) \
condvarWakeAll(condvar)
/* audio */
typedef AudioOutBuffer compat_audio_out_buffer;
#define switch_audio_ipc_init audoutInitialize
#define switch_audio_ipc_finalize audoutExit
#define switch_audio_ipc_output_get_released_buffer(a, b) audoutGetReleasedAudioOutBuffer(&a->current_buffer, &b)
#define switch_audio_ipc_output_append_buffer(a, b) audoutAppendAudioOutBuffer(b)
#define switch_audio_ipc_output_stop(a) audoutStopAudioOut()
#define switch_audio_ipc_output_start(a) audoutStartAudioOut()
#ifndef UINT64_MAX
#define UINT64_MAX U64_MAX
#endif
#else
/* libtransistor definitions */
typedef result_t Result;
#define R_FAILED(r) ((r) != RESULT_OK)
/* threading */
typedef trn_mutex_t compat_mutex;
typedef trn_thread_t compat_thread;
typedef trn_condvar_t compat_condvar;
#define compat_thread_create(thread, func, data, stack_size, prio, cpu) \
trn_thread_create(thread, func, data, prio, cpu, stack_size, NULL)
#define compat_thread_start(thread) \
trn_thread_start(thread)
#define compat_thread_join(thread) \
trn_thread_join(thread, -1)
#define compat_thread_close(thread) \
trn_thread_destroy(thread)
#define compat_mutex_create(mutex) \
trn_mutex_create(mutex)
#define compat_mutex_lock(mutex) \
trn_mutex_lock(mutex)
#define compat_mutex_unlock(mutex) \
trn_mutex_unlock(mutex)
#define compat_condvar_create(condvar) \
trn_condvar_create(condvar)
#define compat_condvar_wait(condvar, mutex) \
trn_condvar_wait(condvar, mutex, -1)
#define compat_condvar_wake_all(condvar) \
trn_condvar_signal(condvar, -1)
/* audio */
typedef audio_output_buffer_t compat_audio_out_buffer;
#define switch_audio_ipc_init audio_ipc_init
#define switch_audio_ipc_finalize audio_ipc_finalize
#define switch_audio_ipc_output_get_released_buffer(a, b) audio_ipc_output_get_released_buffer(&a->output, &b, &a->current_buffer)
#define switch_audio_ipc_output_append_buffer(a, b) audio_ipc_output_append_buffer(&a->output, b)
#define switch_audio_ipc_output_stop(a) audio_ipc_output_stop(&a->output)
#define switch_audio_ipc_output_start(a) audio_ipc_output_start(&a->output)
#endif
#endif

View File

@ -1,368 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2019 - misson20000
* Copyright (C) 2019 - m4xw
* Copyright (C) 2019 - lifajucejo
* Copyright (C) 2019 - p-sam
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdint.h>
#include <switch.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#define BUFFER_COUNT 5
static const int sample_rate = 48000;
static const int num_channels = 2;
static const uint8_t sink_channels[] = { 0, 1 };
static const AudioRendererConfig audio_renderer_config =
{
.output_rate = AudioRendererOutputRate_48kHz,
.num_voices = 24,
.num_effects = 0,
.num_sinks = 1,
.num_mix_objs = 1,
.num_mix_buffers = 2,
};
typedef struct
{
AudioDriver drv;
void* mempool;
AudioDriverWaveBuf wavebufs[BUFFER_COUNT];
AudioDriverWaveBuf* current_wavebuf;
void* current_pool_ptr;
size_t current_size;
size_t buffer_size;
size_t samples;
Mutex update_lock;
bool nonblock;
} libnx_audren_t;
static void *libnx_audren_audio_init(
const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
unsigned i, j;
libnx_audren_t *aud;
Result rc;
int mpid;
size_t mempool_size;
unsigned real_latency;
RARCH_LOG("[Audio]: Using libnx_audren driver\n");
aud = (libnx_audren_t*)calloc(1, sizeof(libnx_audren_t));
if (!aud)
{
RARCH_ERR("[Audio]: struct alloc failed\n");
goto fail;
}
real_latency = MAX(5, latency);
RARCH_LOG("[Audio]: real_latency is %u\n", real_latency);
aud->nonblock = !block_frames;
aud->buffer_size = (real_latency * sample_rate / 1000);
aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t));
aud->current_size = 0;
*new_rate = sample_rate;
mempool_size = (aud->buffer_size * BUFFER_COUNT + (AUDREN_MEMPOOL_ALIGNMENT-1)) &~ (AUDREN_MEMPOOL_ALIGNMENT-1);
aud->mempool = memalign(AUDREN_MEMPOOL_ALIGNMENT, mempool_size);
if (!aud->mempool)
{
RARCH_ERR("[Audio]: mempool alloc failed\n");
goto fail;
}
rc = audrenInitialize(&audio_renderer_config);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrenInitialize: %x\n", rc);
goto fail;
}
rc = audrvCreate(&aud->drv, &audio_renderer_config, num_channels);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrvCreate: %x\n", rc);
goto fail_init;
}
for(i = 0; i < BUFFER_COUNT; i++)
{
aud->wavebufs[i].data_raw = aud->mempool;
aud->wavebufs[i].size = mempool_size;
aud->wavebufs[i].start_sample_offset = i * aud->samples;
aud->wavebufs[i].end_sample_offset = aud->wavebufs[i].start_sample_offset + aud->samples;
}
aud->current_wavebuf = NULL;
mpid = audrvMemPoolAdd(&aud->drv, aud->mempool, mempool_size);
audrvMemPoolAttach(&aud->drv, mpid);
audrvDeviceSinkAdd(&aud->drv, AUDREN_DEFAULT_DEVICE_NAME, num_channels, sink_channels);
rc = audrenStartAudioRenderer();
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrenStartAudioRenderer: %x\n", rc);
}
audrvVoiceInit(&aud->drv, 0, num_channels, PcmFormat_Int16, sample_rate);
audrvVoiceSetDestinationMix(&aud->drv, 0, AUDREN_FINAL_MIX_ID);
for(i = 0; i < num_channels; i++)
{
for(j = 0; j < num_channels; j++)
{
audrvVoiceSetMixFactor(&aud->drv, 0, i == j ? 1.0f : 0.0f, i, j);
}
}
mutexInit(&aud->update_lock);
*new_rate = sample_rate;
return aud;
fail_init:
audrenExit();
fail:
if (aud)
{
if (aud->mempool)
free(aud->mempool);
free(aud);
}
return NULL;
}
static size_t libnx_audren_audio_buffer_size(void *data)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return 0;
return aud->buffer_size;
}
static ssize_t libnx_audren_audio_get_free_wavebuf_idx(libnx_audren_t* aud)
{
unsigned i;
for (i = 0; i < BUFFER_COUNT; i++)
{
if (
aud->wavebufs[i].state == AudioDriverWaveBufState_Free
|| aud->wavebufs[i].state == AudioDriverWaveBufState_Done)
return i;
}
return -1;
}
static size_t libnx_audren_audio_append(
libnx_audren_t* aud, const void *buf, size_t size)
{
void *dstbuf = NULL;
ssize_t free_idx = -1;
if (!aud->current_wavebuf)
{
free_idx = libnx_audren_audio_get_free_wavebuf_idx(aud);
if (free_idx == -1)
return 0;
aud->current_wavebuf = &aud->wavebufs[free_idx];
aud->current_pool_ptr = aud->mempool + (free_idx * aud->buffer_size);
aud->current_size = 0;
}
if (size > aud->buffer_size - aud->current_size)
size = aud->buffer_size - aud->current_size;
dstbuf = aud->current_pool_ptr + aud->current_size;
memcpy(dstbuf, buf, size);
armDCacheFlush(dstbuf, size);
aud->current_size += size;
if (aud->current_size == aud->buffer_size)
{
audrvVoiceAddWaveBuf(&aud->drv, 0, aud->current_wavebuf);
mutexLock(&aud->update_lock);
audrvUpdate(&aud->drv);
mutexUnlock(&aud->update_lock);
if (!audrvVoiceIsPlaying(&aud->drv, 0))
{
audrvVoiceStart(&aud->drv, 0);
}
aud->current_wavebuf = NULL;
}
return size;
}
static ssize_t libnx_audren_audio_write(void *data,
const void *buf, size_t size)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
size_t written = 0;
if (!aud)
return -1;
if (aud->nonblock)
{
while(written < size)
{
written += libnx_audren_audio_append(
aud, buf + written, size - written);
if (written != size)
break;
}
}
else
{
while(written < size)
{
written += libnx_audren_audio_append(
aud, buf + written, size - written);
if (written != size)
{
mutexLock(&aud->update_lock);
audrvUpdate(&aud->drv);
mutexUnlock(&aud->update_lock);
audrenWaitFrame();
}
}
}
return written;
}
static bool libnx_audren_audio_stop(void *data)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return false;
audrvVoiceStop(&aud->drv, 0);
return true;
}
static bool libnx_audren_audio_start(void *data, bool is_shutdown)
{
(void)is_shutdown;
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return false;
audrvVoiceStart(&aud->drv, 0);
return true;
}
static bool libnx_audren_audio_alive(void *data)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return false;
return true;
}
static void libnx_audren_audio_free(void *data)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return;
audrvVoiceStop(&aud->drv, 0);
audrvClose(&aud->drv);
audrenExit();
if (aud->mempool)
{
free(aud->mempool);
}
free(aud);
}
static bool libnx_audren_audio_use_float(void *data)
{
(void)data;
return false; /* force S16 */
}
static size_t libnx_audren_audio_write_avail(void *data)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
size_t avail;
if (!aud || !aud->current_wavebuf)
return 0;
avail = aud->buffer_size - aud->current_size;
return avail;
}
static void libnx_audren_audio_set_nonblock_state(void *data, bool state)
{
libnx_audren_t *aud = (libnx_audren_t*)data;
if (!aud)
return;
aud->nonblock = state;
}
audio_driver_t audio_switch_libnx_audren = {
libnx_audren_audio_init,
libnx_audren_audio_write,
libnx_audren_audio_stop,
libnx_audren_audio_start,
libnx_audren_audio_alive,
libnx_audren_audio_set_nonblock_state,
libnx_audren_audio_free,
libnx_audren_audio_use_float,
"switch_audren",
NULL, /* device_list_new */
NULL, /* device_list_free */
libnx_audren_audio_write_avail,
libnx_audren_audio_buffer_size,
};

View File

@ -1,440 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2019 - p-sam
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdint.h>
#include <switch.h>
#include <queues/fifo_queue.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
#define BUFFER_COUNT 5
static const int sample_rate = 48000;
static const int num_channels = 2;
static const uint8_t sink_channels[] = { 0, 1 };
static const size_t thread_stack_size = 1024 * 8;
static const int thread_preferred_cpu = 2;
static const AudioRendererConfig audio_renderer_config =
{
.output_rate = AudioRendererOutputRate_48kHz,
.num_voices = 24,
.num_effects = 0,
.num_sinks = 1,
.num_mix_objs = 1,
.num_mix_buffers = 2,
};
typedef struct
{
AudioDriver drv;
void* mempool;
AudioDriverWaveBuf wavebufs[BUFFER_COUNT];
size_t buffer_size;
size_t samples;
bool nonblock;
fifo_buffer_t* fifo;
Mutex fifo_lock;
CondVar fifo_condvar;
Mutex fifo_condlock;
Thread thread;
volatile bool running;
volatile bool paused;
} libnx_audren_thread_t;
static void thread_job(void* data)
{
unsigned i;
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available = 0;
size_t current_size = 0;
size_t written_tmp = 0;
AudioDriverWaveBuf* current_wavebuf = NULL;
void* current_pool_ptr = NULL;
void* dstbuf = NULL;
if (!aud)
return;
while (aud->running)
{
if (!current_wavebuf)
{
for (i = 0; i < BUFFER_COUNT; i++)
{
if (aud->wavebufs[i].state == AudioDriverWaveBufState_Free
|| aud->wavebufs[i].state == AudioDriverWaveBufState_Done)
{
current_wavebuf = &aud->wavebufs[i];
current_pool_ptr = aud->mempool + (i * aud->buffer_size);
current_size = 0;
break;
}
}
}
if (current_wavebuf)
{
mutexLock(&aud->fifo_lock);
available = aud->paused ? 0 : fifo_read_avail(aud->fifo);
written_tmp = MIN(available, aud->buffer_size - current_size);
dstbuf = current_pool_ptr + current_size;
if (written_tmp > 0)
fifo_read(aud->fifo, dstbuf, written_tmp);
mutexUnlock(&aud->fifo_lock);
if (written_tmp > 0)
{
condvarWakeAll(&aud->fifo_condvar);
current_size += written_tmp;
armDCacheFlush(dstbuf, written_tmp);
}
if (current_size == aud->buffer_size)
{
audrvVoiceAddWaveBuf(&aud->drv, 0, current_wavebuf);
audrvUpdate(&aud->drv);
if (!audrvVoiceIsPlaying(&aud->drv, 0))
{
audrvVoiceStart(&aud->drv, 0);
}
current_wavebuf = NULL;
}
svcSleepThread(1000UL);
}
else
{
audrvUpdate(&aud->drv);
audrenWaitFrame();
}
}
}
static void *libnx_audren_thread_audio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
unsigned i, j;
libnx_audren_thread_t *aud;
Result rc;
int mpid;
size_t mempool_size;
unsigned real_latency;
uint32_t thread_priority;
RARCH_LOG("[Audio]: Using libnx_audren_thread driver\n");
aud = (libnx_audren_thread_t*)calloc(1, sizeof(libnx_audren_thread_t));
if (!aud)
{
RARCH_ERR("[Audio]: struct alloc failed\n");
goto fail;
}
real_latency = MAX(latency, 5);
RARCH_LOG("[Audio]: real_latency is %u\n", real_latency);
aud->running = true;
aud->paused = false;
aud->nonblock = !block_frames;
aud->buffer_size = (real_latency * sample_rate / 1000);
aud->samples = (aud->buffer_size / num_channels / sizeof(int16_t));
mempool_size = (aud->buffer_size * BUFFER_COUNT +
(AUDREN_MEMPOOL_ALIGNMENT-1)) &~ (AUDREN_MEMPOOL_ALIGNMENT-1);
aud->mempool = memalign(AUDREN_MEMPOOL_ALIGNMENT, mempool_size);
if (!aud->mempool)
{
RARCH_ERR("[Audio]: mempool alloc failed\n");
goto fail;
}
rc = audrenInitialize(&audio_renderer_config);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrenInitialize: %x\n", rc);
goto fail;
}
rc = audrvCreate(&aud->drv, &audio_renderer_config, num_channels);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrvCreate: %x\n", rc);
goto fail_init;
}
for (i = 0; i < BUFFER_COUNT; i++)
{
aud->wavebufs[i].data_raw = aud->mempool;
aud->wavebufs[i].size = mempool_size;
aud->wavebufs[i].start_sample_offset = i * aud->samples;
aud->wavebufs[i].end_sample_offset = aud->wavebufs[i].start_sample_offset + aud->samples;
}
mpid = audrvMemPoolAdd(&aud->drv, aud->mempool, mempool_size);
audrvMemPoolAttach(&aud->drv, mpid);
audrvDeviceSinkAdd(&aud->drv, AUDREN_DEFAULT_DEVICE_NAME,
num_channels, sink_channels);
rc = audrenStartAudioRenderer();
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: audrenStartAudioRenderer: %x\n", rc);
}
audrvVoiceInit(&aud->drv, 0, num_channels, PcmFormat_Int16, sample_rate);
audrvVoiceSetDestinationMix(&aud->drv, 0, AUDREN_FINAL_MIX_ID);
for (i = 0; i < num_channels; i++)
{
for (j = 0; j < num_channels; j++)
{
audrvVoiceSetMixFactor(&aud->drv, 0, i == j ? 1.0f : 0.0f, i, j);
}
}
aud->fifo = fifo_new(aud->buffer_size);
if (!aud->fifo)
{
RARCH_ERR("[Audio]: fifo alloc failed\n");
goto fail_drv;
}
mutexInit(&aud->fifo_lock);
condvarInit(&aud->fifo_condvar);
mutexInit(&aud->fifo_condlock);
svcGetThreadPriority(&thread_priority, CUR_THREAD_HANDLE);
rc = threadCreate(&aud->thread, &thread_job,
(void*)aud, NULL, thread_stack_size,
thread_priority - 1, thread_preferred_cpu);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: threadCreate: %x\n", rc);
goto fail_drv;
}
rc = threadStart(&aud->thread);
if (R_FAILED(rc))
{
RARCH_ERR("[Audio]: threadStart: %x\n", rc);
threadClose(&aud->thread);
goto fail_drv;
}
*new_rate = sample_rate;
return aud;
fail_drv:
audrvClose(&aud->drv);
fail_init:
audrenExit();
fail:
if (aud)
{
if (aud->mempool)
free(aud->mempool);
free(aud);
}
return NULL;
}
static size_t libnx_audren_thread_audio_buffer_size(void *data)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return 0;
return aud->buffer_size;
}
static ssize_t libnx_audren_thread_audio_write(void *data,
const void *buf, size_t size)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available, written, written_tmp;
if (!aud || !aud->running)
return -1;
if (aud->paused)
return 0;
if (aud->nonblock)
{
mutexLock(&aud->fifo_lock);
available = fifo_write_avail(aud->fifo);
written = MIN(available, size);
if (written > 0)
fifo_write(aud->fifo, buf, written);
mutexUnlock(&aud->fifo_lock);
}
else
{
written = 0;
while (written < size && aud->running)
{
mutexLock(&aud->fifo_lock);
available = fifo_write_avail(aud->fifo);
if (available)
{
written_tmp = MIN(size - written, available);
fifo_write(aud->fifo, (const char*)buf + written, written_tmp);
mutexUnlock(&aud->fifo_lock);
written += written_tmp;
}
else
{
mutexUnlock(&aud->fifo_lock);
mutexLock(&aud->fifo_condlock);
condvarWait(&aud->fifo_condvar, &aud->fifo_condlock);
mutexUnlock(&aud->fifo_condlock);
}
}
}
return written;
}
static bool libnx_audren_thread_audio_stop(void *data)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return false;
aud->paused = true;
return true;
}
static bool libnx_audren_thread_audio_start(void *data, bool is_shutdown)
{
(void)is_shutdown;
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return false;
aud->paused = false;
return true;
}
static bool libnx_audren_thread_audio_alive(void *data)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return false;
return true;
}
static void libnx_audren_thread_audio_free(void *data)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return;
aud->running = false;
mutexUnlock(&aud->fifo_lock);
threadWaitForExit(&aud->thread);
threadClose(&aud->thread);
audrvVoiceStop(&aud->drv, 0);
audrvClose(&aud->drv);
audrenExit();
if (aud->mempool)
{
free(aud->mempool);
}
if (aud->fifo)
{
fifo_clear(aud->fifo);
fifo_free(aud->fifo);
}
free(aud);
}
static bool libnx_audren_thread_audio_use_float(void *data)
{
(void)data;
return false; /* force S16 */
}
static size_t libnx_audren_thread_audio_write_avail(void *data)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
size_t available;
if (!aud)
return 0;
mutexLock(&aud->fifo_lock);
available = fifo_write_avail(aud->fifo);
mutexUnlock(&aud->fifo_lock);
return available;
}
static void libnx_audren_thread_audio_set_nonblock_state(void *data, bool state)
{
libnx_audren_thread_t *aud = (libnx_audren_thread_t*)data;
if (!aud)
return;
aud->nonblock = state;
}
audio_driver_t audio_switch_libnx_audren_thread = {
libnx_audren_thread_audio_init,
libnx_audren_thread_audio_write,
libnx_audren_thread_audio_stop,
libnx_audren_thread_audio_start,
libnx_audren_thread_audio_alive,
libnx_audren_thread_audio_set_nonblock_state,
libnx_audren_thread_audio_free,
libnx_audren_thread_audio_use_float,
"switch_audren_thread",
NULL, /* device_list_new */
NULL, /* device_list_free */
libnx_audren_thread_audio_write_avail,
libnx_audren_thread_audio_buffer_size,
};

View File

@ -1,448 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - misson20000
* Copyright (C) 2018 - m4xw
* Copyright (C) 2018 - lifajucejo
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <string.h>
#include <malloc.h>
#include <stdint.h>
#include <sys/unistd.h>
#ifdef HAVE_LIBNX
#include <switch.h>
#else
#include <libtransistor/nx.h>
#endif
#include <queues/fifo_queue.h>
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../tasks/tasks_internal.h"
#include "switch_audio_compat.h"
static const size_t thread_stack_size = 1024 * 8;
static const int thread_preferred_cpu = 2;
static const int channel_count = 2;
static const size_t sample_size = sizeof(uint16_t);
#define AUDIO_BUFFER_COUNT 2
typedef struct
{
fifo_buffer_t* fifo;
compat_mutex fifoLock;
compat_condvar cond;
compat_mutex condLock;
size_t fifoSize;
volatile bool running;
bool nonblock;
bool is_paused;
compat_audio_out_buffer buffers[AUDIO_BUFFER_COUNT];
compat_thread thread;
unsigned latency;
uint32_t sampleRate;
#ifndef HAVE_LIBNX
audio_output_t output;
handle_t event;
#endif
} switch_thread_audio_t;
static void mainLoop(void* data)
{
Result rc;
uint32_t released_out_count = 0;
compat_audio_out_buffer *released_out_buffer = NULL;
switch_thread_audio_t *swa = (switch_thread_audio_t*)data;
if (!swa)
return;
RARCH_LOG("[Audio]: start mainLoop cpu %u tid %u\n", svcGetCurrentProcessorNumber(), swa->thread.handle);
while (swa->running)
{
size_t buf_avail, avail, to_write;
if (!released_out_buffer)
{
#ifdef HAVE_LIBNX
rc = audoutWaitPlayFinish(&released_out_buffer, &released_out_count, UINT64_MAX);
#else
uint32_t handle_idx = 0;
svcWaitSynchronization(&handle_idx, &swa->event, 1, 33333333);
svcResetSignal(swa->event);
rc = audio_ipc_output_get_released_buffer(&swa->output, &released_out_count, &released_out_buffer);
#endif
if (R_FAILED(rc))
{
swa->running = false;
RARCH_LOG("[Audio]: audoutGetReleasedAudioOutBuffer failed: %d\n", (int)rc);
break;
}
released_out_buffer->data_size = 0;
}
buf_avail = released_out_buffer->buffer_size - released_out_buffer->data_size;
compat_mutex_lock(&swa->fifoLock);
avail = fifo_read_avail(swa->fifo);
to_write = MIN(avail, buf_avail);
if (to_write > 0)
{
uint8_t *base;
#ifdef HAVE_LIBNX
base = (uint8_t*) released_out_buffer->buffer;
#else
base = (uint8_t*) released_out_buffer->sample_data;
#endif
fifo_read(swa->fifo, base + released_out_buffer->data_size, to_write);
}
compat_mutex_unlock(&swa->fifoLock);
compat_condvar_wake_all(&swa->cond);
released_out_buffer->data_size += to_write;
if (released_out_buffer->data_size >= released_out_buffer->buffer_size / 2)
{
rc = switch_audio_ipc_output_append_buffer(swa, released_out_buffer);
if (R_FAILED(rc))
{
RARCH_LOG("[Audio]: audoutAppendAudioOutBuffer failed: %d\n", (int)rc);
}
released_out_buffer = NULL;
}
else
svcSleepThread(16000000); /* 16ms */
}
}
static void *switch_thread_audio_init(const char *device, unsigned rate, unsigned latency, unsigned block_frames, unsigned *new_rate)
{
Result rc;
unsigned i;
uint32_t prio;
#ifndef HAVE_LIBNX
char names[8][0x20];
uint32_t num_names = 0;
#endif
switch_thread_audio_t *swa = (switch_thread_audio_t *)calloc(1, sizeof(*swa));
if (!swa)
return NULL;
swa->running = true;
swa->nonblock = true;
swa->is_paused = true;
swa->latency = MAX(latency, 8);
rc = switch_audio_ipc_init();
if (R_FAILED(rc))
{
RARCH_LOG("[Audio]: audio init failed %d\n", (int)rc);
free(swa);
return NULL;
}
#ifdef HAVE_LIBNX
rc = audoutStartAudioOut();
if (R_FAILED(rc))
{
RARCH_LOG("[Audio]: audio start init failed: %d\n", (int)rc);
goto fail_audio_ipc;
}
swa->sampleRate = audoutGetSampleRate();
#else
if (audio_ipc_list_outputs(&names[0], 8, &num_names) != RESULT_OK)
goto fail_audio_ipc;
if (num_names != 1)
{
RARCH_ERR("[Audio]: got back more than one AudioOut\n");
goto fail_audio_ipc;
}
if (audio_ipc_open_output(names[0], &swa->output) != RESULT_OK)
goto fail_audio_ipc;
swa->sampleRate = swa->output.sample_rate;
if (swa->output.num_channels != 2)
{
RARCH_ERR("expected %d channels, got %d\n", 2,
swa->output.num_channels);
goto fail_audio_output;
}
if (swa->output.sample_format != PCM_INT16)
{
RARCH_ERR("expected PCM_INT16, got %d\n", swa->output.sample_format);
goto fail_audio_output;
}
if (audio_ipc_output_register_buffer_event(&swa->output, &swa->event) != 0)
goto fail_audio_output;
#endif
*new_rate = swa->sampleRate;
swa->fifoSize = (swa->sampleRate * sample_size * swa->latency) / 1000;
for (i = 0; i < AUDIO_BUFFER_COUNT; i++)
{
#ifdef HAVE_LIBNX
swa->buffers[i].next = NULL; /* Unused */
swa->buffers[i].data_offset = 0;
swa->buffers[i].buffer_size = swa->fifoSize;
swa->buffers[i].data_size = swa->buffers[i].buffer_size;
swa->buffers[i].buffer = memalign(0x1000, swa->buffers[i].buffer_size);
if (!swa->buffers[i].buffer)
goto fail;
memset(swa->buffers[i].buffer, 0, swa->buffers[i].buffer_size);
#else
swa->buffers[i].ptr = &swa->buffers[i].sample_data;
swa->buffers[i].unknown = 0;
swa->buffers[i].buffer_size = swa->fifoSize;
swa->buffers[i].data_size = swa->buffers[i].buffer_size;
swa->buffers[i].sample_data = alloc_pages(swa->buffers[i].buffer_size, swa->buffers[i].buffer_size, NULL);
if (!swa->buffers[i].sample_data)
goto fail_audio_output;
memset(swa->buffers[i].sample_data, 0, swa->buffers[i].buffer_size);
#endif
if (switch_audio_ipc_output_append_buffer(swa, &swa->buffers[i]) != 0)
goto fail_audio_output;
}
compat_mutex_create(&swa->fifoLock);
swa->fifo = fifo_new(swa->fifoSize);
compat_condvar_create(&swa->cond);
RARCH_LOG("[Audio]: switch_thread_audio_init device %s requested rate %hu rate %hu latency %hu block_frames %hu fifoSize %lu\n",
device, rate, swa->sampleRate, swa->latency, block_frames, swa->fifoSize);
svcGetThreadPriority(&prio, 0xffff8000);
rc = compat_thread_create(&swa->thread, &mainLoop, (void*)swa, thread_stack_size, prio - 1, thread_preferred_cpu);
if (R_FAILED(rc))
{
RARCH_LOG("[Audio]: thread creation failed create %u\n", swa->thread.handle);
swa->running = false;
return NULL;
}
if (R_FAILED(compat_thread_start(&swa->thread)))
{
RARCH_LOG("[Audio]: thread creation failed start %u\n", swa->thread.handle);
compat_thread_close(&swa->thread);
swa->running = false;
return NULL;
}
return swa;
fail_audio_output:
#ifndef HAVE_LIBNX
audio_ipc_output_close(&swa->output);
#endif
fail_audio_ipc:
switch_audio_ipc_finalize();
fail:
free(swa); // freeing a null ptr is valid
return NULL;
}
static bool switch_thread_audio_start(void *data, bool is_shutdown)
{
/* RARCH_LOG("[Audio]: switch_thread_audio_start\n"); */
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (!swa)
return false;
swa->is_paused = false;
return true;
}
static bool switch_thread_audio_stop(void *data)
{
switch_thread_audio_t* swa = (switch_thread_audio_t*)data;
if (!swa)
return false;
swa->is_paused = true;
return true;
}
static void switch_thread_audio_free(void *data)
{
unsigned i;
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (!swa)
return;
if (swa->running)
{
swa->running = false;
compat_thread_join(&swa->thread);
compat_thread_close(&swa->thread);
}
switch_audio_ipc_output_stop(swa);
switch_audio_ipc_finalize();
if (swa->fifo)
{
fifo_free(swa->fifo);
swa->fifo = NULL;
}
for (i = 0; i < ARRAY_SIZE(swa->buffers); i++)
{
#ifdef HAVE_LIBNX
free(swa->buffers[i].buffer);
#else
free_pages(swa->buffers[i].sample_data);
#endif
}
free(swa);
swa = NULL;
}
static ssize_t switch_thread_audio_write(void *data, const void *buf, size_t size)
{
size_t avail, written;
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (!swa || !swa->running)
return 0;
if (swa->nonblock)
{
compat_mutex_lock(&swa->fifoLock);
avail = fifo_write_avail(swa->fifo);
written = MIN(avail, size);
if (written > 0)
fifo_write(swa->fifo, buf, written);
compat_mutex_unlock(&swa->fifoLock);
}
else
{
written = 0;
while (written < size && swa->running)
{
compat_mutex_lock(&swa->fifoLock);
avail = fifo_write_avail(swa->fifo);
if (avail == 0)
{
compat_mutex_unlock(&swa->fifoLock);
compat_mutex_lock(&swa->condLock);
if (swa->running)
compat_condvar_wait(&swa->cond, &swa->condLock);
compat_mutex_unlock(&swa->condLock);
}
else
{
size_t write_amt = MIN(size - written, avail);
fifo_write(swa->fifo, (const char*)buf + written, write_amt);
compat_mutex_unlock(&swa->fifoLock);
written += write_amt;
}
}
}
return written;
}
static bool switch_thread_audio_alive(void *data)
{
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (!swa)
return false;
return !swa->is_paused;
}
static void switch_thread_audio_set_nonblock_state(void *data, bool state)
{
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (swa)
swa->nonblock = state;
}
static bool switch_thread_audio_use_float(void *data)
{
(void)data;
return false;
}
static size_t switch_thread_audio_write_avail(void *data)
{
size_t val;
switch_thread_audio_t* swa = (switch_thread_audio_t*)data;
compat_mutex_lock(&swa->fifoLock);
val = fifo_write_avail(swa->fifo);
compat_mutex_unlock(&swa->fifoLock);
return val;
}
size_t switch_thread_audio_buffer_size(void *data)
{
switch_thread_audio_t *swa = (switch_thread_audio_t *)data;
if (!swa)
return 0;
return swa->fifoSize;
}
audio_driver_t audio_switch_thread = {
switch_thread_audio_init,
switch_thread_audio_write,
switch_thread_audio_stop,
switch_thread_audio_start,
switch_thread_audio_alive,
switch_thread_audio_set_nonblock_state,
switch_thread_audio_free,
switch_thread_audio_use_float,
"switch_thread",
NULL, /* device_list_new */
NULL, /* device_list_free */
switch_thread_audio_write_avail,
switch_thread_audio_buffer_size
};
/* vim: set ts=3 sw=3 */

File diff suppressed because it is too large Load Diff

View File

@ -1,925 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include <string/stdstring.h>
#include "../common/mmdevice_common.h"
#include "../common/mmdevice_common_inline.h"
#include "../../retroarch.h"
#include "../../verbosity.h"
#include "../../configuration.h"
typedef struct
{
bool exclusive;
bool nonblock;
bool running;
size_t frame_size; /* 4 or 8 only */
size_t engine_buffer_size;
HANDLE write_event;
IMMDevice *device;
IAudioClient *client;
IAudioRenderClient *renderer;
fifo_buffer_t *buffer; /* NULL in unbuffered shared mode */
} wasapi_t;
static IMMDevice *wasapi_init_device(const char *id)
{
HRESULT hr;
UINT32 dev_count, i;
IMMDeviceEnumerator *enumerator = NULL;
IMMDevice *device = NULL;
IMMDeviceCollection *collection = NULL;
if (id)
{
RARCH_LOG("[WASAPI]: Initializing device %s ...\n", id);
}
else
{
RARCH_LOG("[WASAPI]: Initializing default device.. \n");
}
#ifdef __cplusplus
hr = CoCreateInstance(CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
IID_IMMDeviceEnumerator, (void **)&enumerator);
#else
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
#endif
if (FAILED(hr))
goto error;
if (id)
{
int32_t idx_found = -1;
struct string_list *list = (struct string_list*)mmdevice_list_new(NULL);
/* Search for device name first */
if (list)
{
if (list->elems)
{
unsigned i;
for (i = 0; i < list->size; i++)
{
RARCH_LOG("[WASAPI]: %d : %s\n", i, list->elems[i].data);
if (string_is_equal(id, list->elems[i].data))
{
idx_found = i;
break;
}
}
/* Index was not found yet based on name string,
* just assume id is a one-character number index. */
if (idx_found == -1 && isdigit(id[0]))
{
idx_found = strtoul(id, NULL, 0);
RARCH_LOG("[WASAPI]: Fallback, device index is a single number index instead: %d.\n", idx_found);
}
}
string_list_free(list);
}
if (idx_found == -1)
idx_found = 0;
hr = _IMMDeviceEnumerator_EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
if (FAILED(hr))
goto error;
hr = _IMMDeviceCollection_GetCount(collection, &dev_count);
if (FAILED(hr))
goto error;
for (i = 0; i < dev_count; ++i)
{
hr = _IMMDeviceCollection_Item(collection, i, &device);
if (FAILED(hr))
goto error;
if (i == idx_found)
break;
IFACE_RELEASE(device);
}
}
else
{
hr = _IMMDeviceEnumerator_GetDefaultAudioEndpoint(
enumerator, eRender, eConsole, &device);
if (FAILED(hr))
goto error;
}
if (!device)
goto error;
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
return device;
error:
IFACE_RELEASE(collection);
IFACE_RELEASE(enumerator);
if (id)
{
RARCH_WARN("[WASAPI]: Failed to initialize device.\n");
}
else
{
RARCH_ERR("[WASAPI]: Failed to initialize device.\n");
}
return NULL;
}
static unsigned wasapi_pref_rate(unsigned i)
{
const unsigned r[] = { 48000, 44100, 96000, 192000, 32000 };
if (i >= sizeof(r) / sizeof(unsigned))
return 0;
return r[i];
}
static void wasapi_set_format(WAVEFORMATEXTENSIBLE *wf,
bool float_fmt, unsigned rate)
{
wf->Format.nChannels = 2;
wf->Format.nSamplesPerSec = rate;
if (float_fmt)
{
wf->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;
wf->Format.nAvgBytesPerSec = rate * 8;
wf->Format.nBlockAlign = 8;
wf->Format.wBitsPerSample = 32;
wf->Format.cbSize = sizeof(WORD) + sizeof(DWORD) + sizeof(GUID);
wf->Samples.wValidBitsPerSample = 32;
wf->dwChannelMask = KSAUDIO_SPEAKER_STEREO;
wf->SubFormat = KSDATAFORMAT_SUBTYPE_IEEE_FLOAT;
}
else
{
wf->Format.wFormatTag = WAVE_FORMAT_PCM;
wf->Format.nAvgBytesPerSec = rate * 4;
wf->Format.nBlockAlign = 4;
wf->Format.wBitsPerSample = 16;
wf->Format.cbSize = 0;
}
}
static IAudioClient *wasapi_init_client_sh(IMMDevice *device,
bool *float_fmt, unsigned *rate, unsigned latency)
{
WAVEFORMATEXTENSIBLE wf;
int i, j;
IAudioClient *client = NULL;
bool float_fmt_res = *float_fmt;
unsigned rate_res = *rate;
HRESULT hr = _IMMDevice_Activate(device,
IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
if (FAILED(hr))
return NULL;
/* once for float, once for pcm (requested first) */
for (i = 0; i < 2; ++i)
{
rate_res = *rate;
if (i == 1)
float_fmt_res = !float_fmt_res;
/* for requested rate (first) and all preferred rates */
for (j = 0; rate_res; ++j)
{
RARCH_LOG("[WASAPI]: Initializing client (shared, %s, %uHz, %ums) ...\n",
float_fmt_res ? "float" : "pcm", rate_res, latency);
wasapi_set_format(&wf, float_fmt_res, rate_res);
#ifdef __cplusplus
hr = client->Initialize(AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
#else
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
#endif
if (hr == AUDCLNT_E_ALREADY_INITIALIZED)
{
HRESULT hr;
IFACE_RELEASE(client);
hr = _IMMDevice_Activate(device,
IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
if (FAILED(hr))
return NULL;
#ifdef __cplusplus
hr = client->Initialize(AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
#else
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
#endif
}
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
{
i = 2; /* break from outer loop too */
break;
}
RARCH_WARN("[WASAPI]: Unsupported format.\n");
rate_res = wasapi_pref_rate(j);
if (rate_res == *rate) /* requested rate is allready tested */
rate_res = wasapi_pref_rate(++j); /* skip it */
}
}
if (FAILED(hr))
goto error;
*float_fmt = float_fmt_res;
*rate = rate_res;
return client;
error:
IFACE_RELEASE(client);
return NULL;
}
static IAudioClient *wasapi_init_client_ex(IMMDevice *device,
bool *float_fmt, unsigned *rate, unsigned latency)
{
WAVEFORMATEXTENSIBLE wf;
int i, j;
IAudioClient *client = NULL;
bool float_fmt_res = *float_fmt;
unsigned rate_res = *rate;
REFERENCE_TIME minimum_period = 0;
REFERENCE_TIME buffer_duration = 0;
UINT32 buffer_length = 0;
HRESULT hr = _IMMDevice_Activate(device,
IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
if (FAILED(hr))
return NULL;
hr = _IAudioClient_GetDevicePeriod(client, NULL, &minimum_period);
if (FAILED(hr))
goto error;
/* buffer_duration is in 100ns units */
buffer_duration = latency * 10000.0;
if (buffer_duration < minimum_period)
buffer_duration = minimum_period;
/* once for float, once for pcm (requested first) */
for (i = 0; i < 2; ++i)
{
rate_res = *rate;
if (i == 1)
float_fmt_res = !float_fmt_res;
/* for requested rate (first) and all preferred rates */
for (j = 0; rate_res; ++j)
{
RARCH_LOG("[WASAPI]: Initializing client (exclusive, %s, %uHz, %ums) ...\n",
float_fmt_res ? "float" : "pcm", rate_res, latency);
wasapi_set_format(&wf, float_fmt_res, rate_res);
#ifdef __cplusplus
hr = client->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#else
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#endif
if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED)
{
hr = _IAudioClient_GetBufferSize(client, &buffer_length);
if (FAILED(hr))
goto error;
IFACE_RELEASE(client);
hr = _IMMDevice_Activate(device,
IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
if (FAILED(hr))
return NULL;
buffer_duration = 10000.0 * 1000.0 / rate_res * buffer_length + 0.5;
#ifdef __cplusplus
hr = client->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#else
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#endif
}
if (hr == AUDCLNT_E_ALREADY_INITIALIZED)
{
IFACE_RELEASE(client);
hr = _IMMDevice_Activate(device,
IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
if (FAILED(hr))
return NULL;
#ifdef __cplusplus
hr = client->Initialize(AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#else
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
#endif
}
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
{
if (hr == AUDCLNT_E_DEVICE_IN_USE)
goto error;
if (hr == AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED)
goto error;
i = 2; /* break from outer loop too */
break;
}
RARCH_WARN("[WASAPI]: Unsupported format.\n");
rate_res = wasapi_pref_rate(j);
if (rate_res == *rate) /* requested rate is allready tested */
rate_res = wasapi_pref_rate(++j); /* skip it */
}
}
if (FAILED(hr))
goto error;
*float_fmt = float_fmt_res;
*rate = rate_res;
return client;
error:
IFACE_RELEASE(client);
return NULL;
}
static IAudioClient *wasapi_init_client(IMMDevice *device, bool *exclusive,
bool *float_fmt, unsigned *rate, unsigned latency)
{
HRESULT hr;
IAudioClient *client;
double latency_res;
REFERENCE_TIME device_period = 0;
REFERENCE_TIME stream_latency = 0;
UINT32 buffer_length = 0;
if (*exclusive)
{
client = wasapi_init_client_ex(device, float_fmt, rate, latency);
if (!client)
{
client = wasapi_init_client_sh(device, float_fmt, rate, latency);
if (client)
*exclusive = false;
}
}
else
{
client = wasapi_init_client_sh(device, float_fmt, rate, latency);
if (!client)
{
client = wasapi_init_client_ex(device, float_fmt, rate, latency);
if (client)
*exclusive = true;
}
}
if (!client)
return NULL;
/* next calls are allowed to fail (we losing info only) */
if (*exclusive)
hr = _IAudioClient_GetDevicePeriod(client, NULL, &device_period);
else
hr = _IAudioClient_GetDevicePeriod(client, &device_period, NULL);
if (FAILED(hr))
{
RARCH_WARN("[WASAPI]: IAudioClient::GetDevicePeriod failed with error 0x%.8X.\n", hr);
}
if (!*exclusive)
{
hr = _IAudioClient_GetStreamLatency(client, &stream_latency);
if (FAILED(hr))
{
RARCH_WARN("[WASAPI]: IAudioClient::GetStreamLatency failed with error 0x%.8X.\n", hr);
}
}
hr = _IAudioClient_GetBufferSize(client, &buffer_length);
if (FAILED(hr))
{
RARCH_WARN("[WASAPI]: IAudioClient::GetBufferSize failed with error 0x%.8X.\n", hr);
}
if (*exclusive)
latency_res = (double)buffer_length * 1000.0 / (*rate);
else
latency_res = (double)(stream_latency + device_period) / 10000.0;
RARCH_LOG("[WASAPI]: Client initialized (%s, %s, %uHz, %.1fms).\n",
*exclusive ? "exclusive" : "shared",
*float_fmt ? "float" : "pcm", *rate, latency_res);
RARCH_LOG("[WASAPI]: Client's buffer length is %u frames (%.1fms).\n",
buffer_length, (double)buffer_length * 1000.0 / (*rate));
RARCH_LOG("[WASAPI]: Device period is %.1fms (%lld frames).\n",
(double)device_period / 10000.0, device_period * (*rate) / 10000000);
return client;
}
static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency,
unsigned u1, unsigned *u2)
{
HRESULT hr;
UINT32 frame_count = 0;
REFERENCE_TIME dev_period = 0;
BYTE *dest = NULL;
settings_t *settings = config_get_ptr();
bool float_format = settings->bools.audio_wasapi_float_format;
bool exclusive_mode = settings->bools.audio_wasapi_exclusive_mode;
int sh_buffer_length = settings->ints.audio_wasapi_sh_buffer_length;
wasapi_t *w = (wasapi_t*)calloc(1, sizeof(wasapi_t));
if (!w)
return NULL;
w->exclusive = exclusive_mode;
w->device = wasapi_init_device(dev_id);
if (!w->device && dev_id)
w->device = wasapi_init_device(NULL);
if (!w->device)
goto error;
w->client = wasapi_init_client(w->device,
&w->exclusive, &float_format, &rate, latency);
if (!w->client)
goto error;
hr = _IAudioClient_GetBufferSize(w->client, &frame_count);
if (FAILED(hr))
goto error;
w->frame_size = float_format ? 8 : 4;
w->engine_buffer_size = frame_count * w->frame_size;
if (w->exclusive)
{
w->buffer = fifo_new(w->engine_buffer_size);
if (!w->buffer)
goto error;
RARCH_LOG("[WASAPI]: Intermediate buffer length is %u frames (%.1fms).\n",
frame_count, (double)frame_count * 1000.0 / rate);
}
else if (sh_buffer_length)
{
if (sh_buffer_length < 0)
{
hr = _IAudioClient_GetDevicePeriod(w->client, &dev_period, NULL);
if (FAILED(hr))
goto error;
sh_buffer_length = dev_period * rate / 10000000;
}
w->buffer = fifo_new(sh_buffer_length * w->frame_size);
if (!w->buffer)
goto error;
RARCH_LOG("[WASAPI]: Intermediate buffer length is %u frames (%.1fms).\n",
sh_buffer_length, (double)sh_buffer_length * 1000.0 / rate);
}
else
{
RARCH_LOG("[WASAPI]: Intermediate buffer is off. \n");
}
w->write_event = CreateEventA(NULL, FALSE, FALSE, NULL);
if (!w->write_event)
goto error;
hr = _IAudioClient_SetEventHandle(w->client, w->write_event);
if (FAILED(hr))
goto error;
hr = _IAudioClient_GetService(w->client,
IID_IAudioRenderClient, (void**)&w->renderer);
if (FAILED(hr))
goto error;
hr = _IAudioRenderClient_GetBuffer(w->renderer, frame_count, &dest);
if (FAILED(hr))
goto error;
hr = _IAudioRenderClient_ReleaseBuffer(
w->renderer, frame_count,
AUDCLNT_BUFFERFLAGS_SILENT);
if (FAILED(hr))
goto error;
hr = _IAudioClient_Start(w->client);
if (FAILED(hr))
goto error;
w->running = true;
w->nonblock = !settings->bools.audio_sync;
return w;
error:
IFACE_RELEASE(w->renderer);
IFACE_RELEASE(w->client);
IFACE_RELEASE(w->device);
if (w->write_event)
CloseHandle(w->write_event);
if (w->buffer)
fifo_free(w->buffer);
free(w);
return NULL;
}
static bool wasapi_flush(wasapi_t * w, const void * data, size_t size)
{
BYTE *dest = NULL;
UINT32 frame_count = size / w->frame_size;
if (FAILED(_IAudioRenderClient_GetBuffer(
w->renderer, frame_count, &dest)))
return false;
memcpy(dest, data, size);
if (FAILED(_IAudioRenderClient_ReleaseBuffer(
w->renderer, frame_count,
0)))
return false;
return true;
}
static bool wasapi_flush_buffer(wasapi_t * w, size_t size)
{
BYTE *dest = NULL;
UINT32 frame_count = size / w->frame_size;
if (FAILED(_IAudioRenderClient_GetBuffer(
w->renderer, frame_count, &dest)))
return false;
fifo_read(w->buffer, dest, size);
if (FAILED(_IAudioRenderClient_ReleaseBuffer(
w->renderer, frame_count,
0)))
return false;
return true;
}
static ssize_t wasapi_write_sh_buffer(wasapi_t *w, const void * data, size_t size)
{
ssize_t written = -1;
UINT32 padding = 0;
size_t write_avail = fifo_write_avail(w->buffer);
if (!write_avail)
{
size_t read_avail = 0;
if (!(WaitForSingleObject(w->write_event, INFINITE) == WAIT_OBJECT_0))
return -1;
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
return -1;
read_avail = fifo_read_avail(w->buffer);
write_avail = w->engine_buffer_size - padding * w->frame_size;
written = read_avail < write_avail ? read_avail : write_avail;
if (written)
if (!wasapi_flush_buffer(w, written))
return -1;
}
write_avail = fifo_write_avail(w->buffer);
written = size < write_avail ? size : write_avail;
if (written)
fifo_write(w->buffer, data, written);
return written;
}
static ssize_t wasapi_write_sh(wasapi_t *w, const void * data, size_t size)
{
size_t write_avail = 0;
ssize_t written = -1;
UINT32 padding = 0;
if (!(WaitForSingleObject(w->write_event, INFINITE) == WAIT_OBJECT_0))
return -1;
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
return -1;
write_avail = w->engine_buffer_size - padding * w->frame_size;
if (!write_avail)
return 0;
written = size < write_avail ? size : write_avail;
if (written)
if (!wasapi_flush(w, data, written))
return -1;
return written;
}
static ssize_t wasapi_write_sh_nonblock(wasapi_t *w, const void * data, size_t size)
{
size_t write_avail = 0;
ssize_t written = -1;
UINT32 padding = 0;
if (w->buffer)
{
write_avail = fifo_write_avail(w->buffer);
if (!write_avail)
{
size_t read_avail = 0;
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
return -1;
read_avail = fifo_read_avail(w->buffer);
write_avail = w->engine_buffer_size - padding * w->frame_size;
written = read_avail < write_avail ? read_avail : write_avail;
if (written)
if (!wasapi_flush_buffer(w, written))
return -1;
}
write_avail = fifo_write_avail(w->buffer);
written = size < write_avail ? size : write_avail;
if (written)
fifo_write(w->buffer, data, written);
}
else
{
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
return -1;
if (!(write_avail = w->engine_buffer_size - padding * w->frame_size))
return 0;
written = size < write_avail ? size : write_avail;
if (written)
if (!wasapi_flush(w, data, written))
return -1;
}
return written;
}
static ssize_t wasapi_write_ex(wasapi_t *w, const void * data, size_t size, DWORD ms)
{
ssize_t written = 0;
size_t write_avail = fifo_write_avail(w->buffer);
if (!write_avail)
{
if (WaitForSingleObject(w->write_event, ms) != WAIT_OBJECT_0)
return -1;
if (!wasapi_flush_buffer(w, w->engine_buffer_size))
return -1;
write_avail = w->engine_buffer_size;
}
written = size < write_avail ? size : write_avail;
fifo_write(w->buffer, data, written);
return written;
}
static ssize_t wasapi_write(void *wh, const void *data, size_t size)
{
size_t written = 0;
wasapi_t *w = (wasapi_t*)wh;
if (w->nonblock)
{
if (w->exclusive)
return wasapi_write_ex(w, data, size, 0);
return wasapi_write_sh_nonblock(w, data, size);
}
if (w->exclusive)
{
ssize_t ir;
for (ir = -1; written < size; written += ir)
{
ir = wasapi_write_ex(w, (char*)data + written, size - written, INFINITE);
if (ir == -1)
return -1;
}
}
else
{
ssize_t ir;
if (w->buffer)
{
for (ir = -1; written < size; written += ir)
{
ir = wasapi_write_sh_buffer(w, (char*)data + written, size - written);
if (ir == -1)
return -1;
}
}
else
{
for (ir = -1; written < size; written += ir)
{
ir = wasapi_write_sh(w, (char*)data + written, size - written);
if (ir == -1)
return -1;
}
}
}
return written;
}
static bool wasapi_stop(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
if (FAILED(_IAudioClient_Stop(w->client)))
return !w->running;
w->running = false;
return true;
}
static bool wasapi_start(void *wh, bool u)
{
wasapi_t *w = (wasapi_t*)wh;
HRESULT hr = _IAudioClient_Start(w->client);
if (hr == AUDCLNT_E_NOT_STOPPED)
return true;
if (FAILED(hr))
return w->running;
w->running = true;
return true;
}
static bool wasapi_alive(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
return w->running;
}
static void wasapi_set_nonblock_state(void *wh, bool nonblock)
{
wasapi_t *w = (wasapi_t*)wh;
RARCH_LOG("[WASAPI]: Sync %s.\n", nonblock ? "off" : "on");
w->nonblock = nonblock;
}
static void wasapi_free(void *wh)
{
DWORD ir;
wasapi_t *w = (wasapi_t*)wh;
HANDLE write_event = w->write_event;
IFACE_RELEASE(w->renderer);
if (w->client)
_IAudioClient_Stop(w->client);
IFACE_RELEASE(w->client);
IFACE_RELEASE(w->device);
if (w->buffer)
fifo_free(w->buffer);
free(w);
ir = WaitForSingleObject(write_event, 20);
if (ir == WAIT_FAILED)
{
RARCH_ERR("[WASAPI]: WaitForSingleObject failed with error %d.\n", GetLastError());
}
/* If event isn't signaled log and leak */
if (!(ir == WAIT_OBJECT_0))
return;
CloseHandle(write_event);
}
static bool wasapi_use_float(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
return w->frame_size == 8;
}
static void wasapi_device_list_free(void *u, void *slp)
{
struct string_list *sl = (struct string_list*)slp;
if (sl)
string_list_free(sl);
}
static size_t wasapi_write_avail(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
UINT32 padding = 0;
if (w->buffer)
return fifo_write_avail(w->buffer);
if (FAILED(_IAudioClient_GetCurrentPadding(w->client, &padding)))
return 0;
return w->engine_buffer_size - padding * w->frame_size;
}
static size_t wasapi_buffer_size(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
if (!w->exclusive && w->buffer)
return w->buffer->size;
return w->engine_buffer_size;
}
audio_driver_t audio_wasapi = {
wasapi_init,
wasapi_write,
wasapi_stop,
wasapi_start,
wasapi_alive,
wasapi_set_nonblock_state,
wasapi_free,
wasapi_use_float,
"wasapi",
mmdevice_list_new,
wasapi_device_list_free,
wasapi_write_avail,
wasapi_buffer_size
};

View File

@ -1,340 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel
* Copyright (C) 2016-2017 - FIX94
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <malloc.h>
#include <stdint.h>
#include <wiiu/os.h>
#include <wiiu/ax.h>
#include "../../wiiu/wiiu_dbg.h"
#include "../../wiiu/system/memory.h"
#include "../../retroarch.h"
typedef struct
{
AXMVoice* mvoice;
uint16_t* buffer_l;
uint16_t* buffer_r;
bool nonblock;
uint32_t pos;
uint32_t written;
OSSpinLock spinlock;
} ax_audio_t;
/* 3072 samples main buffer, 64ms total */
#define AX_AUDIO_COUNT 3072
#define AX_AUDIO_SIZE (AX_AUDIO_COUNT << 1u)
#define AX_AUDIO_SAMPLE_COUNT 144 /* 3ms */
#define AX_AUDIO_SAMPLE_MIN (AX_AUDIO_SAMPLE_COUNT * 3) /* 9ms */
#define AX_AUDIO_SAMPLE_LOAD (AX_AUDIO_SAMPLE_COUNT * 10)/* 30ms */
#define AX_AUDIO_MAX_FREE (AX_AUDIO_COUNT - (AX_AUDIO_SAMPLE_COUNT * 2))
#define AX_AUDIO_RATE 48000
#if 0
#define ax_audio_ticks_to_samples(ticks) (((ticks) * 64) / 82875)
#define ax_audio_samples_to_ticks(samples) (((samples) * 82875) / 64)
#endif
static volatile ax_audio_t *wiiu_cb_ax = NULL;
void wiiu_ax_callback(void)
{
ax_audio_t *ax = NULL;
/*possibly called before unregister */
if (!wiiu_cb_ax)
return;
ax = (ax_audio_t*)wiiu_cb_ax;
if (AXIsMultiVoiceRunning(ax->mvoice))
{
if (OSUninterruptibleSpinLock_Acquire(&ax->spinlock))
{
/* Buffer underrun, stop playback to let it fill up */
if (ax->written < AX_AUDIO_SAMPLE_MIN)
AXSetMultiVoiceState(ax->mvoice, AX_VOICE_STATE_STOPPED);
ax->written -= AX_AUDIO_SAMPLE_COUNT;
OSUninterruptibleSpinLock_Release(&ax->spinlock);
}
}
}
extern void AXRegisterFrameCallback(void *cb);
static void* ax_audio_init(const char* device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
AXVoiceOffsets offsets[2];
u16 setup_buf[0x30] = {0};
setup_buf[0x25] = 2; /* we request 2 channels */
AXInitParams init = {AX_INIT_RENDERER_48KHZ, 0, 0};
AXVoiceVeData ve = {0x8000, 0};
ax_audio_t* ax = (ax_audio_t*)calloc(1, sizeof(ax_audio_t));
if (!ax)
return NULL;
AXInitWithParams(&init);
AXAcquireMultiVoice(31, NULL, 0, setup_buf, &ax->mvoice);
if (!ax->mvoice || ax->mvoice->channels != 2)
{
free(ax);
return NULL;
}
ax->buffer_l = MEM1_alloc(AX_AUDIO_SIZE, 0x100);
ax->buffer_r = MEM1_alloc(AX_AUDIO_SIZE, 0x100);
memset(ax->buffer_l,0,AX_AUDIO_SIZE);
memset(ax->buffer_r,0,AX_AUDIO_SIZE);
DCFlushRange(ax->buffer_l,AX_AUDIO_SIZE);
DCFlushRange(ax->buffer_r,AX_AUDIO_SIZE);
/* shared by both voices */
offsets[0].currentOffset = 0;
offsets[0].loopOffset = 0;
offsets[0].endOffset = AX_AUDIO_COUNT - 1;
offsets[0].loopingEnabled = AX_VOICE_LOOP_ENABLED;
offsets[0].dataType = AX_VOICE_FORMAT_LPCM16;
memcpy(&offsets[1], &offsets[0], sizeof(AXVoiceOffsets));
/* different buffers per voice */
offsets[0].data = ax->buffer_l;
offsets[1].data = ax->buffer_r;
AXSetMultiVoiceOffsets(ax->mvoice, offsets);
AXSetMultiVoiceSrcType(ax->mvoice, AX_VOICE_SRC_TYPE_NONE);
AXSetMultiVoiceSrcRatio(ax->mvoice, 1.0f);
AXSetMultiVoiceVe(ax->mvoice, &ve);
AXSetMultiVoiceDeviceMix(ax->mvoice, AX_DEVICE_TYPE_DRC, 0, 0, 0x8000, 0);
AXSetMultiVoiceDeviceMix(ax->mvoice, AX_DEVICE_TYPE_TV, 0, 0, 0x8000, 0);
AXSetMultiVoiceState(ax->mvoice, AX_VOICE_STATE_STOPPED);
ax->pos = 0;
ax->written = 0;
*new_rate = AX_AUDIO_RATE;
OSInitSpinLock(&ax->spinlock);
wiiu_cb_ax = ax;
AXRegisterFrameCallback(wiiu_ax_callback);
return ax;
}
static void ax_audio_free(void* data)
{
ax_audio_t* ax = (ax_audio_t*)data;
wiiu_cb_ax = NULL;
AXRegisterFrameCallback(NULL);
AXFreeMultiVoice(ax->mvoice);
AXQuit();
MEM1_free(ax->buffer_l);
MEM1_free(ax->buffer_r);
free(ax);
}
static bool ax_audio_stop(void* data)
{
ax_audio_t* ax = (ax_audio_t*)data;
AXSetMultiVoiceState(ax->mvoice, AX_VOICE_STATE_STOPPED);
return true;
}
static int ax_audio_limit(int in)
{
if (in < 0)
in += AX_AUDIO_COUNT;
else if (in >= AX_AUDIO_COUNT)
in -= AX_AUDIO_COUNT;
return in;
}
static bool ax_audio_start(void* data, bool is_shutdown)
{
ax_audio_t* ax = (ax_audio_t*)data;
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (is_shutdown)
return true;
/* Set back to playing on enough buffered data */
if (ax->written > AX_AUDIO_SAMPLE_LOAD)
{
AXSetMultiVoiceCurrentOffset(ax->mvoice, ax_audio_limit(ax->pos - ax->written));
AXSetMultiVoiceState(ax->mvoice, AX_VOICE_STATE_PLAYING);
}
return true;
}
static ssize_t ax_audio_write(void* data, const void* buf, size_t size)
{
uint32_t i;
size_t count_avail = 0;
ax_audio_t* ax = (ax_audio_t*)data;
const uint16_t* src = buf;
size_t count = size >> 2;
if (!size || (size & 0x3))
return 0;
if (count > AX_AUDIO_MAX_FREE)
count = AX_AUDIO_MAX_FREE;
count_avail = ((ax->written > AX_AUDIO_MAX_FREE) ? 0 : (AX_AUDIO_MAX_FREE - ax->written));
if (ax->nonblock)
{
/* Not enough available for 3ms of data */
if (count_avail < AX_AUDIO_SAMPLE_COUNT)
count = 0;
}
else if (count_avail < count)
{
/* Sync, wait for free memory */
while(AXIsMultiVoiceRunning(ax->mvoice) && (count_avail < count))
{
OSYieldThread(); /* Gives threads with same priority time to run */
count_avail = (ax->written > AX_AUDIO_MAX_FREE ? 0 : (AX_AUDIO_MAX_FREE - ax->written));
}
}
/* Over available space, do as much as possible */
if (count > count_avail)
count = count_avail;
/* make sure we have input size */
if (count > 0)
{
/* write in new data */
size_t start_pos = ax->pos;
int flush_p2_needed = 0;
int flush_p2 = 0;
for (i = 0; i < (count << 1); i += 2)
{
ax->buffer_l[ax->pos] = src[i];
ax->buffer_r[ax->pos] = src[i + 1];
ax->pos = ax_audio_limit(ax->pos + 1);
/* wrapped around, make sure to store cache */
if (ax->pos == 0)
{
flush_p2_needed = 1;
flush_p2 = ((count << 1) - i);
DCStoreRangeNoSync(ax->buffer_l + start_pos,
(AX_AUDIO_COUNT - start_pos) << 1);
DCStoreRangeNoSync(ax->buffer_r + start_pos, (AX_AUDIO_COUNT - start_pos) << 1);
}
}
/* standard cache store case */
if (!flush_p2_needed)
{
DCStoreRangeNoSync(ax->buffer_l + start_pos, count << 1);
DCStoreRange(ax->buffer_r + start_pos, count << 1);
}
/* store the rest after wrap */
else if (flush_p2 > 0)
{
DCStoreRangeNoSync(ax->buffer_l, flush_p2);
DCStoreRange(ax->buffer_r, flush_p2);
}
/* add in new audio data */
if (OSUninterruptibleSpinLock_Acquire(&ax->spinlock))
{
ax->written += count;
OSUninterruptibleSpinLock_Release(&ax->spinlock);
}
}
/* Possibly buffer underrun
*
* checks if it can be started
*/
if (!AXIsMultiVoiceRunning(ax->mvoice))
ax_audio_start(ax, false);
/* return what was actually copied */
return (count << 2);
}
static bool ax_audio_alive(void* data)
{
ax_audio_t* ax = (ax_audio_t*)data;
return AXIsMultiVoiceRunning(ax->mvoice);
}
static void ax_audio_set_nonblock_state(void* data, bool state)
{
ax_audio_t* ax = (ax_audio_t*)data;
if (ax)
ax->nonblock = state;
}
static bool ax_audio_use_float(void* data)
{
(void)data;
return false;
}
static size_t ax_audio_write_avail(void* data)
{
ax_audio_t* ax = (ax_audio_t*)data;
size_t ret = AX_AUDIO_COUNT - ax->written;
return (ret < AX_AUDIO_SAMPLE_COUNT ? 0 : ret);
}
static size_t ax_audio_buffer_size(void* data)
{
(void)data;
return AX_AUDIO_COUNT;
}
audio_driver_t audio_ax =
{
ax_audio_init,
ax_audio_write,
ax_audio_stop,
ax_audio_start,
ax_audio_alive,
ax_audio_set_nonblock_state,
ax_audio_free,
ax_audio_use_float,
"AX",
NULL, /* device_list_new */
NULL, /* device_list_free */
NULL, /* write_avail */
NULL, /* buffer_size */
};

View File

@ -1,514 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(_XBOX) && (_MSC_VER == 1310)
#ifndef _WIN32_DCOM
#define _WIN32_DCOM
#endif
#endif
#include <stdint.h>
#include <stddef.h>
#include <stdlib.h>
#include <boolean.h>
#include <compat/msvc.h>
#include <retro_miscellaneous.h>
#include <string/stdstring.h>
#include <encodings/utf.h>
#include <lists/string_list.h>
#if defined(_MSC_VER) && (_WIN32_WINNT <= _WIN32_WINNT_WIN2K)
/* needed for CoInitializeEx */
#define _WIN32_DCOM
#endif
#include "xaudio.h"
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
#include "../common/mmdevice_common.h"
#endif
#include "../../retroarch.h"
#include "../../verbosity.h"
typedef struct xaudio2 xaudio2_t;
#define MAX_BUFFERS 16
#define MAX_BUFFERS_MASK (MAX_BUFFERS - 1)
#ifndef COINIT_MULTITHREADED
#define COINIT_MULTITHREADED 0x00
#endif
#define XAUDIO2_WRITE_AVAILABLE(handle) ((handle)->bufsize * (MAX_BUFFERS - (handle)->buffers - 1))
typedef struct
{
xaudio2_t *xa;
bool nonblock;
bool is_paused;
size_t bufsize;
} xa_t;
/* Forward declarations */
static void *xa_list_new(void *u);
#if defined(__cplusplus) && !defined(CINTERFACE)
struct xaudio2 : public IXAudio2VoiceCallback
#else
struct xaudio2
#endif
{
#if defined(__cplusplus) && !defined(CINTERFACE)
xaudio2() :
buf(0), pXAudio2(0), pMasterVoice(0),
pSourceVoice(0), hEvent(0), buffers(0), bufsize(0),
bufptr(0), write_buffer(0)
{}
virtual ~xaudio2() {}
STDMETHOD_(void, OnBufferStart) (void *) {}
STDMETHOD_(void, OnBufferEnd) (void *)
{
InterlockedDecrement((LONG volatile*)&buffers);
SetEvent(hEvent);
}
STDMETHOD_(void, OnLoopEnd) (void *) {}
STDMETHOD_(void, OnStreamEnd) () {}
STDMETHOD_(void, OnVoiceError) (void *, HRESULT) {}
STDMETHOD_(void, OnVoiceProcessingPassEnd) () {}
STDMETHOD_(void, OnVoiceProcessingPassStart) (UINT32) {}
#else
const IXAudio2VoiceCallbackVtbl *lpVtbl;
#endif
uint8_t *buf;
IXAudio2 *pXAudio2;
IXAudio2MasteringVoice *pMasterVoice;
IXAudio2SourceVoice *pSourceVoice;
HANDLE hEvent;
unsigned long volatile buffers;
unsigned bufsize;
unsigned bufptr;
unsigned write_buffer;
};
#if !defined(__cplusplus) || defined(CINTERFACE)
static void WINAPI voice_on_buffer_end(IXAudio2VoiceCallback *handle_, void *data)
{
xaudio2_t *handle = (xaudio2_t*)handle_;
(void)data;
InterlockedDecrement((LONG volatile*)&handle->buffers);
SetEvent(handle->hEvent);
}
static void WINAPI dummy_voidp(IXAudio2VoiceCallback *handle, void *data) { (void)handle; (void)data; }
static void WINAPI dummy_nil(IXAudio2VoiceCallback *handle) { (void)handle; }
static void WINAPI dummy_uint32(IXAudio2VoiceCallback *handle, UINT32 dummy) { (void)handle; (void)dummy; }
static void WINAPI dummy_voidp_hresult(IXAudio2VoiceCallback *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; }
const struct IXAudio2VoiceCallbackVtbl voice_vtable = {
dummy_uint32,
dummy_nil,
dummy_nil,
dummy_voidp,
voice_on_buffer_end,
dummy_voidp,
dummy_voidp_hresult,
};
#endif
static void xaudio2_set_wavefmt(WAVEFORMATEX *wfx,
unsigned channels, unsigned samplerate)
{
wfx->wFormatTag = WAVE_FORMAT_IEEE_FLOAT;
wfx->nBlockAlign = channels * sizeof(float);
wfx->wBitsPerSample = sizeof(float) * 8;
wfx->nChannels = channels;
wfx->nSamplesPerSec = samplerate;
wfx->nAvgBytesPerSec = wfx->nSamplesPerSec * wfx->nBlockAlign;
wfx->cbSize = 0;
}
static void xaudio2_free(xaudio2_t *handle)
{
if (!handle)
return;
if (handle->pSourceVoice)
{
IXAudio2SourceVoice_Stop(handle->pSourceVoice,
0, XAUDIO2_COMMIT_NOW);
IXAudio2SourceVoice_DestroyVoice(handle->pSourceVoice);
}
if (handle->pMasterVoice)
{
IXAudio2MasteringVoice_DestroyVoice(handle->pMasterVoice);
}
if (handle->pXAudio2)
{
IXAudio2_Release(handle->pXAudio2);
}
if (handle->hEvent)
CloseHandle(handle->hEvent);
free(handle->buf);
#if defined(__cplusplus) && !defined(CINTERFACE)
delete handle;
#else
free(handle);
#endif
}
static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
size_t size, const char *device)
{
int32_t idx_found = -1;
WAVEFORMATEX wfx = {0};
struct string_list *list = NULL;
#if defined(__cplusplus) && !defined(CINTERFACE)
xaudio2_t *handle = new xaudio2;
#else
xaudio2_t *handle = (xaudio2_t*)calloc(1, sizeof(*handle));
#endif
if (!handle)
goto error;
list = (struct string_list*)xa_list_new(NULL);
#if !defined(__cplusplus) || defined(CINTERFACE)
handle->lpVtbl = &voice_vtable;
#endif
if (FAILED(XAudio2Create(&handle->pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR)))
goto error;
if (device)
{
/* Search for device name first */
if (list && list->elems)
{
if (list->elems)
{
unsigned i;
for (i = 0; i < list->size; i++)
{
if (string_is_equal(device, list->elems[i].data))
{
idx_found = i;
break;
}
}
/* Index was not found yet based on name string,
* just assume id is a one-character number index. */
if (idx_found == -1)
{
if (isdigit(device[0]))
{
RARCH_LOG("[XAudio2]: Fallback, device index is a single number index instead: %d.\n", idx_found);
idx_found = strtoul(device, NULL, 0);
}
}
}
}
}
if (idx_found == -1)
idx_found = 0;
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
{
wchar_t *temp = NULL;
if (device)
temp = utf8_to_utf16_string_alloc((const char*)list->elems[idx_found].userdata);
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, (LPCWSTR)(uintptr_t)temp, NULL, AudioCategory_GameEffects)))
{
free(temp);
goto error;
}
if (temp)
free(temp);
}
#else
if (FAILED(IXAudio2_CreateMasteringVoice(handle->pXAudio2, &handle->pMasterVoice, channels, samplerate, 0, idx_found, NULL)))
goto error;
#endif
xaudio2_set_wavefmt(&wfx, channels, samplerate);
if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2,
&handle->pSourceVoice, &wfx,
XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO,
(IXAudio2VoiceCallback*)handle, 0, 0)))
goto error;
handle->hEvent = CreateEvent(0, FALSE, FALSE, 0);
if (!handle->hEvent)
goto error;
handle->bufsize = size / MAX_BUFFERS;
handle->buf = (uint8_t*)calloc(1, handle->bufsize * MAX_BUFFERS);
if (!handle->buf)
goto error;
if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0,
XAUDIO2_COMMIT_NOW)))
goto error;
if (list)
string_list_free(list);
return handle;
error:
if (list)
string_list_free(list);
xaudio2_free(handle);
return NULL;
}
static void *xa_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
size_t bufsize;
xa_t *xa = (xa_t*)calloc(1, sizeof(*xa));
if (!xa)
return NULL;
if (latency < 8)
latency = 8; /* Do not allow shenanigans. */
bufsize = latency * rate / 1000;
RARCH_LOG("[XAudio2]: Requesting %u ms latency, using %d ms latency.\n",
latency, (int)bufsize * 1000 / rate);
xa->bufsize = bufsize * 2 * sizeof(float);
xa->xa = xaudio2_new(rate, 2, xa->bufsize, device);
if (!xa->xa)
{
RARCH_ERR("Failed to init XAudio2.\n");
free(xa);
return NULL;
}
return xa;
}
static ssize_t xa_write(void *data, const void *buf, size_t size)
{
unsigned bytes;
xa_t *xa = (xa_t*)data;
xaudio2_t *handle = xa->xa;
const uint8_t *buffer = (const uint8_t*)buf;
if (xa->nonblock)
{
size_t avail = XAUDIO2_WRITE_AVAILABLE(xa->xa);
if (avail == 0)
return 0;
if (avail < size)
size = avail;
}
bytes = size;
while (bytes)
{
unsigned need = MIN(bytes, handle->bufsize - handle->bufptr);
memcpy(handle->buf + handle->write_buffer *
handle->bufsize + handle->bufptr,
buffer, need);
handle->bufptr += need;
buffer += need;
bytes -= need;
if (handle->bufptr == handle->bufsize)
{
XAUDIO2_BUFFER xa2buffer;
while (handle->buffers == MAX_BUFFERS - 1)
WaitForSingleObject(handle->hEvent, INFINITE);
xa2buffer.Flags = 0;
xa2buffer.AudioBytes = handle->bufsize;
xa2buffer.pAudioData = handle->buf + handle->write_buffer * handle->bufsize;
xa2buffer.PlayBegin = 0;
xa2buffer.PlayLength = 0;
xa2buffer.LoopBegin = 0;
xa2buffer.LoopLength = 0;
xa2buffer.LoopCount = 0;
xa2buffer.pContext = NULL;
if (FAILED(IXAudio2SourceVoice_SubmitSourceBuffer(
handle->pSourceVoice, &xa2buffer, NULL)))
{
if (size > 0)
return -1;
return 0;
}
InterlockedIncrement((LONG volatile*)&handle->buffers);
handle->bufptr = 0;
handle->write_buffer = (handle->write_buffer + 1) & MAX_BUFFERS_MASK;
}
}
return size;
}
static bool xa_stop(void *data)
{
xa_t *xa = (xa_t*)data;
xa->is_paused = true;
return true;
}
static bool xa_alive(void *data)
{
xa_t *xa = (xa_t*)data;
if (!xa)
return false;
return !xa->is_paused;
}
static void xa_set_nonblock_state(void *data, bool state)
{
xa_t *xa = (xa_t*)data;
if (xa)
xa->nonblock = state;
}
static bool xa_start(void *data, bool is_shutdown)
{
xa_t *xa = (xa_t*)data;
xa->is_paused = false;
return true;
}
static bool xa_use_float(void *data)
{
(void)data;
return true;
}
static void xa_free(void *data)
{
xa_t *xa = (xa_t*)data;
if (!xa)
return;
if (xa->xa)
xaudio2_free(xa->xa);
free(xa);
}
static size_t xa_write_avail(void *data)
{
xa_t *xa = (xa_t*)data;
return XAUDIO2_WRITE_AVAILABLE(xa->xa);
}
static size_t xa_buffer_size(void *data)
{
xa_t *xa = (xa_t*)data;
return xa->bufsize;
}
static void xa_device_list_free(void *u, void *slp)
{
struct string_list *sl = (struct string_list*)slp;
if (sl)
string_list_free(sl);
}
static void *xa_list_new(void *u)
{
#if defined(_XBOX) || !(_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
unsigned i;
union string_list_elem_attr attr;
uint32_t dev_count = 0;
IXAudio2 *ixa2 = NULL;
struct string_list *sl = string_list_new();
if (!sl)
return NULL;
attr.i = 0;
if (FAILED(XAudio2Create(&ixa2, 0, XAUDIO2_DEFAULT_PROCESSOR)))
return NULL;
IXAudio2_GetDeviceCount(ixa2, &dev_count);
for (i = 0; i < dev_count; i++)
{
XAUDIO2_DEVICE_DETAILS dev_detail;
if (IXAudio2_GetDeviceDetails(ixa2, i, &dev_detail) == S_OK)
{
char *str = utf16_to_utf8_string_alloc(dev_detail.DisplayName);
if (str)
{
string_list_append(sl, str, attr);
free(str);
}
}
}
IXAudio2_Release(ixa2);
return sl;
#elif defined(__WINRT__)
return NULL;
#else
return mmdevice_list_new(u);
#endif
}
audio_driver_t audio_xa = {
xa_init,
xa_write,
xa_stop,
xa_start,
xa_alive,
xa_set_nonblock_state,
xa_free,
xa_use_float,
"xaudio",
xa_list_new,
xa_device_list_free,
xa_write_avail,
xa_buffer_size,
};

View File

@ -1,26 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - Krzysztof Haładyn
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#if (_WIN32_WINNT >= 0x0602 /*_WIN32_WINNT_WIN8*/)
/* XAudio 2.7 it part of the old DirectX SDKs. XAudio 2.8+ is part of the
* Windows OS itself (starting from Windows 8). Since UWP lets you access
* only libraries that are built-in to the OS, the headers had to be
* upgraded to the newer version to get audio support working. */
#include "xaudio29.h"
#else
/* The old version still has to be there since XAudio 2.8 is not available
* on Windows 7 and earlier */
#include "xaudio27.h"
#endif

View File

@ -1,364 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2010-2014 - OV2
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
/* Kinda stripped down. Only contains the bare essentials used in RetroArch. */
#ifndef XAUDIO2_STRIPPED_H
#define XAUDIO2_STRIPPED_H
#include <retro_inline.h>
#include <retro_environment.h>
/* All structures defined in this file use tight field packing */
#pragma pack(push, 1)
#if defined(__cplusplus) && !defined(CINTERFACE)
#define X2DEFAULT(x) = (x)
#else
#define X2DEFAULT(x)
#endif
#ifdef _XBOX
#include <xtl.h>
#ifndef __cplusplus
#define OPAQUE interface
#endif
#define DEFINE_CLSID(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
#define DEFINE_IID(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
DEFINE_CLSID(XAudio2, 3eda9b49, 2085, 498b, 9b, b2, 39, a6, 77, 84, 93, de);
DEFINE_CLSID(XAudio2_Debug, 47199894, 7cc2, 444d, 98, 73, ce, d2, 56, 2c, c6, 0e);
DEFINE_IID(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb);
#include <audiodefs.h> /* Basic audio data types and constants */
#else
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <basetyps.h>
#include <objbase.h>
#include <mmreg.h>
#ifndef __cplusplus
#undef OPAQUE
#define OPAQUE struct
#endif
#define DEFINE_GUID_X(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
static const GUID n = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#define DEFINE_CLSID_X(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID_X(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
#define DEFINE_IID_X(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID_X(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
#ifndef __cplusplus
#ifndef INTERFACE
#define INTERFACE void
#endif
#endif
DEFINE_CLSID_X(XAudio2, 5a508685, a254, 4fba, 9b, 82, 9a, 24, b0, 03, 06, af); /* 2.7 */
DEFINE_IID_X(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb);
#endif
#ifdef _XBOX
#define XAUDIO2_DEFAULT_FREQ_RATIO 2.0f
#else
#define XAUDIO2_DEFAULT_FREQ_RATIO 4.0f
#endif
#define XAUDIO2_COMMIT_NOW 0
#define XAUDIO2_DEFAULT_CHANNELS 0
#define XAUDIO2_DEFAULT_SAMPLERATE 0
#define XAUDIO2_DEBUG_ENGINE 0x0001
#define XAUDIO2_VOICE_NOSRC 0x0004
typedef enum XAUDIO2_DEVICE_ROLE
{
NotDefaultDevice = 0x0,
DefaultConsoleDevice = 0x1,
DefaultMultimediaDevice = 0x2,
DefaultCommunicationsDevice = 0x4,
DefaultGameDevice = 0x8,
GlobalDefaultDevice = 0xf,
InvalidDeviceRole = ~GlobalDefaultDevice
} XAUDIO2_DEVICE_ROLE;
#ifdef _XBOX
typedef enum XAUDIO2_XBOX_HWTHREAD_SPECIFIER
{
XboxThread0 = 0x01,
XboxThread1 = 0x02,
XboxThread2 = 0x04,
XboxThread3 = 0x08,
XboxThread4 = 0x10,
XboxThread5 = 0x20,
XAUDIO2_ANY_PROCESSOR = XboxThread4,
XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
} XAUDIO2_XBOX_HWTHREAD_SPECIFIER, XAUDIO2_PROCESSOR;
#else
typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER
{
#if defined(__STDC_C89__)
XAUDIO2_ANY_PROCESSOR = 0xffff,
#else
XAUDIO2_ANY_PROCESSOR = 0xffffffff,
#endif
XAUDIO2_DEFAULT_PROCESSOR = XAUDIO2_ANY_PROCESSOR
} XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER, XAUDIO2_PROCESSOR;
#endif
typedef enum XAUDIO2_FILTER_TYPE {
LowPassFilter,
BandPassFilter,
HighPassFilter
} XAUDIO2_FILTER_TYPE;
typedef struct XAUDIO2_DEVICE_DETAILS
{
WCHAR DeviceID[256];
WCHAR DisplayName[256];
XAUDIO2_DEVICE_ROLE Role;
WAVEFORMATEXTENSIBLE OutputFormat;
} XAUDIO2_DEVICE_DETAILS;
/* Forward declarations. */
#ifdef __cplusplus
struct XAUDIO2_VOICE_DETAILS;
struct XAUDIO2_VOICE_SENDS;
struct XAUDIO2_EFFECT_DESCRIPTOR;
struct XAUDIO2_EFFECT_CHAIN;
struct XAUDIO2_FILTER_PARAMETERS;
struct XAUDIO2_BUFFER_WMA;
struct XAUDIO2_VOICE_STATE;
struct XAUDIO2_PERFORMANCE_DATA;
struct XAUDIO2_DEBUG_CONFIGURATION;
struct IXAudio2EngineCallback;
struct IXAudio2SubmixVoice;
#else
typedef OPAQUE XAUDIO2_VOICE_DETAILS XAUDIO2_VOICE_DETAILS;
typedef OPAQUE XAUDIO2_VOICE_SENDS XAUDIO2_VOICE_SENDS;
typedef OPAQUE XAUDIO2_EFFECT_DESCRIPTOR XAUDIO2_EFFECT_DESCRIPTOR;
typedef OPAQUE XAUDIO2_EFFECT_CHAIN XAUDIO2_EFFECT_CHAIN;
typedef OPAQUE XAUDIO2_FILTER_PARAMETERS XAUDIO2_FILTER_PARAMETERS;
typedef OPAQUE XAUDIO2_BUFFER_WMA XAUDIO2_BUFFER_WMA;
typedef OPAQUE XAUDIO2_VOICE_STATE XAUDIO2_VOICE_STATE;
typedef OPAQUE XAUDIO2_PERFORMANCE_DATA XAUDIO2_PERFORMANCE_DATA;
typedef OPAQUE XAUDIO2_DEBUG_CONFIGURATION XAUDIO2_DEBUG_CONFIGURATION;
typedef OPAQUE IXAudio2EngineCallback IXAudio2EngineCallback;
typedef OPAQUE IXAudio2SubmixVoice IXAudio2SubmixVoice;
#endif
typedef struct XAUDIO2_BUFFER
{
UINT32 Flags;
UINT32 AudioBytes;
const BYTE* pAudioData;
UINT32 PlayBegin;
UINT32 PlayLength;
UINT32 LoopBegin;
UINT32 LoopLength;
UINT32 LoopCount;
void *pContext;
} XAUDIO2_BUFFER;
#undef INTERFACE
#define INTERFACE IXAudio2VoiceCallback
DECLARE_INTERFACE(IXAudio2VoiceCallback)
{
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) PURE;
STDMETHOD_(void, OnStreamEnd) (THIS) PURE;
STDMETHOD_(void, OnBufferStart) (THIS_ void *pBufferContext) PURE;
STDMETHOD_(void, OnBufferEnd) (THIS_ void *pBufferContext) PURE;
STDMETHOD_(void, OnLoopEnd) (THIS_ void *pBufferContext) PURE;
STDMETHOD_(void, OnVoiceError) (THIS_ void *pBufferContext, HRESULT Error) PURE;
};
#undef INTERFACE
#define INTERFACE IXAudio2Voice
DECLARE_INTERFACE(IXAudio2Voice)
{
#define Declare_IXAudio2Voice_Methods() \
STDMETHOD_(void, GetVoiceDetails) (THIS_ XAUDIO2_VOICE_DETAILS* pVoiceDetails) PURE; \
STDMETHOD(SetOutputVoices) (THIS_ const XAUDIO2_VOICE_SENDS* pSendList) PURE; \
STDMETHOD(SetEffectChain) (THIS_ const XAUDIO2_EFFECT_CHAIN* pEffectChain) PURE; \
STDMETHOD(EnableEffect) (THIS_ UINT32 EffectIndex, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD(DisableEffect) (THIS_ UINT32 EffectIndex, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetEffectState) (THIS_ UINT32 EffectIndex, BOOL* pEnabled) PURE; \
STDMETHOD(SetEffectParameters) (THIS_ UINT32 EffectIndex, \
const void *pParameters, \
UINT32 ParametersByteSize, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD(GetEffectParameters) (THIS_ UINT32 EffectIndex, void *pParameters, \
UINT32 ParametersByteSize) PURE; \
STDMETHOD(SetFilterParameters) (THIS_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetFilterParameters) (THIS_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
STDMETHOD_(void, SetOutputFilterParameters) (THIS_ IXAudio2Voice *voice, const XAUDIO2_FILTER_PARAMETERS* param, \
UINT32 op X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetOutputFilterParameters) (THIS_ IXAudio2Voice *voice, XAUDIO2_FILTER_PARAMETERS* param) PURE; \
STDMETHOD(SetVolume) (THIS_ float Volume, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetVolume) (THIS_ float* pVolume) PURE; \
STDMETHOD(SetChannelVolumes) (THIS_ UINT32 Channels, const float* pVolumes, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetChannelVolumes) (THIS_ UINT32 Channels, float* pVolumes) PURE; \
STDMETHOD(SetOutputMatrix) (THIS_ IXAudio2Voice* pDestinationVoice, \
UINT32 SourceChannels, UINT32 DestinationChannels, \
const float* pLevelMatrix, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetOutputMatrix) (THIS_ IXAudio2Voice* pDestinationVoice, \
UINT32 SourceChannels, UINT32 DestinationChannels, \
float* pLevelMatrix) PURE; \
STDMETHOD_(void, DestroyVoice) (THIS) PURE
Declare_IXAudio2Voice_Methods();
};
#undef INTERFACE
#define INTERFACE IXAudio2MasteringVoice
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
};
#undef INTERFACE
#define INTERFACE IXAudio2SourceVoice
DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
STDMETHOD(Start) (THIS_ UINT32 Flags, UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD(Stop) (THIS_ UINT32 Flags, UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD(SubmitSourceBuffer) (THIS_ const XAUDIO2_BUFFER* pBuffer, const XAUDIO2_BUFFER_WMA* pBufferWMA X2DEFAULT(NULL)) PURE;
STDMETHOD(FlushSourceBuffers) (THIS) PURE;
STDMETHOD(Discontinuity) (THIS) PURE;
STDMETHOD(ExitLoop) (THIS_ UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD_(void, GetState) (THIS_ XAUDIO2_VOICE_STATE* pVoiceState) PURE;
STDMETHOD(SetFrequencyRatio) (THIS_ float Ratio,
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD_(void, GetFrequencyRatio) (THIS_ float* pRatio) PURE;
};
#undef INTERFACE
#define INTERFACE IXAudio2
DECLARE_INTERFACE_(IXAudio2, IUnknown)
{
STDMETHOD(QueryInterface) (THIS_ REFIID riid, void** ppvInterface) PURE;
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
STDMETHOD_(ULONG, Release) (THIS) PURE;
STDMETHOD(GetDeviceCount) (THIS_ UINT32* pCount) PURE;
STDMETHOD(GetDeviceDetails) (THIS_ UINT32 Index, XAUDIO2_DEVICE_DETAILS* pDeviceDetails) PURE;
STDMETHOD(Initialize) (THIS_ UINT32 Flags X2DEFAULT(0),
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR)) PURE;
STDMETHOD(RegisterForCallbacks) (IXAudio2EngineCallback* pCallback) PURE;
STDMETHOD_(void, UnregisterForCallbacks) (IXAudio2EngineCallback* pCallback) PURE;
STDMETHOD(CreateSourceVoice) (THIS_ IXAudio2SourceVoice** ppSourceVoice,
const WAVEFORMATEX* pSourceFormat,
UINT32 Flags X2DEFAULT(0),
float MaxFrequencyRatio X2DEFAULT(XAUDIO2_DEFAULT_FREQ_RATIO),
IXAudio2VoiceCallback* pCallback X2DEFAULT(NULL),
const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
STDMETHOD(CreateSubmixVoice) (THIS_ IXAudio2SubmixVoice** ppSubmixVoice,
UINT32 InputChannels, UINT32 InputSampleRate,
UINT32 Flags X2DEFAULT(0), UINT32 ProcessingStage X2DEFAULT(0),
const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
STDMETHOD(CreateMasteringVoice) (THIS_ IXAudio2MasteringVoice** ppMasteringVoice,
UINT32 InputChannels X2DEFAULT(XAUDIO2_DEFAULT_CHANNELS),
UINT32 InputSampleRate X2DEFAULT(XAUDIO2_DEFAULT_SAMPLERATE),
UINT32 Flags X2DEFAULT(0), UINT32 DeviceIndex X2DEFAULT(0),
const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
STDMETHOD(StartEngine) (THIS) PURE;
STDMETHOD_(void, StopEngine) (THIS) PURE;
STDMETHOD(CommitChanges) (THIS_ UINT32 OperationSet) PURE;
STDMETHOD_(void, GetPerformanceData) (THIS_ XAUDIO2_PERFORMANCE_DATA* pPerfData) PURE;
STDMETHOD_(void, SetDebugConfiguration) (THIS_ const XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration,
void *pReserved X2DEFAULT(NULL)) PURE;
};
#if defined(__cplusplus) && !defined(CINTERFACE)
/* C++ hooks */
#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b)
#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b)
#define IXAudio2SourceVoice_Stop(handle, a, b) handle->Stop(a, b)
#define IXAudio2SourceVoice_DestroyVoice(handle) handle->DestroyVoice()
#define IXAudio2MasteringVoice_DestroyVoice(handle) handle->DestroyVoice()
#define IXAudio2_Release(handle) handle->Release()
#define IXAudio2_CreateSourceVoice(handle, a, b, c, d, e, f, g) handle->CreateSourceVoice(a, b, c, d, e, f, g)
#define IXAudio2_GetDeviceCount(handle, puCount) (handle)->GetDeviceCount(puCount)
#define IXAudio2_GetDeviceDetails(handle, Index,pDeviceDetails) (handle)->GetDeviceDetails(Index, pDeviceDetails)
#define IXAudio2_CreateMasteringVoice(handle, a, b, c, d, e, f) handle->CreateMasteringVoice(a, b, c, d, e, f)
#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b)
#else
/* C hooks */
#define IXAudio2_Initialize(handle,a,b) (handle)->lpVtbl->Initialize(handle, a, b)
#define IXAudio2_Release(handle) (handle)->lpVtbl->Release(handle)
#define IXAudio2_CreateSourceVoice(handle,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (handle)->lpVtbl->CreateSourceVoice(handle, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain)
#define IXAudio2_CreateMasteringVoice(handle,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (handle)->lpVtbl->CreateMasteringVoice(handle, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain)
#define IXAudio2_GetDeviceCount(handle, puCount) (handle)->lpVtbl->GetDeviceCount(handle, puCount)
#define IXAudio2_GetDeviceDetails(handle, Index,pDeviceDetails) (handle)->lpVtbl->GetDeviceDetails(handle, Index, pDeviceDetails)
#define IXAudio2SourceVoice_Start(handle, Flags, OperationSet) (handle)->lpVtbl->Start(handle, Flags, OperationSet)
#define IXAudio2SourceVoice_Stop(handle, Flags, OperationSet) (handle)->lpVtbl->Stop(handle, Flags, OperationSet)
#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, pBuffer, pBufferWMA) (handle)->lpVtbl->SubmitSourceBuffer(handle, pBuffer, pBufferWMA)
#define IXAudio2SourceVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle)
#define IXAudio2MasteringVoice_DestroyVoice(handle) (handle)->lpVtbl->DestroyVoice(handle)
#endif
#ifdef _XBOX
STDAPI XAudio2Create(__deref_out IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0),
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR));
#else
static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_PROCESSOR proc)
{
IXAudio2 *pXAudio2 = NULL;
#ifdef __cplusplus
HRESULT hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2);
#else
HRESULT hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2);
#endif
if (SUCCEEDED(hr))
{
hr = IXAudio2_Initialize(pXAudio2, 0, XAUDIO2_DEFAULT_PROCESSOR);
if (SUCCEEDED(hr))
*ppXAudio2 = pXAudio2;
else
IXAudio2_Release(pXAudio2);
}
return hr;
}
#endif
/* Undo the #pragma pack(push, 1) directive at the top of this file */
#pragma pack(pop)
#endif

View File

@ -1,910 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2018 - Krzysztof Haładyn
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
/**************************************************************************
*
* Copyright (c) Microsoft Corporation. All rights reserved.
*
* File: xaudio2.h
* Content: Declarations for the XAudio2 game audio API.
*
**************************************************************************/
/* Modified slightly to build without requiring the WinRT compiler since that is only available in C++ sources */
#ifdef _MSC_VER
#pragma once
#endif
#ifndef __XAUDIO2_INCLUDED__
#define __XAUDIO2_INCLUDED__
#include <sdkddkver.h>
#include <retro_inline.h>
#if(_WIN32_WINNT < _WIN32_WINNT_WIN8)
#error "This version of XAudio2 is available only in Windows 8 or later. Use the XAudio2 headers and libraries from the DirectX SDK with applications that target Windows 7 and earlier versions."
#endif /* (_WIN32_WINNT < _WIN32_WINNT_WIN8) */
#include <winapifamily.h>
#pragma region Application Family
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE)
/* Current name of the DLL shipped in the same SDK as this header.
* The name reflects the current version */
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
#define XAUDIO2_DLL_A "xaudio2_9.dll"
#define XAUDIO2_DLL_W L"xaudio2_9.dll"
#define XAUDIO2D_DLL_A "xaudio2_9d.dll"
#define XAUDIO2D_DLL_W L"xaudio2_9d.dll"
#else
#define XAUDIO2_DLL_A "xaudio2_8.dll"
#define XAUDIO2_DLL_W L"xaudio2_8.dll"
#define XAUDIO2D_DLL_A "xaudio2_8.dll"
#define XAUDIO2D_DLL_W L"xaudio2_8.dll"
#endif
#ifdef UNICODE
#define XAUDIO2_DLL XAUDIO2_DLL_W
#define XAUDIO2D_DLL XAUDIO2D_DLL_W
#else
#define XAUDIO2_DLL XAUDIO2_DLL_A
#define XAUDIO2D_DLL XAUDIO2D_DLL_A
#endif
/**************************************************************************
*
* XAudio2 COM object class and interface IDs.
*
**************************************************************************/
#include <basetyps.h>
#if defined(__cplusplus__) && defined(__WINRT__)
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
/* XAudio 2.9 */
interface __declspec(uuid("2B02E3CF-2E0B-4ec3-BE45-1B2A3FE7210D")) IXAudio2;
#else
/* XAudio 2.8 */
interface __declspec(uuid("60d8dac8-5aa1-4e8e-b597-2f5e2883d484")) IXAudio2;
#endif
#else
/* Modified for C support */
#define DEFINE_GUID_X(n, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
static const GUID n = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }
#define DEFINE_CLSID_X(className, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID_X(CLSID_##className, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
#define DEFINE_IID_X(interfaceName, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \
DEFINE_GUID_X(IID_##interfaceName, 0x##l, 0x##w1, 0x##w2, 0x##b1, 0x##b2, 0x##b3, 0x##b4, 0x##b5, 0x##b6, 0x##b7, 0x##b8)
#if(_WIN32_WINNT >= _WIN32_WINNT_WIN10)
DEFINE_IID_X(IXAudio2, 2B02E3CF, 2E0B, 4ec3, BE, 45, 1B, 2A, 3F, E7, 21, 0D);
#else
DEFINE_IID_X(IXAudio2, 60d8dac8, 5aa1, 4e8e, b5, 97, 2f, 5e, 28, 83, d4, 84);
#endif
#endif
/* Ignore the rest of this header if only the GUID definitions were requested */
#ifndef GUID_DEFS_ONLY
#include <objbase.h> /* Windows COM declarations */
#include <sal.h> /* Markers for documenting API semantics */
#include <mmreg.h> /* Basic data types and constants for audio work */
#include <audiosessiontypes.h> /* For AUDIO_STREAM_CATEGORY */
/* All structures defined in this file use tight field packing */
#pragma pack(push, 1)
/**************************************************************************
*
* XAudio2 constants, flags and error codes.
*
**************************************************************************/
/* Numeric boundary values */
#define XAUDIO2_MAX_BUFFER_BYTES 0x80000000 /* Maximum bytes allowed in a source buffer */
#define XAUDIO2_MAX_QUEUED_BUFFERS 64 /* Maximum buffers allowed in a voice queue */
#define XAUDIO2_MAX_BUFFERS_SYSTEM 2 /* Maximum buffers allowed for system threads (Xbox 360 only) */
#define XAUDIO2_MAX_AUDIO_CHANNELS 64 /* Maximum channels in an audio stream */
#define XAUDIO2_MIN_SAMPLE_RATE 1000 /* Minimum audio sample rate supported */
#define XAUDIO2_MAX_SAMPLE_RATE 200000 /* Maximum audio sample rate supported */
#define XAUDIO2_MAX_VOLUME_LEVEL 16777216.0f /* Maximum acceptable volume level (2^24) */
#define XAUDIO2_MIN_FREQ_RATIO (1/1024.0f) /* Minimum SetFrequencyRatio argument */
#define XAUDIO2_MAX_FREQ_RATIO 1024.0f /* Maximum MaxFrequencyRatio argument */
#define XAUDIO2_DEFAULT_FREQ_RATIO 2.0f /* Default MaxFrequencyRatio argument */
#define XAUDIO2_MAX_FILTER_ONEOVERQ 1.5f /* Maximum XAUDIO2_FILTER_PARAMETERS.OneOverQ */
#define XAUDIO2_MAX_FILTER_FREQUENCY 1.0f /* Maximum XAUDIO2_FILTER_PARAMETERS.Frequency */
#define XAUDIO2_MAX_LOOP_COUNT 254 /* Maximum non-infinite XAUDIO2_BUFFER.LoopCount */
#define XAUDIO2_MAX_INSTANCES 8 /* Maximum simultaneous XAudio2 objects on Xbox 360 */
/* For XMA voices on Xbox 360 there is an additional restriction on the MaxFrequencyRatio
* argument and the voice's sample rate: the product of these numbers cannot exceed 600000
* for one-channel voices or 300000 for voices with more than one channel.
*/
#define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MONO 600000
#define XAUDIO2_MAX_RATIO_TIMES_RATE_XMA_MULTICHANNEL 300000
/* Numeric values with special meanings */
#define XAUDIO2_COMMIT_NOW 0 /* Used as an OperationSet argument */
#define XAUDIO2_COMMIT_ALL 0 /* Used in IXAudio2::CommitChanges */
#define XAUDIO2_INVALID_OPSET (UINT32)(-1) /* Not allowed for OperationSet arguments */
#define XAUDIO2_NO_LOOP_REGION 0 /* Used in XAUDIO2_BUFFER.LoopCount */
#define XAUDIO2_LOOP_INFINITE 255 /* Used in XAUDIO2_BUFFER.LoopCount */
#define XAUDIO2_DEFAULT_CHANNELS 0 /* Used in CreateMasteringVoice */
#define XAUDIO2_DEFAULT_SAMPLERATE 0 /* Used in CreateMasteringVoice */
/* Flags */
#define XAUDIO2_DEBUG_ENGINE 0x0001 /* Used in XAudio2Create */
#define XAUDIO2_VOICE_NOPITCH 0x0002 /* Used in IXAudio2::CreateSourceVoice */
#define XAUDIO2_VOICE_NOSRC 0x0004 /* Used in IXAudio2::CreateSourceVoice */
#define XAUDIO2_VOICE_USEFILTER 0x0008 /* Used in IXAudio2::CreateSource/SubmixVoice */
#define XAUDIO2_PLAY_TAILS 0x0020 /* Used in IXAudio2SourceVoice::Stop */
#define XAUDIO2_END_OF_STREAM 0x0040 /* Used in XAUDIO2_BUFFER.Flags */
#define XAUDIO2_SEND_USEFILTER 0x0080 /* Used in XAUDIO2_SEND_DESCRIPTOR.Flags */
#define XAUDIO2_VOICE_NOSAMPLESPLAYED 0x0100 /* Used in IXAudio2SourceVoice::GetState */
#define XAUDIO2_STOP_ENGINE_WHEN_IDLE 0x2000 /* Used in XAudio2Create to force the engine to Stop when no source voices are Started, and Start when a voice is Started */
#define XAUDIO2_1024_QUANTUM 0x8000 /* Used in XAudio2Create to specify nondefault processing quantum of 21.33 ms (1024 samples at 48KHz) */
#define XAUDIO2_NO_VIRTUAL_AUDIO_CLIENT 0x10000 /* Used in CreateMasteringVoice to create a virtual audio client */
/* Default parameters for the built-in filter */
#define XAUDIO2_DEFAULT_FILTER_TYPE LowPassFilter
#define XAUDIO2_DEFAULT_FILTER_FREQUENCY XAUDIO2_MAX_FILTER_FREQUENCY
#define XAUDIO2_DEFAULT_FILTER_ONEOVERQ 1.0f
/* Internal XAudio2 constants */
/* The audio frame quantum can be calculated by reducing the fraction:
* SamplesPerAudioFrame / SamplesPerSecond */
#define XAUDIO2_QUANTUM_NUMERATOR 1 /* On Windows, XAudio2 processes audio */
#define XAUDIO2_QUANTUM_DENOMINATOR 100 /* in 10ms chunks (= 1/100 seconds) */
#define XAUDIO2_QUANTUM_MS (1000.0f * XAUDIO2_QUANTUM_NUMERATOR / XAUDIO2_QUANTUM_DENOMINATOR)
/* XAudio2 error codes */
#define FACILITY_XAUDIO2 0x896
#define XAUDIO2_E_INVALID_CALL 0x88960001 /* An API call or one of its arguments was illegal */
#define XAUDIO2_E_XMA_DECODER_ERROR 0x88960002 /* The XMA hardware suffered an unrecoverable error */
#define XAUDIO2_E_XAPO_CREATION_FAILED 0x88960003 /* XAudio2 failed to initialize an XAPO effect */
#define XAUDIO2_E_DEVICE_INVALIDATED 0x88960004 /* An audio device became unusable (unplugged, etc) */
/**************************************************************************
*
* Forward declarations for the XAudio2 interfaces.
*
**************************************************************************/
#ifdef __cplusplus
#define FWD_DECLARE(x) interface x
#else
#define FWD_DECLARE(x) typedef interface x x
#endif
FWD_DECLARE(IXAudio2);
FWD_DECLARE(IXAudio2Voice);
FWD_DECLARE(IXAudio2SourceVoice);
FWD_DECLARE(IXAudio2SubmixVoice);
FWD_DECLARE(IXAudio2MasteringVoice);
FWD_DECLARE(IXAudio2EngineCallback);
FWD_DECLARE(IXAudio2VoiceCallback);
/**************************************************************************
*
* XAudio2 structures and enumerations.
*
**************************************************************************/
/* Used in XAudio2Create, specifies which CPU(s) to use. */
typedef UINT32 XAUDIO2_PROCESSOR;
#define Processor1 0x00000001
#define Processor2 0x00000002
#define Processor3 0x00000004
#define Processor4 0x00000008
#define Processor5 0x00000010
#define Processor6 0x00000020
#define Processor7 0x00000040
#define Processor8 0x00000080
#define Processor9 0x00000100
#define Processor10 0x00000200
#define Processor11 0x00000400
#define Processor12 0x00000800
#define Processor13 0x00001000
#define Processor14 0x00002000
#define Processor15 0x00004000
#define Processor16 0x00008000
#define Processor17 0x00010000
#define Processor18 0x00020000
#define Processor19 0x00040000
#define Processor20 0x00080000
#define Processor21 0x00100000
#define Processor22 0x00200000
#define Processor23 0x00400000
#define Processor24 0x00800000
#define Processor25 0x01000000
#define Processor26 0x02000000
#define Processor27 0x04000000
#define Processor28 0x08000000
#define Processor29 0x10000000
#define Processor30 0x20000000
#define Processor31 0x40000000
#define Processor32 0x80000000
#define XAUDIO2_ANY_PROCESSOR 0xffffffff
#define XAUDIO2_DEFAULT_PROCESSOR Processor1
/* Returned by IXAudio2Voice::GetVoiceDetails */
typedef struct XAUDIO2_VOICE_DETAILS
{
UINT32 CreationFlags; /* Flags the voice was created with. */
UINT32 ActiveFlags; /* Flags currently active. */
UINT32 InputChannels; /* Channels in the voice's input audio. */
UINT32 InputSampleRate; /* Sample rate of the voice's input audio. */
} XAUDIO2_VOICE_DETAILS;
/* Used in XAUDIO2_VOICE_SENDS below */
typedef struct XAUDIO2_SEND_DESCRIPTOR
{
UINT32 Flags; /* Either 0 or XAUDIO2_SEND_USEFILTER. */
IXAudio2Voice* pOutputVoice; /* This send's destination voice. */
} XAUDIO2_SEND_DESCRIPTOR;
/* Used in the voice creation functions and in IXAudio2Voice::SetOutputVoices */
typedef struct XAUDIO2_VOICE_SENDS
{
UINT32 SendCount; /* Number of sends from this voice. */
XAUDIO2_SEND_DESCRIPTOR* pSends; /* Array of SendCount send descriptors. */
} XAUDIO2_VOICE_SENDS;
/* Used in XAUDIO2_EFFECT_CHAIN below */
typedef struct XAUDIO2_EFFECT_DESCRIPTOR
{
IUnknown* pEffect; /* Pointer to the effect object's IUnknown interface. */
BOOL InitialState; /* TRUE if the effect should begin in the enabled state. */
UINT32 OutputChannels; /* How many output channels the effect should produce. */
} XAUDIO2_EFFECT_DESCRIPTOR;
/* Used in the voice creation functions and in IXAudio2Voice::SetEffectChain */
typedef struct XAUDIO2_EFFECT_CHAIN
{
UINT32 EffectCount; /* Number of effects in this voice's effect chain. */
XAUDIO2_EFFECT_DESCRIPTOR* pEffectDescriptors; /* Array of effect descriptors. */
} XAUDIO2_EFFECT_CHAIN;
/* Used in XAUDIO2_FILTER_PARAMETERS below */
typedef enum XAUDIO2_FILTER_TYPE
{
LowPassFilter, /* Attenuates frequencies above the cutoff frequency (state-variable filter). */
BandPassFilter, /* Attenuates frequencies outside a given range (state-variable filter). */
HighPassFilter, /* Attenuates frequencies below the cutoff frequency (state-variable filter). */
NotchFilter, /* Attenuates frequencies inside a given range (state-variable filter). */
LowPassOnePoleFilter, /* Attenuates frequencies above the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect) */
HighPassOnePoleFilter /* Attenuates frequencies below the cutoff frequency (one-pole filter, XAUDIO2_FILTER_PARAMETERS.OneOverQ has no effect) */
} XAUDIO2_FILTER_TYPE;
/* Used in IXAudio2Voice::Set/GetFilterParameters and Set/GetOutputFilterParameters */
typedef struct XAUDIO2_FILTER_PARAMETERS
{
XAUDIO2_FILTER_TYPE Type; /* Filter type. */
float Frequency; /* Filter coefficient. */
/* must be >= 0 and <= XAUDIO2_MAX_FILTER_FREQUENCY */
/* See XAudio2CutoffFrequencyToRadians() for state-variable filter types and */
/* XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types. */
float OneOverQ; /* Reciprocal of the filter's quality factor Q; */
/* must be > 0 and <= XAUDIO2_MAX_FILTER_ONEOVERQ. */
/* Has no effect for one-pole filters. */
} XAUDIO2_FILTER_PARAMETERS;
/* Used in IXAudio2SourceVoice::SubmitSourceBuffer */
typedef struct XAUDIO2_BUFFER
{
UINT32 Flags; /* Either 0 or XAUDIO2_END_OF_STREAM. */
UINT32 AudioBytes; /* Size of the audio data buffer in bytes. */
const BYTE* pAudioData; /* Pointer to the audio data buffer. */
UINT32 PlayBegin; /* First sample in this buffer to be played. */
UINT32 PlayLength; /* Length of the region to be played in samples, */
/* or 0 to play the whole buffer. */
UINT32 LoopBegin; /* First sample of the region to be looped. */
UINT32 LoopLength; /* Length of the desired loop region in samples, */
/* or 0 to loop the entire buffer. */
UINT32 LoopCount; /* Number of times to repeat the loop region, */
/* or XAUDIO2_LOOP_INFINITE to loop forever. */
void* pContext; /* Context value to be passed back in callbacks. */
} XAUDIO2_BUFFER;
/* Used in IXAudio2SourceVoice::SubmitSourceBuffer when submitting XWMA data.
* NOTE: If an XWMA sound is submitted in more than one buffer, each buffer's
* pDecodedPacketCumulativeBytes[PacketCount-1] value must be subtracted from
* all the entries in the next buffer's pDecodedPacketCumulativeBytes array.
* And whether a sound is submitted in more than one buffer or not, the final
* buffer of the sound should use the XAUDIO2_END_OF_STREAM flag, or else the
* client must call IXAudio2SourceVoice::Discontinuity after submitting it.
*/
typedef struct XAUDIO2_BUFFER_WMA
{
const UINT32* pDecodedPacketCumulativeBytes; /* Decoded packet's cumulative size array.
* Each element is the number of bytes accumulated
* when the corresponding XWMA packet is decoded in
* order. The array must have PacketCount elements. */
UINT32 PacketCount; /* Number of XWMA packets submitted. Must be >= 1 and */
/* divide evenly into XAUDIO2_BUFFER.AudioBytes. */
} XAUDIO2_BUFFER_WMA;
/* Returned by IXAudio2SourceVoice::GetState */
typedef struct XAUDIO2_VOICE_STATE
{
void* pCurrentBufferContext; /* The pContext value provided in the XAUDIO2_BUFFER */
/* that is currently being processed, or NULL if */
/* there are no buffers in the queue. */
UINT32 BuffersQueued; /* Number of buffers currently queued on the voice */
/* (including the one that is being processed). */
UINT64 SamplesPlayed; /* Total number of samples produced by the voice since
* it began processing the current audio stream.
* If XAUDIO2_VOICE_NOSAMPLESPLAYED is specified
* in the call to IXAudio2SourceVoice::GetState,
* this member will not be calculated, saving CPU. */
} XAUDIO2_VOICE_STATE;
/* Returned by IXAudio2::GetPerformanceData */
typedef struct XAUDIO2_PERFORMANCE_DATA
{
/* CPU usage information */
UINT64 AudioCyclesSinceLastQuery; /* CPU cycles spent on audio processing since the
* last call to StartEngine or GetPerformanceData. */
UINT64 TotalCyclesSinceLastQuery; /* Total CPU cycles elapsed since the last call
* (only counts the CPU XAudio2 is running on). */
UINT32 MinimumCyclesPerQuantum; /* Fewest CPU cycles spent processing any one
* audio quantum since the last call. */
UINT32 MaximumCyclesPerQuantum; /* Most CPU cycles spent processing any one
* audio quantum since the last call. */
/* Memory usage information */
UINT32 MemoryUsageInBytes; /* Total heap space currently in use. */
/* Audio latency and glitching information */
UINT32 CurrentLatencyInSamples; /* Minimum delay from when a sample is read from a */
/* source buffer to when it reaches the speakers. */
UINT32 GlitchesSinceEngineStarted; /* Audio dropouts since the engine was started. */
/* Data about XAudio2's current workload */
UINT32 ActiveSourceVoiceCount; /* Source voices currently playing. */
UINT32 TotalSourceVoiceCount; /* Source voices currently existing. */
UINT32 ActiveSubmixVoiceCount; /* Submix voices currently playing/existing. */
UINT32 ActiveResamplerCount; /* Resample xAPOs currently active. */
UINT32 ActiveMatrixMixCount; /* MatrixMix xAPOs currently active. */
/* Usage of the hardware XMA decoder (Xbox 360 only) */
UINT32 ActiveXmaSourceVoices; /* Number of source voices decoding XMA data. */
UINT32 ActiveXmaStreams; /* A voice can use more than one XMA stream. */
} XAUDIO2_PERFORMANCE_DATA;
/* Used in IXAudio2::SetDebugConfiguration */
typedef struct XAUDIO2_DEBUG_CONFIGURATION
{
UINT32 TraceMask; /* Bitmap of enabled debug message types. */
UINT32 BreakMask; /* Message types that will break into the debugger. */
BOOL LogThreadID; /* Whether to log the thread ID with each message. */
BOOL LogFileline; /* Whether to log the source file and line number. */
BOOL LogFunctionName; /* Whether to log the function name. */
BOOL LogTiming; /* Whether to log message timestamps. */
} XAUDIO2_DEBUG_CONFIGURATION;
/* Values for the TraceMask and BreakMask bitmaps. Only ERRORS and WARNINGS
* are valid in BreakMask. WARNINGS implies ERRORS, DETAIL implies INFO, and
* FUNC_CALLS implies API_CALLS. By default, TraceMask is ERRORS and WARNINGS
* and all the other settings are zero. */
#define XAUDIO2_LOG_ERRORS 0x0001 /* For handled errors with serious effects. */
#define XAUDIO2_LOG_WARNINGS 0x0002 /* For handled errors that may be recoverable. */
#define XAUDIO2_LOG_INFO 0x0004 /* Informational chit-chat (e.g. state changes). */
#define XAUDIO2_LOG_DETAIL 0x0008 /* More detailed chit-chat. */
#define XAUDIO2_LOG_API_CALLS 0x0010 /* Public API function entries and exits. */
#define XAUDIO2_LOG_FUNC_CALLS 0x0020 /* Internal function entries and exits. */
#define XAUDIO2_LOG_TIMING 0x0040 /* Delays detected and other timing data. */
#define XAUDIO2_LOG_LOCKS 0x0080 /* Usage of critical sections and mutexes. */
#define XAUDIO2_LOG_MEMORY 0x0100 /* Memory heap usage information. */
#define XAUDIO2_LOG_STREAMING 0x1000 /* Audio streaming information. */
/**************************************************************************
*
* IXAudio2: Top-level XAudio2 COM interface.
*
**************************************************************************/
/* Use default arguments if compiling as C++ */
#ifdef __cplusplus
#define X2DEFAULT(x) =x
#else
#define X2DEFAULT(x)
#endif
#undef INTERFACE
#define INTERFACE IXAudio2
DECLARE_INTERFACE_(IXAudio2, IUnknown)
{
STDMETHOD(QueryInterface) (THIS_ REFIID riid, _Outptr_ void** ppvInterface) PURE;
STDMETHOD_(ULONG, AddRef) (THIS) PURE;
STDMETHOD_(ULONG, Release) (THIS) PURE;
STDMETHOD(RegisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
STDMETHOD_(void, UnregisterForCallbacks) (_In_ IXAudio2EngineCallback* pCallback) PURE;
STDMETHOD(CreateSourceVoice) (THIS_ _Outptr_ IXAudio2SourceVoice** ppSourceVoice,
_In_ const WAVEFORMATEX* pSourceFormat,
UINT32 Flags X2DEFAULT(0),
float MaxFrequencyRatio X2DEFAULT(XAUDIO2_DEFAULT_FREQ_RATIO),
_In_opt_ IXAudio2VoiceCallback* pCallback X2DEFAULT(NULL),
_In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
_In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
STDMETHOD(CreateSubmixVoice) (THIS_ _Outptr_ IXAudio2SubmixVoice** ppSubmixVoice,
UINT32 InputChannels, UINT32 InputSampleRate,
UINT32 Flags X2DEFAULT(0), UINT32 ProcessingStage X2DEFAULT(0),
_In_opt_ const XAUDIO2_VOICE_SENDS* pSendList X2DEFAULT(NULL),
_In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL)) PURE;
STDMETHOD(CreateMasteringVoice) (THIS_ _Outptr_ IXAudio2MasteringVoice** ppMasteringVoice,
UINT32 InputChannels X2DEFAULT(XAUDIO2_DEFAULT_CHANNELS),
UINT32 InputSampleRate X2DEFAULT(XAUDIO2_DEFAULT_SAMPLERATE),
UINT32 Flags X2DEFAULT(0), _In_opt_z_ LPCWSTR szDeviceId X2DEFAULT(NULL),
_In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain X2DEFAULT(NULL),
_In_ AUDIO_STREAM_CATEGORY StreamCategory X2DEFAULT(AudioCategory_GameEffects)) PURE;
STDMETHOD(StartEngine) (THIS) PURE;
STDMETHOD_(void, StopEngine) (THIS) PURE;
STDMETHOD(CommitChanges) (THIS_ UINT32 OperationSet) PURE;
STDMETHOD_(void, GetPerformanceData) (THIS_ _Out_ XAUDIO2_PERFORMANCE_DATA* pPerfData) PURE;
STDMETHOD_(void, SetDebugConfiguration) (THIS_ _In_opt_ const XAUDIO2_DEBUG_CONFIGURATION* pDebugConfiguration,
_Reserved_ void* pReserved X2DEFAULT(NULL)) PURE;
};
/**************************************************************************
*
* IXAudio2Voice: Base voice management interface.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2Voice
DECLARE_INTERFACE(IXAudio2Voice)
{
#define Declare_IXAudio2Voice_Methods() \
STDMETHOD_(void, GetVoiceDetails) (THIS_ _Out_ XAUDIO2_VOICE_DETAILS* pVoiceDetails) PURE; \
STDMETHOD(SetOutputVoices) (THIS_ _In_opt_ const XAUDIO2_VOICE_SENDS* pSendList) PURE; \
STDMETHOD(SetEffectChain) (THIS_ _In_opt_ const XAUDIO2_EFFECT_CHAIN* pEffectChain) PURE; \
STDMETHOD(EnableEffect) (THIS_ UINT32 EffectIndex, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD(DisableEffect) (THIS_ UINT32 EffectIndex, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetEffectState) (THIS_ UINT32 EffectIndex, _Out_ BOOL* pEnabled) PURE; \
STDMETHOD(SetEffectParameters) (THIS_ UINT32 EffectIndex, \
_In_reads_bytes_(ParametersByteSize) const void* pParameters, \
UINT32 ParametersByteSize, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD(GetEffectParameters) (THIS_ UINT32 EffectIndex, \
_Out_writes_bytes_(ParametersByteSize) void* pParameters, \
UINT32 ParametersByteSize) PURE; \
STDMETHOD(SetFilterParameters) (THIS_ _In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetFilterParameters) (THIS_ _Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
STDMETHOD(SetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
_In_ const XAUDIO2_FILTER_PARAMETERS* pParameters, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetOutputFilterParameters) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
_Out_ XAUDIO2_FILTER_PARAMETERS* pParameters) PURE; \
STDMETHOD(SetVolume) (THIS_ float Volume, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetVolume) (THIS_ _Out_ float* pVolume) PURE; \
STDMETHOD(SetChannelVolumes) (THIS_ UINT32 Channels, _In_reads_(Channels) const float* pVolumes, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetChannelVolumes) (THIS_ UINT32 Channels, _Out_writes_(Channels) float* pVolumes) PURE; \
STDMETHOD(SetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
UINT32 SourceChannels, UINT32 DestinationChannels, \
_In_reads_(SourceChannels * DestinationChannels) const float* pLevelMatrix, \
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE; \
STDMETHOD_(void, GetOutputMatrix) (THIS_ _In_opt_ IXAudio2Voice* pDestinationVoice, \
UINT32 SourceChannels, UINT32 DestinationChannels, \
_Out_writes_(SourceChannels * DestinationChannels) float* pLevelMatrix) PURE; \
STDMETHOD_(void, DestroyVoice) (THIS) PURE
Declare_IXAudio2Voice_Methods();
};
/**************************************************************************
*
* IXAudio2SourceVoice: Source voice management interface.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2SourceVoice
DECLARE_INTERFACE_(IXAudio2SourceVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
STDMETHOD(Start) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD(Stop) (THIS_ UINT32 Flags X2DEFAULT(0), UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD(SubmitSourceBuffer) (THIS_ _In_ const XAUDIO2_BUFFER* pBuffer, _In_opt_ const XAUDIO2_BUFFER_WMA* pBufferWMA X2DEFAULT(NULL)) PURE;
STDMETHOD(FlushSourceBuffers) (THIS) PURE;
STDMETHOD(Discontinuity) (THIS) PURE;
STDMETHOD(ExitLoop) (THIS_ UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD_(void, GetState) (THIS_ _Out_ XAUDIO2_VOICE_STATE* pVoiceState, UINT32 Flags X2DEFAULT(0)) PURE;
STDMETHOD(SetFrequencyRatio) (THIS_ float Ratio,
UINT32 OperationSet X2DEFAULT(XAUDIO2_COMMIT_NOW)) PURE;
STDMETHOD_(void, GetFrequencyRatio) (THIS_ _Out_ float* pRatio) PURE;
STDMETHOD(SetSourceSampleRate) (THIS_ UINT32 NewSourceSampleRate) PURE;
};
/**************************************************************************
*
* IXAudio2SubmixVoice: Submixing voice management interface.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2SubmixVoice
DECLARE_INTERFACE_(IXAudio2SubmixVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
};
/**************************************************************************
*
* IXAudio2MasteringVoice: Mastering voice management interface.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2MasteringVoice
DECLARE_INTERFACE_(IXAudio2MasteringVoice, IXAudio2Voice)
{
Declare_IXAudio2Voice_Methods();
STDMETHOD(GetChannelMask) (THIS_ _Out_ DWORD* pChannelmask) PURE;
};
/**************************************************************************
*
* IXAudio2EngineCallback: Client notification interface for engine events.
*
* REMARKS: Contains methods to notify the client when certain events happen
* in the XAudio2 engine. This interface should be implemented by
* the client. XAudio2 will call these methods via the interface
* pointer provided by the client when it calls
* IXAudio2::RegisterForCallbacks.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2EngineCallback
DECLARE_INTERFACE(IXAudio2EngineCallback)
{
STDMETHOD_(void, OnProcessingPassStart) (THIS) PURE;
STDMETHOD_(void, OnProcessingPassEnd) (THIS) PURE;
STDMETHOD_(void, OnCriticalError) (THIS_ HRESULT Error) PURE;
};
/**************************************************************************
*
* IXAudio2VoiceCallback: Client notification interface for voice events.
*
* REMARKS: Contains methods to notify the client when certain events happen
* in an XAudio2 voice. This interface should be implemented by the
* client. XAudio2 will call these methods via an interface pointer
* provided by the client in the IXAudio2::CreateSourceVoice call.
*
**************************************************************************/
#undef INTERFACE
#define INTERFACE IXAudio2VoiceCallback
DECLARE_INTERFACE(IXAudio2VoiceCallback)
{
STDMETHOD_(void, OnVoiceProcessingPassStart) (THIS_ UINT32 BytesRequired) PURE;
STDMETHOD_(void, OnVoiceProcessingPassEnd) (THIS) PURE;
STDMETHOD_(void, OnStreamEnd) (THIS) PURE;
STDMETHOD_(void, OnBufferStart) (THIS_ void* pBufferContext) PURE;
STDMETHOD_(void, OnBufferEnd) (THIS_ void* pBufferContext) PURE;
STDMETHOD_(void, OnLoopEnd) (THIS_ void* pBufferContext) PURE;
STDMETHOD_(void, OnVoiceError) (THIS_ void* pBufferContext, HRESULT Error) PURE;
};
/**************************************************************************
*
* Macros to make it easier to use the XAudio2 COM interfaces in C code.
*
**************************************************************************/
#ifndef __cplusplus
/* IXAudio2 */
#define IXAudio2_QueryInterface(This,riid,ppvInterface) ((This)->lpVtbl->QueryInterface(This,riid,ppvInterface))
#define IXAudio2_AddRef(This) ((This)->lpVtbl->AddRef(This))
#define IXAudio2_Release(This) ((This)->lpVtbl->Release(This))
#define IXAudio2_CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) ((This)->lpVtbl->CreateSourceVoice(This,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain))
#define IXAudio2_CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain) ((This)->lpVtbl->CreateSubmixVoice(This,ppSubmixVoice,InputChannels,InputSampleRate,Flags,ProcessingStage,pSendList,pEffectChain))
#define IXAudio2_CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory) ((This)->lpVtbl->CreateMasteringVoice(This,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceId,pEffectChain,StreamCategory))
#define IXAudio2_StartEngine(This) ((This)->lpVtbl->StartEngine(This))
#define IXAudio2_StopEngine(This) ((This)->lpVtbl->StopEngine(This))
#define IXAudio2_CommitChanges(This,OperationSet) ((This)->lpVtbl->CommitChanges(This,OperationSet))
#define IXAudio2_GetPerformanceData(This,pPerfData) ((This)->lpVtbl->GetPerformanceData(This,pPerfData))
#define IXAudio2_SetDebugConfiguration(This,pDebugConfiguration,pReserved) ((This)->lpVtbl->SetDebugConfiguration(This,pDebugConfiguration,pReserved))
/* IXAudio2Voice */
#define IXAudio2Voice_GetVoiceDetails(This,pVoiceDetails) ((This)->lpVtbl->GetVoiceDetails(This,pVoiceDetails))
#define IXAudio2Voice_SetOutputVoices(This,pSendList) ((This)->lpVtbl->SetOutputVoices(This,pSendList))
#define IXAudio2Voice_SetEffectChain(This,pEffectChain) ((This)->lpVtbl->SetEffectChain(This,pEffectChain))
#define IXAudio2Voice_EnableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->EnableEffect(This,EffectIndex,OperationSet))
#define IXAudio2Voice_DisableEffect(This,EffectIndex,OperationSet) ((This)->lpVtbl->DisableEffect(This,EffectIndex,OperationSet))
#define IXAudio2Voice_GetEffectState(This,EffectIndex,pEnabled) ((This)->lpVtbl->GetEffectState(This,EffectIndex,pEnabled))
#define IXAudio2Voice_SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize, OperationSet) ((This)->lpVtbl->SetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize,OperationSet))
#define IXAudio2Voice_GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize) ((This)->lpVtbl->GetEffectParameters(This,EffectIndex,pParameters,ParametersByteSize))
#define IXAudio2Voice_SetFilterParameters(This,pParameters,OperationSet) ((This)->lpVtbl->SetFilterParameters(This,pParameters,OperationSet))
#define IXAudio2Voice_GetFilterParameters(This,pParameters) ((This)->lpVtbl->GetFilterParameters(This,pParameters))
#define IXAudio2Voice_SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet) ((This)->lpVtbl->SetOutputFilterParameters(This,pDestinationVoice,pParameters,OperationSet))
#define IXAudio2Voice_GetOutputFilterParameters(This,pDestinationVoice,pParameters) ((This)->lpVtbl->GetOutputFilterParameters(This,pDestinationVoice,pParameters))
#define IXAudio2Voice_SetVolume(This,Volume,OperationSet) ((This)->lpVtbl->SetVolume(This,Volume,OperationSet))
#define IXAudio2Voice_GetVolume(This,pVolume) ((This)->lpVtbl->GetVolume(This,pVolume))
#define IXAudio2Voice_SetChannelVolumes(This,Channels,pVolumes,OperationSet) ((This)->lpVtbl->SetChannelVolumes(This,Channels,pVolumes,OperationSet))
#define IXAudio2Voice_GetChannelVolumes(This,Channels,pVolumes) ((This)->lpVtbl->GetChannelVolumes(This,Channels,pVolumes))
#define IXAudio2Voice_SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet) ((This)->lpVtbl->SetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix,OperationSet))
#define IXAudio2Voice_GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix) ((This)->lpVtbl->GetOutputMatrix(This,pDestinationVoice,SourceChannels,DestinationChannels,pLevelMatrix))
#define IXAudio2Voice_DestroyVoice(This) ((This)->lpVtbl->DestroyVoice(This))
/* IXAudio2SourceVoice */
#define IXAudio2SourceVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
#define IXAudio2SourceVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
#define IXAudio2SourceVoice_SetEffectChain IXAudio2Voice_SetEffectChain
#define IXAudio2SourceVoice_EnableEffect IXAudio2Voice_EnableEffect
#define IXAudio2SourceVoice_DisableEffect IXAudio2Voice_DisableEffect
#define IXAudio2SourceVoice_GetEffectState IXAudio2Voice_GetEffectState
#define IXAudio2SourceVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
#define IXAudio2SourceVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
#define IXAudio2SourceVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
#define IXAudio2SourceVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
#define IXAudio2SourceVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
#define IXAudio2SourceVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
#define IXAudio2SourceVoice_SetVolume IXAudio2Voice_SetVolume
#define IXAudio2SourceVoice_GetVolume IXAudio2Voice_GetVolume
#define IXAudio2SourceVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
#define IXAudio2SourceVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
#define IXAudio2SourceVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
#define IXAudio2SourceVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
#define IXAudio2SourceVoice_DestroyVoice IXAudio2Voice_DestroyVoice
#define IXAudio2SourceVoice_Start(This,Flags,OperationSet) ((This)->lpVtbl->Start(This,Flags,OperationSet))
#define IXAudio2SourceVoice_Stop(This,Flags,OperationSet) ((This)->lpVtbl->Stop(This,Flags,OperationSet))
#define IXAudio2SourceVoice_SubmitSourceBuffer(This,pBuffer,pBufferWMA) ((This)->lpVtbl->SubmitSourceBuffer(This,pBuffer,pBufferWMA))
#define IXAudio2SourceVoice_FlushSourceBuffers(This) ((This)->lpVtbl->FlushSourceBuffers(This))
#define IXAudio2SourceVoice_Discontinuity(This) ((This)->lpVtbl->Discontinuity(This))
#define IXAudio2SourceVoice_ExitLoop(This,OperationSet) ((This)->lpVtbl->ExitLoop(This,OperationSet))
#define IXAudio2SourceVoice_GetState(This,pVoiceState,Flags) ((This)->lpVtbl->GetState(This,pVoiceState,Flags))
#define IXAudio2SourceVoice_SetFrequencyRatio(This,Ratio,OperationSet) ((This)->lpVtbl->SetFrequencyRatio(This,Ratio,OperationSet))
#define IXAudio2SourceVoice_GetFrequencyRatio(This,pRatio) ((This)->lpVtbl->GetFrequencyRatio(This,pRatio))
#define IXAudio2SourceVoice_SetSourceSampleRate(This,NewSourceSampleRate) ((This)->lpVtbl->SetSourceSampleRate(This,NewSourceSampleRate))
/* IXAudio2SubmixVoice */
#define IXAudio2SubmixVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
#define IXAudio2SubmixVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
#define IXAudio2SubmixVoice_SetEffectChain IXAudio2Voice_SetEffectChain
#define IXAudio2SubmixVoice_EnableEffect IXAudio2Voice_EnableEffect
#define IXAudio2SubmixVoice_DisableEffect IXAudio2Voice_DisableEffect
#define IXAudio2SubmixVoice_GetEffectState IXAudio2Voice_GetEffectState
#define IXAudio2SubmixVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
#define IXAudio2SubmixVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
#define IXAudio2SubmixVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
#define IXAudio2SubmixVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
#define IXAudio2SubmixVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
#define IXAudio2SubmixVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
#define IXAudio2SubmixVoice_SetVolume IXAudio2Voice_SetVolume
#define IXAudio2SubmixVoice_GetVolume IXAudio2Voice_GetVolume
#define IXAudio2SubmixVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
#define IXAudio2SubmixVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
#define IXAudio2SubmixVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
#define IXAudio2SubmixVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
#define IXAudio2SubmixVoice_DestroyVoice IXAudio2Voice_DestroyVoice
/* IXAudio2MasteringVoice */
#define IXAudio2MasteringVoice_GetVoiceDetails IXAudio2Voice_GetVoiceDetails
#define IXAudio2MasteringVoice_SetOutputVoices IXAudio2Voice_SetOutputVoices
#define IXAudio2MasteringVoice_SetEffectChain IXAudio2Voice_SetEffectChain
#define IXAudio2MasteringVoice_EnableEffect IXAudio2Voice_EnableEffect
#define IXAudio2MasteringVoice_DisableEffect IXAudio2Voice_DisableEffect
#define IXAudio2MasteringVoice_GetEffectState IXAudio2Voice_GetEffectState
#define IXAudio2MasteringVoice_SetEffectParameters IXAudio2Voice_SetEffectParameters
#define IXAudio2MasteringVoice_GetEffectParameters IXAudio2Voice_GetEffectParameters
#define IXAudio2MasteringVoice_SetFilterParameters IXAudio2Voice_SetFilterParameters
#define IXAudio2MasteringVoice_GetFilterParameters IXAudio2Voice_GetFilterParameters
#define IXAudio2MasteringVoice_SetOutputFilterParameters IXAudio2Voice_SetOutputFilterParameters
#define IXAudio2MasteringVoice_GetOutputFilterParameters IXAudio2Voice_GetOutputFilterParameters
#define IXAudio2MasteringVoice_SetVolume IXAudio2Voice_SetVolume
#define IXAudio2MasteringVoice_GetVolume IXAudio2Voice_GetVolume
#define IXAudio2MasteringVoice_SetChannelVolumes IXAudio2Voice_SetChannelVolumes
#define IXAudio2MasteringVoice_GetChannelVolumes IXAudio2Voice_GetChannelVolumes
#define IXAudio2MasteringVoice_SetOutputMatrix IXAudio2Voice_SetOutputMatrix
#define IXAudio2MasteringVoice_GetOutputMatrix IXAudio2Voice_GetOutputMatrix
#define IXAudio2MasteringVoice_DestroyVoice IXAudio2Voice_DestroyVoice
#define IXAudio2MasteringVoice_GetChannelMask(This,pChannelMask) ((This)->lpVtbl->GetChannelMask(This,pChannelMask))
#endif /* #ifndef __cplusplus */
/**************************************************************************
*
* Utility functions used to convert from pitch in semitones and volume
* in decibels to the frequency and amplitude ratio units used by XAudio2.
* These are only defined if the client #defines XAUDIO2_HELPER_FUNCTIONS
* prior to #including xaudio2.h.
*
**************************************************************************/
#ifdef XAUDIO2_HELPER_FUNCTIONS
#define _USE_MATH_DEFINES /* Make math.h define M_PI */
#include <math.h> /* For powf, log10f, sinf and asinf */
/* Calculate the argument to SetVolume from a decibel value */
static INLINE float XAudio2DecibelsToAmplitudeRatio(float Decibels)
{
return powf(10.0f, Decibels / 20.0f);
}
/* Recover a volume in decibels from an amplitude factor */
static INLINE float XAudio2AmplitudeRatioToDecibels(float Volume)
{
if (Volume == 0)
return -3.402823466e+38f; /* Smallest float value (-FLT_MAX) */
return 20.0f * log10f(Volume);
}
/* Calculate the argument to SetFrequencyRatio from a semitone value */
static INLINE float XAudio2SemitonesToFrequencyRatio(float Semitones)
{
/* FrequencyRatio = 2 ^ Octaves
* = 2 ^ (Semitones / 12)
*/
return powf(2.0f, Semitones / 12.0f);
}
/* Recover a pitch in semitones from a frequency ratio */
static INLINE float XAudio2FrequencyRatioToSemitones(float FrequencyRatio)
{
/* Semitones = 12 * log2(FrequencyRatio)
* = 12 * log2(10) * log10(FrequencyRatio)
*/
return 39.86313713864835f * log10f(FrequencyRatio);
}
/* Convert from filter cutoff frequencies expressed in Hertz to the radian
* frequency values used in XAUDIO2_FILTER_PARAMETERS.Frequency, state-variable
* filter types only. Use XAudio2CutoffFrequencyToOnePoleCoefficient() for one-pole filter types.
* Note that the highest CutoffFrequency supported is SampleRate/6.
* Higher values of CutoffFrequency will return XAUDIO2_MAX_FILTER_FREQUENCY.
*/
static INLINE float XAudio2CutoffFrequencyToRadians(float CutoffFrequency, UINT32 SampleRate)
{
if ((UINT32)(CutoffFrequency * 6.0f) >= SampleRate)
return XAUDIO2_MAX_FILTER_FREQUENCY;
return 2.0f * sinf((float)M_PI * CutoffFrequency / SampleRate);
}
/* Convert from radian frequencies back to absolute frequencies in Hertz */
static INLINE float XAudio2RadiansToCutoffFrequency(float Radians, float SampleRate)
{
return SampleRate * asinf(Radians / 2.0f) / (float)M_PI;
}
/* Convert from filter cutoff frequencies expressed in Hertz to the filter
* coefficients used with XAUDIO2_FILTER_PARAMETERS.Frequency,
* LowPassOnePoleFilter and HighPassOnePoleFilter filter types only.
* Use XAudio2CutoffFrequencyToRadians() for state-variable filter types.
*/
static INLINE float XAudio2CutoffFrequencyToOnePoleCoefficient(float CutoffFrequency, UINT32 SampleRate)
{
if ((UINT32)CutoffFrequency >= SampleRate)
return XAUDIO2_MAX_FILTER_FREQUENCY;
return (1.0f - powf(1.0f - 2.0f * CutoffFrequency / SampleRate, 2.0f));
}
#endif /* #ifdef XAUDIO2_HELPER_FUNCTIONS */
/**************************************************************************
*
* XAudio2Create: Top-level function that creates an XAudio2 instance.
*
* ARGUMENTS:
*
* Flags - Flags specifying the XAudio2 object's behavior.
*
* XAudio2Processor - An XAUDIO2_PROCESSOR value that specifies the
* hardware threads (Xbox) or processors (Windows) that XAudio2
* will use. Note that XAudio2 supports concurrent processing on
* multiple threads, using any combination of XAUDIO2_PROCESSOR
* flags. The values are platform-specific; platform-independent
* code can use XAUDIO2_DEFAULT_PROCESSOR to use the default on
* each platform.
*
**************************************************************************/
#ifdef __cplusplus__
#if (defined XAUDIO2_EXPORT)
/* We're building xaudio2.dll */
#define XAUDIO2_STDAPI extern "C" __declspec(dllexport) HRESULT __stdcall
#else
/* We're an xaudio2 client */
#define XAUDIO2_STDAPI extern "C" __declspec(dllimport) HRESULT __stdcall
#endif
#else
/* Modified for C support */
#if (defined XAUDIO2_EXPORT)
/* We're building xaudio2.dll */
#define XAUDIO2_STDAPI __declspec(dllexport) HRESULT __stdcall
#else
/* We're an xaudio2 client */
#define XAUDIO2_STDAPI __declspec(dllimport) HRESULT __stdcall
#endif
#endif
#if (NTDDI_VERSION >= NTDDI_WIN10_RS5) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
XAUDIO2_STDAPI XAudio2CreateWithVersionInfo(_Outptr_ IXAudio2** ppXAudio2,
UINT32 Flags X2DEFAULT(0),
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR),
DWORD ntddiVersion X2DEFAULT(NTDDI_VERSION));
static INLINE HRESULT XAudio2Create(_Outptr_ IXAudio2** ppXAudio2,
UINT32 Flags X2DEFAULT(0),
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR))
{
/* When compiled for RS5 or later, try to invoke XAudio2CreateWithVersionInfo.
* Need to use LoadLibrary in case the app is running on an older OS. */
typedef HRESULT(__stdcall *XAudio2CreateWithVersionInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR, DWORD);
typedef HRESULT(__stdcall *XAudio2CreateInfoFunc)(_Outptr_ IXAudio2**, UINT32, XAUDIO2_PROCESSOR);
static XAudio2CreateWithVersionInfoFunc
s_pfnAudio2CreateWithVersion = NULL;
static XAudio2CreateInfoFunc s_pfnAudio2Create = NULL;
static HMODULE s_dllInstance = NULL;
if (!s_dllInstance)
{
s_dllInstance = LoadLibraryEx(XAUDIO2_DLL, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32);
if (!s_dllInstance)
return HRESULT_FROM_WIN32(GetLastError());
s_pfnAudio2CreateWithVersion = (XAudio2CreateWithVersionInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2CreateWithVersionInfo");
if (!s_pfnAudio2CreateWithVersion)
{
s_pfnAudio2Create = (XAudio2CreateInfoFunc)(void*)GetProcAddress(s_dllInstance, "XAudio2Create");
if (!s_pfnAudio2Create)
return HRESULT_FROM_WIN32(GetLastError());
}
}
if (s_pfnAudio2CreateWithVersion)
return (*s_pfnAudio2CreateWithVersion)(ppXAudio2, Flags, XAudio2Processor, NTDDI_VERSION);
return (*s_pfnAudio2Create)(ppXAudio2, Flags, XAudio2Processor);
}
#else
/* RS4 or older, or not a desktop app */
XAUDIO2_STDAPI XAudio2Create(_Outptr_ IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0),
XAUDIO2_PROCESSOR XAudio2Processor X2DEFAULT(XAUDIO2_DEFAULT_PROCESSOR));
#endif
/* Undo the #pragma pack(push, 1) directive at the top of this file */
#pragma pack(pop)
#endif /* #ifndef GUID_DEFS_ONLY */
#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP | WINAPI_PARTITION_TV_APP | WINAPI_PARTITION_TV_TITLE) */
#pragma endregion
#endif /* #ifndef __XAUDIO2_INCLUDED__ */

View File

@ -1,154 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <boolean.h>
#include <xenon_sound/sound.h>
#include <retro_inline.h>
#include "../../retroarch.h"
#define SOUND_FREQUENCY 48000
#define MAX_BUFFER 2048
typedef struct
{
uint32_t buffer[2048];
bool nonblock;
bool is_paused;
} xenon_audio_t;
static void *xenon360_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
{
static bool inited = false;
if (!inited)
{
xenon_sound_init();
inited = true;
}
*new_rate = SOUND_FREQUENCY;
return calloc(1, sizeof(xenon_audio_t));
}
static INLINE uint32_t bswap_32(uint32_t val)
{
return (val >> 24) | (val << 24) |
((val >> 8) & 0xff00) | ((val << 8) & 0xff0000);
}
static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size)
{
size_t written = 0, i;
const uint32_t *in_buf = buf;
xenon_audio_t *xa = data;
for (i = 0; i < (size >> 2); i++)
xa->buffer[i] = bswap_32(in_buf[i]);
if (xa->nonblock)
{
if (xenon_sound_get_unplayed() < MAX_BUFFER)
{
xenon_sound_submit(xa->buffer, size);
written = size;
}
}
else
{
while (xenon_sound_get_unplayed() >= MAX_BUFFER)
{
/* libxenon doesn't have proper
* synchronization primitives for this... */
udelay(50);
}
xenon_sound_submit(xa->buffer, size);
written = size;
}
return written;
}
static bool xenon360_audio_stop(void *data)
{
xenon_audio_t *xa = data;
xa->is_paused = true;
return true;
}
static bool xenon360_audio_alive(void *data)
{
xenon_audio_t *xa = data;
if (!xa)
return false;
return !xa->is_paused;
}
static void xenon360_audio_set_nonblock_state(void *data, bool state)
{
xenon_audio_t *xa = data;
if (xa)
xa->nonblock = state;
}
static bool xenon360_audio_start(void *data, bool is_shutdown)
{
xenon_audio_t *xa = data;
xa->is_paused = false;
return true;
}
static void xenon360_audio_free(void *data)
{
if (data)
free(data);
}
static bool xenon360_use_float(void *data)
{
(void)data;
return false;
}
static size_t xenon360_write_avail(void *data)
{
(void)data;
return 0;
}
audio_driver_t audio_xenon360 = {
xenon360_audio_init,
xenon360_audio_write,
xenon360_audio_stop,
xenon360_audio_start,
xenon360_audio_alive,
xenon360_audio_set_nonblock_state,
xenon360_audio_free,
xenon360_use_float,
"xenon360",
NULL,
NULL,
xenon360_write_avail,
NULL
};

View File

@ -1,548 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel ( aliaspider@gmail.com )
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
/* Convoluted Cosine Resampler */
#include <stdint.h>
#include <stdlib.h>
#ifdef __SSE__
#include <xmmintrin.h>
#endif
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <memalign.h>
#include <math/float_minmax.h>
#include <audio/audio_resampler.h>
/* Since SSE and NEON don't provide support for trigonometric functions
* we approximate those with polynoms
*
* CC_RESAMPLER_PRECISION defines how accurate the approximation is
* a setting of 5 or more means full precison.
* setting 0 doesn't use a polynom
* setting 1 uses P(X) = X - (3/4)*X^3 + (1/4)*X^5
*
* only 0 and 1 are implemented for SSE and NEON currently
*
* the MIPS_ARCH_ALLEGREX target doesnt require this setting since it has
* native support for the required functions so it will always use full precision.
*/
#ifndef CC_RESAMPLER_PRECISION
#define CC_RESAMPLER_PRECISION 1
#endif
typedef struct rarch_CC_resampler
{
audio_frame_float_t buffer[4];
float distance;
void (*process)(void *re, struct resampler_data *data);
} rarch_CC_resampler_t;
#ifdef _MIPS_ARCH_ALLEGREX
static void resampler_CC_process(void *re_, struct resampler_data *data)
{
float ratio, fraction;
audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in;
audio_frame_float_t *inp_max = (audio_frame_float_t*)
(inp + data->input_frames);
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
(void)re_;
__asm__ (
".set push\n"
".set noreorder\n"
"mtv %2, s700 \n" /* 700 = data->ratio = b */
/* "vsat0.s s700, s700 \n" */
"vrcp.s s701, s700 \n" /* 701 = 1.0 / b */
"vadd.s s702, s700, s700 \n" /* 702 = 2 * b */
"vmul.s s703, s700, s710 \n" /* 703 = b * pi */
"mfv %0, s701 \n"
"mfv %1, s730 \n"
".set pop\n"
: "=r"(ratio), "=r"(fraction)
: "r"((float)data->ratio)
);
for (;;)
{
while (fraction < ratio)
{
if (inp == inp_max)
goto done;
__asm__ (
".set push \n"
".set noreorder \n"
"lv.s s620, 0(%1) \n"
"lv.s s621, 4(%1) \n"
"vsub.s s731, s701, s730 \n"
"vadd.q c600, c730[-X,Y,-X,Y], c730[1/2,1/2,-1/2,-1/2]\n"
"vmul.q c610, c600, c700[Z,Z,Z,Z] \n" /* *2*b */
"vmul.q c600, c600, c700[W,W,W,W] \n" /* *b*pi */
"vsin.q c610, c610 \n"
"vadd.q c600, c600, c610 \n"
"vmul.q c600[-1:1,-1:1,-1:1,-1:1], c600, c710[Y,Y,Y,Y] \n"
"vsub.p c600, c600, c602 \n"
"vmul.q c620, c620[X,Y,X,Y], c600[X,X,Y,Y] \n"
"vadd.q c720, c720, c620 \n"
"vadd.s s730, s730, s730[1] \n"
"mfv %0, s730 \n"
".set pop \n"
: "=r"(fraction)
: "r"(inp));
inp++;
}
__asm__ (
".set push \n"
".set noreorder \n"
"vmul.p c720, c720, c720[1/2,1/2] \n"
"sv.s s720, 0(%1) \n"
"sv.s s721, 4(%1) \n"
"vmov.q c720, c720[Z,W,0,0] \n"
"vsub.s s730, s730, s701 \n"
"mfv %0, s730 \n"
".set pop \n"
: "=r"(fraction)
: "r"(outp));
outp++;
}
/* The VFPU state is assumed to remain intact
* in-between calls to resampler_CC_process. */
done:
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
static void *resampler_CC_init(const struct resampler_config *config,
double bandwidth_mod,
enum resampler_quality quality,
resampler_simd_mask_t mask)
{
(void)mask;
(void)bandwidth_mod;
(void)config;
__asm__ (
".set push\n"
".set noreorder\n"
"vcst.s s710, VFPU_PI \n" /* 710 = pi */
"vcst.s s711, VFPU_1_PI \n" /* 711 = 1.0 / (pi) */
"vzero.q c720 \n"
"vzero.q c730 \n"
".set pop\n");
return (void*)-1;
}
#else
#if defined(__SSE__)
#define CC_RESAMPLER_IDENT "SSE"
static void resampler_CC_downsample(void *re_, struct resampler_data *data)
{
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in;
audio_frame_float_t *inp_max = (audio_frame_float_t*)(inp + data->input_frames);
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
float ratio = 1.0 / data->ratio;
float b = data->ratio; /* cutoff frequency. */
__m128 vec_previous = _mm_loadu_ps((float*)&re->buffer[0]);
__m128 vec_current = _mm_loadu_ps((float*)&re->buffer[2]);
while (inp != inp_max)
{
__m128 vec_ww1, vec_ww2;
__m128 vec_w_previous;
__m128 vec_w_current;
__m128 vec_in;
__m128 vec_ratio =
_mm_mul_ps(_mm_set_ps1(ratio), _mm_set_ps(3.0, 2.0, 1.0, 0.0));
__m128 vec_w = _mm_sub_ps(_mm_set_ps1(re->distance), vec_ratio);
__m128 vec_w1 = _mm_add_ps(vec_w , _mm_set_ps1(0.5));
__m128 vec_w2 = _mm_sub_ps(vec_w , _mm_set_ps1(0.5));
__m128 vec_b = _mm_set_ps1(b);
vec_w1 = _mm_mul_ps(vec_w1, vec_b);
vec_w2 = _mm_mul_ps(vec_w2, vec_b);
(void)vec_ww1;
(void)vec_ww2;
#if (CC_RESAMPLER_PRECISION > 0)
vec_ww1 = _mm_mul_ps(vec_w1, vec_w1);
vec_ww2 = _mm_mul_ps(vec_w2, vec_w2);
vec_ww1 = _mm_mul_ps(vec_ww1, _mm_sub_ps(_mm_set_ps1(3.0),vec_ww1));
vec_ww2 = _mm_mul_ps(vec_ww2, _mm_sub_ps(_mm_set_ps1(3.0),vec_ww2));
vec_ww1 = _mm_mul_ps(_mm_set_ps1(1.0/4.0), vec_ww1);
vec_ww2 = _mm_mul_ps(_mm_set_ps1(1.0/4.0), vec_ww2);
vec_w1 = _mm_mul_ps(vec_w1, _mm_sub_ps(_mm_set_ps1(1.0), vec_ww1));
vec_w2 = _mm_mul_ps(vec_w2, _mm_sub_ps(_mm_set_ps1(1.0), vec_ww2));
#endif
vec_w1 = _mm_min_ps(vec_w1, _mm_set_ps1( 0.5));
vec_w2 = _mm_min_ps(vec_w2, _mm_set_ps1( 0.5));
vec_w1 = _mm_max_ps(vec_w1, _mm_set_ps1(-0.5));
vec_w2 = _mm_max_ps(vec_w2, _mm_set_ps1(-0.5));
vec_w = _mm_sub_ps(vec_w1, vec_w2);
vec_w_previous =
_mm_shuffle_ps(vec_w,vec_w,_MM_SHUFFLE(1, 1, 0, 0));
vec_w_current =
_mm_shuffle_ps(vec_w,vec_w,_MM_SHUFFLE(3, 3, 2, 2));
vec_in = _mm_loadl_pi(_mm_setzero_ps(),(__m64*)inp);
vec_in = _mm_shuffle_ps(vec_in,vec_in,_MM_SHUFFLE(1, 0, 1, 0));
vec_previous =
_mm_add_ps(vec_previous, _mm_mul_ps(vec_in, vec_w_previous));
vec_current =
_mm_add_ps(vec_current, _mm_mul_ps(vec_in, vec_w_current));
re->distance++;
inp++;
if (re->distance > (ratio + 0.5))
{
_mm_storel_pi((__m64*)outp, vec_previous);
vec_previous =
_mm_shuffle_ps(vec_previous,vec_current,_MM_SHUFFLE(1, 0, 3, 2));
vec_current =
_mm_shuffle_ps(vec_current,_mm_setzero_ps(),_MM_SHUFFLE(1, 0, 3, 2));
re->distance -= ratio;
outp++;
}
}
_mm_storeu_ps((float*)&re->buffer[0], vec_previous);
_mm_storeu_ps((float*)&re->buffer[2], vec_current);
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
static void resampler_CC_upsample(void *re_, struct resampler_data *data)
{
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in;
audio_frame_float_t *inp_max = (audio_frame_float_t*)(inp + data->input_frames);
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
float b = float_min(data->ratio, 1.00); /* cutoff frequency. */
float ratio = 1.0 / data->ratio;
__m128 vec_previous = _mm_loadu_ps((float*)&re->buffer[0]);
__m128 vec_current = _mm_loadu_ps((float*)&re->buffer[2]);
while (inp != inp_max)
{
__m128 vec_in = _mm_loadl_pi(_mm_setzero_ps(),(__m64*)inp);
vec_previous =
_mm_shuffle_ps(vec_previous,vec_current,_MM_SHUFFLE(1, 0, 3, 2));
vec_current =
_mm_shuffle_ps(vec_current,vec_in,_MM_SHUFFLE(1, 0, 3, 2));
while (re->distance < 1.0)
{
__m128 vec_w_previous, vec_w_current, vec_out;
#if (CC_RESAMPLER_PRECISION > 0)
__m128 vec_ww1, vec_ww2;
#endif
__m128 vec_w =
_mm_add_ps(_mm_set_ps1(re->distance), _mm_set_ps(-2.0, -1.0, 0.0, 1.0));
__m128 vec_w1 = _mm_add_ps(vec_w , _mm_set_ps1(0.5));
__m128 vec_w2 = _mm_sub_ps(vec_w , _mm_set_ps1(0.5));
__m128 vec_b = _mm_set_ps1(b);
vec_w1 = _mm_mul_ps(vec_w1, vec_b);
vec_w2 = _mm_mul_ps(vec_w2, vec_b);
#if (CC_RESAMPLER_PRECISION > 0)
vec_ww1 = _mm_mul_ps(vec_w1, vec_w1);
vec_ww2 = _mm_mul_ps(vec_w2, vec_w2);
vec_ww1 = _mm_mul_ps(vec_ww1,_mm_sub_ps(_mm_set_ps1(3.0),vec_ww1));
vec_ww2 = _mm_mul_ps(vec_ww2,_mm_sub_ps(_mm_set_ps1(3.0),vec_ww2));
vec_ww1 = _mm_mul_ps(_mm_set_ps1(1.0 / 4.0), vec_ww1);
vec_ww2 = _mm_mul_ps(_mm_set_ps1(1.0 / 4.0), vec_ww2);
vec_w1 = _mm_mul_ps(vec_w1, _mm_sub_ps(_mm_set_ps1(1.0), vec_ww1));
vec_w2 = _mm_mul_ps(vec_w2, _mm_sub_ps(_mm_set_ps1(1.0), vec_ww2));
#endif
vec_w1 = _mm_min_ps(vec_w1, _mm_set_ps1( 0.5));
vec_w2 = _mm_min_ps(vec_w2, _mm_set_ps1( 0.5));
vec_w1 = _mm_max_ps(vec_w1, _mm_set_ps1(-0.5));
vec_w2 = _mm_max_ps(vec_w2, _mm_set_ps1(-0.5));
vec_w = _mm_sub_ps(vec_w1, vec_w2);
vec_w_previous = _mm_shuffle_ps(vec_w,vec_w,_MM_SHUFFLE(1, 1, 0, 0));
vec_w_current = _mm_shuffle_ps(vec_w,vec_w,_MM_SHUFFLE(3, 3, 2, 2));
vec_out = _mm_mul_ps(vec_previous, vec_w_previous);
vec_out = _mm_add_ps(vec_out, _mm_mul_ps(vec_current, vec_w_current));
vec_out =
_mm_add_ps(vec_out, _mm_shuffle_ps(vec_out,vec_out,_MM_SHUFFLE(3, 2, 3, 2)));
_mm_storel_pi((__m64*)outp,vec_out);
re->distance += ratio;
outp++;
}
re->distance -= 1.0;
inp++;
}
_mm_storeu_ps((float*)&re->buffer[0], vec_previous);
_mm_storeu_ps((float*)&re->buffer[2], vec_current);
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
#elif defined (__ARM_NEON__) && !defined(DONT_WANT_ARM_OPTIMIZATIONS)
#define CC_RESAMPLER_IDENT "NEON"
size_t resampler_CC_downsample_neon(float *outp, const float *inp,
rarch_CC_resampler_t* re_, size_t input_frames, float ratio);
size_t resampler_CC_upsample_neon (float *outp, const float *inp,
rarch_CC_resampler_t* re_, size_t input_frames, float ratio);
static void resampler_CC_downsample(void *re_, struct resampler_data *data)
{
data->output_frames = resampler_CC_downsample_neon(
data->data_out, data->data_in, re_, data->input_frames, data->ratio);
}
static void resampler_CC_upsample(void *re_, struct resampler_data *data)
{
data->output_frames = resampler_CC_upsample_neon(
data->data_out, data->data_in, re_, data->input_frames, data->ratio);
}
#else
/* C reference version. Not optimized. */
#define CC_RESAMPLER_IDENT "C"
#if (CC_RESAMPLER_PRECISION > 4)
static INLINE float cc_int(float x, float b)
{
float val = x * b * M_PI + sinf(x * b * M_PI);
return (val > M_PI) ? M_PI : (val < -M_PI) ? -M_PI : val;
}
#define cc_kernel(x, b) ((cc_int((x) + 0.5, (b)) - cc_int((x) - 0.5, (b))) / (2.0 * M_PI))
#else
static INLINE float cc_int(float x, float b)
{
float val = x * b;
#if (CC_RESAMPLER_PRECISION > 0)
val = val*(1 - 0.25 * val * val * (3.0 - val * val));
#endif
return (val > 0.5) ? 0.5 : (val < -0.5) ? -0.5 : val;
}
#define cc_kernel(x, b) ((cc_int((x) + 0.5, (b)) - cc_int((x) - 0.5, (b))))
#endif
static INLINE void add_to(const audio_frame_float_t *source,
audio_frame_float_t *target, float ratio)
{
target->l += source->l * ratio;
target->r += source->r * ratio;
}
static void resampler_CC_downsample(void *re_, struct resampler_data *data)
{
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in;
audio_frame_float_t *inp_max = (audio_frame_float_t*)
(inp + data->input_frames);
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
float ratio = 1.0 / data->ratio;
float b = data->ratio; /* cutoff frequency. */
while (inp != inp_max)
{
add_to(inp, re->buffer + 0, cc_kernel(re->distance, b));
add_to(inp, re->buffer + 1, cc_kernel(re->distance - ratio, b));
add_to(inp, re->buffer + 2, cc_kernel(re->distance - ratio - ratio, b));
re->distance++;
inp++;
if (re->distance > (ratio + 0.5))
{
*outp = re->buffer[0];
re->buffer[0] = re->buffer[1];
re->buffer[1] = re->buffer[2];
re->buffer[2].l = 0.0;
re->buffer[2].r = 0.0;
re->distance -= ratio;
outp++;
}
}
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
static void resampler_CC_upsample(void *re_, struct resampler_data *data)
{
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
audio_frame_float_t *inp = (audio_frame_float_t*)data->data_in;
audio_frame_float_t *inp_max = (audio_frame_float_t*)
(inp + data->input_frames);
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
float b = float_min(data->ratio, 1.00); /* cutoff frequency. */
float ratio = 1.0 / data->ratio;
while (inp != inp_max)
{
re->buffer[0] = re->buffer[1];
re->buffer[1] = re->buffer[2];
re->buffer[2] = re->buffer[3];
re->buffer[3] = *inp;
while (re->distance < 1.0)
{
int i;
outp->l = 0.0;
outp->r = 0.0;
for (i = 0; i < 4; i++)
{
float temp = cc_kernel(re->distance + 1.0 - i, b);
outp->l += re->buffer[i].l * temp;
outp->r += re->buffer[i].r * temp;
}
re->distance += ratio;
outp++;
}
re->distance -= 1.0;
inp++;
}
data->output_frames = outp - (audio_frame_float_t*)data->data_out;
}
#endif
static void resampler_CC_process(void *re_, struct resampler_data *data)
{
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
if (re)
re->process(re_, data);
}
static void *resampler_CC_init(const struct resampler_config *config,
double bandwidth_mod,
enum resampler_quality quality,
resampler_simd_mask_t mask)
{
int i;
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)
memalign_alloc(32, sizeof(rarch_CC_resampler_t));
/* TODO: lookup if NEON support can be detected at
* runtime and a funcptr set at runtime for either
* C codepath or NEON codepath. This will help out
* Android. */
(void)mask;
(void)config;
if (!re)
return NULL;
for (i = 0; i < 4; i++)
{
re->buffer[i].l = 0.0;
re->buffer[i].r = 0.0;
}
/* Variations of data->ratio around 0.75 are safer
* than around 1.0 for both up/downsampler. */
if (bandwidth_mod < 0.75)
{
re->process = resampler_CC_downsample;
re->distance = 0.0;
}
else
{
re->process = resampler_CC_upsample;
re->distance = 2.0;
}
return re;
}
#endif
static void resampler_CC_free(void *re_)
{
#ifndef _MIPS_ARCH_ALLEGREX
rarch_CC_resampler_t *re = (rarch_CC_resampler_t*)re_;
if (re)
memalign_free(re);
#endif
(void)re_;
}
retro_resampler_t CC_resampler = {
resampler_CC_init,
resampler_CC_process,
resampler_CC_free,
RESAMPLER_API_VERSION,
"CC",
"cc"
};

View File

@ -1,370 +0,0 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel ( aliaspider@gmail.com )
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
* of the GNU General Public License as published by the Free Software Found-
* ation, either version 3 of the License, or (at your option) any later version.
*
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#if defined(__ARM_NEON__)
#ifndef CC_RESAMPLER_PRECISION
#define CC_RESAMPLER_PRECISION 1
#endif
#ifndef __MACH__
.arm
#endif
.align 4
.globl resampler_CC_downsample_neon
#ifndef __MACH__
.type resampler_CC_downsample_neon, %function
#endif
.globl _resampler_CC_downsample_neon
#ifndef __MACH__
.type _resampler_CC_downsample_neon, %function
#endif
# size_t resampler_CC_downsample_neon(float *outp, const float *inp,
# rarch_CC_resampler_t* re_, size_t input_frames, float ratio);
# r0: outp initial (and output_frames return value)
# r1: inp initial/current
# r2: re_ [r2+0] --> {q14,q15}=buffer , [r2+32] --> s5=distance
# r3: input_frames/inp_max
# r4: outp current
# r5:
# r6:
# r7:
# q0: d0: s0: 0.0 # q4: d8: s16: min(ratio, 1.0)
# s1: 1.0 # s17: min(ratio, 1.0)
# d1: s2: 2.0 # d9: s18: min(ratio, 1.0)
# s3: 3.0 # s19: min(ratio, 1.0)
# q1: d2: s4: ratio # q5: d10: s20: 1.0
# s5: distance # s21: 1.0
# d3: s6: (1.0/ratio) # d11: s22: 1.0
# s7: (1.0/ratio)+0.5 # s23: 1.0
# q2: d4: s8: 0.5 # q6: d12: s24: 3.0
# s9: 0.5 # s25: 3.0
# d5: s10: 0.5 # d13: s26: 3.0
# s11: 0.5 # s27: 3.0
# q3: d6: s12: -0.5 # q7: d14: s28: 0.25
# s13: -0.5 # s29: 0.25
# d7: s14: -0.5 # d15: s30: 0.25
# s15: -0.5 # s31: 0.25
# q8: d16: (temp) # q12: d24: (temp)
# (temp) # (temp)
# d17: (temp) # d25: (temp)
# (temp) # (temp)
# q9: d18: (temp) # q13: d26: (temp)
# (temp) # (temp)
# d19: (temp) # d27: (temp)
# (temp) # (temp)
# q10: d20: (temp) # q14: d28: buffer[0]
# (temp) # buffer[1]
# d21: (temp) # d29: buffer[2]
# (temp) # buffer[3]
# q11: d22: (temp) # q15: d30: buffer[4]
# (temp) # buffer[5]
# d23: (temp) # d31: buffer[6]
# (temp) # buffer[7]
resampler_CC_downsample_neon:
_resampler_CC_downsample_neon:
vld1.f32 {q14-q15}, [r2, :256]
vldr s4, [sp]
vpush {q4,q5,q6,q7}
push {r4}
mov r4, r0
veor q0, q0, q0
vmov.f32 s1, #1.0
vmov.f32 s2, #2.0
vmov.f32 s3, #3.0
vmov.f32 q2, #0.5
vmov.f32 q3, #-0.5
vmov.f32 q5, #1.0
vmov.f32 q6, #3.0
vmov.f32 q7, #0.25
vldr s5, [r2, #32]
vdiv.f32 s6, s20, s4
vadd.f32 s7, s6, s8
vdup.f32 q4, d2[0]
vmin.f32 q4, q4, q5
lsl r3, #3
add r3, r3, r1
cmp r3, r1
beq 3f
1:
vdup.f32 q8, d3[0]
vmul.f32 q8, q8, q0
vdup.f32 q9, d2[1]
vsub.f32 q8, q9, q8
vadd.f32 q10, q8, q2
vsub.f32 q11, q8, q2
vmul.f32 q10, q10, q4
vmul.f32 q11, q11, q4
#if (CC_RESAMPLER_PRECISION > 0)
vmul.f32 q8, q10, q10
vmul.f32 q9, q11, q11
vsub.f32 q12, q6, q8
vsub.f32 q13, q6, q9
vmul.f32 q12, q12, q8
vmul.f32 q13, q13, q9
vmul.f32 q12, q12, q7
vmul.f32 q13, q13, q7
vsub.f32 q12, q5, q12
vsub.f32 q13, q5, q13
vmul.f32 q10, q10, q12
vmul.f32 q11, q11, q13
#endif
vmin.f32 q10, q10, q2
vmin.f32 q11, q11, q2
vmax.f32 q10, q10, q3
vmax.f32 q11, q11, q3
vsub.f32 q10, q10, q11
vmov.f32 q11, q10
vzip.f32 q10, q11
vld1.f32 d16, [r1, :64]!
vmov.f32 d17, d16
vmul.f32 q10, q10, q8
vmul.f32 q11, q11, q8
vadd.f32 q14, q14, q10
vadd.f32 q15, q15, q11
# distance++
vadd.f32 s5, s5, s20
vcmpe.f32 s5, s7
vmrs APSR_nzcv, fpscr
ble 2f
vst1.f32 d28, [r4, :64]!
vmov.f32 d28, d29
vmov.f32 d29, d30
vmov.f32 d30, d31
vmov.f32 d31, #0.0
vsub.f32 s5, s5, s6
2:
cmp r3, r1
bne 1b
3:
vst1.f32 {q14-q15}, [r2, :256]
vstr s5, [r2, #32]
sub r0, r4, r0
lsr r0, r0, #3
pop {r4}
vpop {q4,q5,q6,q7}
bx lr
.align 4
.globl resampler_CC_upsample_neon
#ifndef __MACH__
.type resampler_CC_upsample_neon, %function
#endif
.globl _resampler_CC_upsample_neon
#ifndef __MACH__
.type _resampler_CC_upsample_neon, %function
#endif
# size_t resampler_CC_upsample_neon(float *outp, const float *inp,
# rarch_CC_resampler_t* re_, size_t input_frames, float ratio);
# r0: outp initial (and output_frames return value)
# r1: inp initial/current
# r2: re_ [r2+0] --> {q14,q15}=buffer , [r2+32] --> s5=distance
# r3: input_frames/inp_max
# r4: outp current
# r5:
# r6:
# r7:
# q0: d0: s0: 1.0 # q4: d8: s16: min(ratio, 1.0)
# s1: 0.0 # s17: min(ratio, 1.0)
# d1: s2: -1.0 # d9: s18: min(ratio, 1.0)
# s3: -2.0 # s19: min(ratio, 1.0)
# q1: d2: s4: ratio # q5: d10: s20: 1.0
# s5: distance # s21: 1.0
# d3: s6: (1.0/ratio) # d11: s22: 1.0
# s7: (1.0/ratio)+0.5 # s23: 1.0
# q2: d4: s8: 0.5 # q6: d12: s24: 3.0
# s9: 0.5 # s25: 3.0
# d5: s10: 0.5 # d13: s26: 3.0
# s11: 0.5 # s27: 3.0
# q3: d6: s12: -0.5 # q7: d14: s28: 0.25
# s13: -0.5 # s29: 0.25
# d7: s14: -0.5 # d15: s30: 0.25
# s15: -0.5 # s31: 0.25
# q8: d16: (temp) # q12: d24: (temp)
# (temp) # (temp)
# d17: (temp) # d25: (temp)
# (temp) # (temp)
# q9: d18: (temp) # q13: d26: (temp)
# (temp) # (temp)
# d19: (temp) # d27: (temp)
# (temp) # (temp)
# q10: d20: (temp) # q14: d28: buffer[0]
# (temp) # buffer[1]
# d21: (temp) # d29: buffer[2]
# (temp) # buffer[3]
# q11: d22: (temp) # q15: d30: buffer[4]
# (temp) # buffer[5]
# d23: (temp) # d31: buffer[6]
# (temp) # buffer[7]
resampler_CC_upsample_neon:
_resampler_CC_upsample_neon:
vld1.f32 {q14-q15}, [r2, :256]
vldr s4, [sp]
vpush {q4,q5,q6,q7}
push {r4}
mov r4, r0
veor q0, q0, q0
vmov.f32 s0, #1.0
vmov.f32 s2, #-1.0
vmov.f32 s3, #-2.0
vmov.f32 q2, #0.5
vmov.f32 q3, #-0.5
vmov.f32 q5, #1.0
vmov.f32 q6, #3.0
vmov.f32 q7, #0.25
vldr s5, [r2, #32]
vdiv.f32 s6, s20, s4
vadd.f32 s7, s6, s8
vdup.f32 q4, d2[0]
vmin.f32 q4, q4, q5
lsl r3, #3
add r3, r3, r1
cmp r3, r1
beq 4f
1:
vld1.f32 d16, [r1, :64]!
vmov.f32 d28, d29
vmov.f32 d29, d30
vmov.f32 d30, d31
vmov.f32 d31, d16
vcmpe.f32 s5, s20
vmrs APSR_nzcv, fpscr
bge 3f
2:
vdup.f32 q8, d2[1]
vadd.f32 q8, q8, q0
vadd.f32 q10, q8, q2
vsub.f32 q11, q8, q2
vmul.f32 q10, q10, q4
vmul.f32 q11, q11, q4
#if (CC_RESAMPLER_PRECISION > 0)
vmul.f32 q8, q10, q10
vmul.f32 q9, q11, q11
vsub.f32 q12, q6, q8
vsub.f32 q13, q6, q9
vmul.f32 q12, q12, q8
vmul.f32 q13, q13, q9
vmul.f32 q12, q12, q7
vmul.f32 q13, q13, q7
vsub.f32 q12, q5, q12
vsub.f32 q13, q5, q13
vmul.f32 q10, q10, q12
vmul.f32 q11, q11, q13
#endif
vmin.f32 q10, q10, q2
vmin.f32 q11, q11, q2
vmax.f32 q10, q10, q3
vmax.f32 q11, q11, q3
vsub.f32 q10, q10, q11
vmov.f32 q11, q10
vzip.f32 q10, q11
vmul.f32 q10, q10, q14
vmul.f32 q11, q11, q15
vadd.f32 q10, q10, q11
vadd.f32 d20, d20, d21
vst1.f32 d20, [r4, :64]!
vadd.f32 s5, s5, s6
vcmpe.f32 s5, s20
vmrs APSR_nzcv, fpscr
blt 2b
3:
# distance--
vsub.f32 s5, s5, s20
cmp r3, r1
bne 1b
4:
vst1.f32 {q14-q15}, [r2, :256]
vstr s5, [r2, #32]
sub r0, r4, r0
lsr r0, r0, #3
pop {r4}
vpop {q4,q5,q6,q7}
bx lr
#endif

Some files were not shown because too many files have changed in this diff Show More