Compare commits

..
14 Commits
Author SHA1 Message Date
twinaphex 28c7ae5007 Bump version code 2016-03-16 19:45:57 +01:00
twinaphex 0a613c04a6 Bump up to 1.3.2 2016-03-15 23:16:12 +01:00
Alcaro f12092a09f Fix missing linebreak. 2016-03-15 13:44:46 +01:00
twinaphex 21aa1cdbe6 (menu_setting.c) Update paths 2016-03-14 22:58:25 +01:00
twinaphex 5e18a5513c (menu_setting.c) Update menu paths 2016-03-14 22:47:59 +01:00
twinaphex 1188650a3f (menu_setting.c) Update paths 2016-03-14 22:44:43 +01:00
twinaphex f64a01c5d4 (menu_setting.c) Update more paths 2016-03-14 22:07:18 +01:00
twinaphex 42e803435f (menu_setting.c) Update paths 2016-03-14 21:51:02 +01:00
Twinaphex 5e1486d92a Remove some unused variables 2016-03-14 21:23:45 +01:00
twinaphex f03a0cedca (menu_setting.c) Updates 2016-03-14 16:49:01 +01:00
twinaphex 75a134a578 (menu_setting.c) Updates 2016-03-14 16:42:16 +01:00
twinaphex a9b9435e0b (menu_setting.c) Update 2016-03-14 16:37:33 +01:00
twinaphex b674457671 More menu settings refactoring 2016-03-14 16:27:52 +01:00
twinaphex 7752c73abc Start using temporary copies for menu_settings 2016-03-14 16:11:59 +01:00
3199 changed files with 151606 additions and 747194 deletions

No files matched your search

-20
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
File renamed without changes.
-35
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]
-25
View File
@@ -11,7 +11,6 @@ config.log
/retroarch
/retroarch.cfg
/retroarch.exe
/retroarch_debug.exe
/config.h
/config.mk
/tools/retroarch-joyconfig
@@ -63,17 +62,9 @@ menu/driverspzarch.c
/media/shaders_glsl/
/obj-w32/
# Wii U
*.depend
*.rpx
wiiu/wut/elf2rpl/elf2rpl
# Ctags
/tags
# CLion
/cmake-build-debug/
# Android
/pkg/android/phoenix/obj/
/pkg/android/phoenix/assets/
@@ -94,19 +85,3 @@ pkg/apple/iOS/modules/
obj-unix/
.vagrant/
.MAKEFILE_DEFINES
.CONFIG_DEFINES
/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/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
+3
View File
@@ -0,0 +1,3 @@
[submodule "deps/glslang/glslang"]
path = deps/glslang/glslang
url = git://github.com/KhronosGroup/glslang.git
-48
View File
@@ -1,48 +0,0 @@
# Use 'generic' to be able to override CC/CXX for clang
language: generic
matrix:
include:
- compiler: gcc
- compiler: clang
addons:
# Install a more recent clang than the default
apt:
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-precise-3.8
packages:
- clang-3.8
env: COMPILER_NAME=clang-3.8 CXX=clang++-3.8 CC=clang-3.8
- os: osx
osx_image: xcode7.3
script:
- xcodebuild -target RetroArch -configuration Release -project pkg/apple/RetroArch.xcodeproj
script:
- ./configure
- make
env:
global:
- secure: "qc91ReC3OlzSh2gFaSH6TYzC2qIQvgA2AZff6J13eaH8xijAhuMzttZ0rMQJ0DWCIhPeUb0kIzVyaGoe4MwPALzpw1C1AznIWiZJ53HN+hWCOcS/af7YVPk6HPySnwqrS+Wv3AIIvIKFV2mxv21F/JbT/N+pArlRrp904Xj+KPo="
addons:
apt:
packages:
- curl
- pkg-config
- libglu1-mesa-dev
- freeglut3-dev
- mesa-common-dev
- libsdl1.2-dev
- libsdl-image1.2-dev
- libsdl-mixer1.2-dev
- libsdl-ttf2.0-dev
coverity_scan:
project:
name: "RetroArch"
description: "RetroArch is the official reference frontend for the libretro API."
notification_email: [email protected]
build_command_prepend: "./configure; make clean"
build_command: "make"
branch_pattern: coverity_scan
-100
View File
@@ -1,100 +0,0 @@
# 1.6.2 (future)
- IOS: Fix GL regression - 32bit color format cores were no longer rendering
- CHEEVOS: Add support for N64 cheevos and other small fixes.
- CHEEVOS: Add 'Achievements -> Achievements Verbose Mode'. Ability to display cheevos related messages in OSD, useful for RetroAchievements users.
- AUDIO: Audio mixer's volume can now be independently increased/decreased, and muted.
- AUDIO: Mute now no longer disables/enables audio but instead properly mutes the audio volume. Mute is also independent from the audio mixer volume.
- INPUT: Add mouse index selection; ability now to select between different mice
- INPUT: Fix 'All Users Control Menu' setting
- LINUX: Add a tinyalsa audio driver. Doesn't require asoundlib, should be self-contained and lower-level.
- LOBBIES: Announce the RetroArch version too
- LOCALIZATION: Add Traditional Chinese translation
- LOCALIZATION: Update French translation
- LOCALIZATION: Update Italian translation
- LOCALIZATION: Update Japanese translation
- LOCALIZATION: Update Russian translation
- MENU: Add 'User Interface -> Views'. Ability to display/hide online updater and core updater options.
- NETPLAY: Disconnecting one client shouldn't cause everyone to disconnect anymore
- NETWORK: SSL/TLS support, disabled by default
- SCANNER: Fix PS1 game scanning
- SCANNER: Move content list builder into scanner task with progress, fixes menu freeze with large playlists
- SDL2: Fix 'SDL2 driver does not see the hat on wired Xbox 360 controller"
- SETTINGS: Fix regression 'Custom Viewport is no longer overridable per-core or per-game'
- VITA: Add cheevos support
- VITA: Add support for external USB if mounted
- WAYLAND: Fix menu mouse input
- WII: Add support for single-port 'PS1/PS2 to USB controller adapter'
# 1.6.0
- ANDROID: Allow remotes to retain OK/Cancel position when menu_swap_ok_cancel is enabled
- ANDROID: Improve autoconf fallback
- ANDROID: Improve shield portable/gamepad device grouping workaround
- ANDROID: Runtime permission checking
- AUDIO: Audio mixer support. Mix up to 8 streams with the game's audio.
- AUTOSAVE/SRAM - Fix bug #3829 / #4820 (https://github.com/libretro/RetroArch/issues/3829)
- ENDIANNESS: Fixed database scanning. Should fix scanning on PS3/WiiU/Wii, etc.
- LOBBIES: Fallback to filename based matching if no CRC matches are found (for people making playlists by hand)
- LOBBIES: GUI refinement, show stop hosting when a host has been started, show disconnect when playing as client
- LOBBIES: if the game is already loaded it will try to connect directly instead of re-loading content (non-fullpath cores only)
- LOBBIES: unify both netplay menus
- LOCALIZATION/GUI: Korean font should display properly now with XMB/MaterialUI's default font
- LOCALIZATION: Update German translation
- LOCALIZATION: Update Japanese translation
- LOCALIZATION: Update Russian translation
- LOCALIZATION: Update/finish French translation
- MENU: Improved rendering for XMB ribbon; using additive blending (Vulkan/GL)
- MISC: Various frontend optimizations.
- NET: Fix bug #4703 (https://github.com/libretro/RetroArch/issues/4703)
- OSX/MACOS: Fixes serious memory leak
- THUMBNAILS: Thumbnails show up now in Load Content -> Collection, Information -> Database
- VIDEO: Fix threaded video regression; tickering of menu entries would no longer work.
- VITA: Fix 30fps menu (poke into input now instead of reading the entire input buffer which apparently is slow)
- VITA: Fix frame throttle
- VITA: Fix slow I/O
- VULKAN: Fix some crashes on loading some thumbnails
- VULKAN: Unicode font rendering support. Should fix bad character encoding for French characters, etc.
- WII: Fix crashing issues which could occur with the dummy core
- WIIU: HID Controller support
- WIIU: Initial network/netplay support
- WIIU: XMB/MaterialUI menu driver support
- WINDOWS: Added RawInput input driver for low-latency, low-level input.
- WINDOWS: Added WASAPI audio driver for low-latency audio. Both shared and exclusive mode.
- WINDOWS: Core mouse input should be relative again in cores
# 1.5.0
- ANDROID: Autoconf fallback
- ANDROID: Mouse support / Emulated mouse support
- AUTOCONF: Fix partial matches for pad name
- CHEEVOS: Fix crashes in the cheevos description menu
- CHEEVOS: WIP leaderboards support
- COMMON: 9-slice texture drawing support
- COMMON: Threading fixes
- CORETEXT/APPLE: Ability to load menu display font drivers and loading of custom font.
- DOS: Add keyboard driver
- DOS: Improve color accuracy and scaling
- GUI: Add a symbol page in the OSK
- GUI: Allow changing icon theme on the fly
- GUI: Better dialogs for XMB
- GUI: Various settings are now only visible when advanced settings is enabled
- LOCALIZATION: Add/update Korean translation
- LOCALIZATION: Rewrite German translation
- LOCALIZATION: Update several English sublabels
- LOCALIZATION: Update several Japanese labels
- MOBILE: Long-tap a setting to reset to default
- MOBILE: Single-tap for menu entry selection
- NET: Allow manual netplay content loading
- NET: Announcing network games to the public lobby is optional now
- NET: Bake in miniupnpc
- NET: Fix netplay join for contentless cores
- NET: Fix netplay rooms being pushed on the wrong tab
- NET: Lan games show next to lobbies with (lan) and connect via the private IP address
- NET: Use new lobby system with MITM support
- NUKLEAR: Update to current version
- SCANNER: Always add 7z & zip to supported extensions
- VULKAN: Add snow/bokeh shader pipeline effects - at parity with GL now
- VULKAN: Find supported composite alpha in swapchain
- WIIU: Keyboard support
- WINDOWS: Fix loading of core/content via file menu
- WINDOWS: Logging to file no longer spawns an empty window
# 1.4.1
+19 -62
View File
@@ -1,6 +1,4 @@
HAVE_FILE_LOGGER=1
HAVE_CC_RESAMPLER=1
NEED_CXX_LINKER=0
MISSING_DECLS =0
ifneq ($(C90_BUILD),)
@@ -17,23 +15,13 @@ ifeq ($(GLOBAL_CONFIG_DIR),)
GLOBAL_CONFIG_DIR = /etc
endif
OBJ :=
OBJ :=
LIBS :=
DEFINES := -DHAVE_CONFIG_H -DRARCH_INTERNAL -DHAVE_OVERLAY
DEFINES += -DGLOBAL_CONFIG_DIR='"$(GLOBAL_CONFIG_DIR)"'
ifneq ($(findstring BSD,$(OS)),)
CFLAGS += -DBSD
LDFLAGS += -L/usr/local/lib
endif
ifneq ($(findstring DOS,$(OS)),)
CFLAGS += -march=i386
LDFLAGS += -lemu
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -static-libgcc -lwinmm
LDFLAGS += -static-libgcc
endif
include Makefile.common
@@ -42,16 +30,10 @@ ifeq ($(shell $(CC) -v 2>&1 | grep -c "clang"),1)
DEFINES += -Wno-invalid-source-encoding
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)
DEFINES += -Werror=missing-declarations
DEFINES += -Werror=missing-declarations
endif
ifeq ($(HAVE_DYLIB), 1)
@@ -72,11 +54,10 @@ ifeq ($(DEBUG), 1)
OPTIMIZE_FLAG = -O0 -g
else
OPTIMIZE_FLAG = -O3 -ffast-math
endif
ifneq ($(findstring Win32,$(OS)),)
LDFLAGS += -mwindows
endif
endif
CFLAGS += -Wall $(OPTIMIZE_FLAG) $(INCLUDE_DIRS) $(DEBUG_FLAG) -I.
@@ -86,13 +67,9 @@ OBJCFLAGS := $(CFLAGS) -D__STDC_CONSTANT_MACROS
ifeq ($(CXX_BUILD), 1)
LINK = $(CXX)
CFLAGS := $(CXXFLAGS) -xc++
CFLAGS += -DCXX_BUILD
CXXFLAGS += -DCXX_BUILD
CFLAGS := $(CXXFLAGS) -xc++
else
ifeq ($(NEED_CXX_LINKER),1)
LINK = $(CXX)
else ifeq ($(findstring Win32,$(OS)),)
ifeq ($(findstring Win32,$(OS)),)
LINK = $(CC)
else
# directx-related code is c++
@@ -126,7 +103,7 @@ RARCH_OBJ := $(addprefix $(OBJDIR)/,$(OBJ))
ifneq ($(SANITIZER),)
CFLAGS := -fsanitize=$(SANITIZER) $(CFLAGS)
CXXFLAGS := -fsanitize=$(SANITIZER) $(CXXFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDFLAGS)
LDFLAGS := -fsanitize=$(SANITIZER) $(LDLAGS)
endif
ifneq ($(findstring $(GPERFTOOLS),profiler),)
@@ -138,14 +115,10 @@ endif
all: $(TARGET) config.mk
ifeq ($(MAKECMDGOALS),clean)
config.mk:
else
-include $(RARCH_OBJ:.o=.d)
config.mk: configure qb/*
@echo "config.mk is outdated or non-existing. Run ./configure again."
@exit 1
endif
retroarch: $(RARCH_OBJ)
@$(if $(Q), $(shell echo echo LD $@),)
@@ -154,12 +127,12 @@ retroarch: $(RARCH_OBJ)
$(OBJDIR)/%.o: %.c config.h config.mk
@mkdir -p $(dir $@)
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CPPFLAGS) $(CFLAGS) $(DEFINES) $(MD) -c -o $@ $<
$(Q)$(CC) $(CFLAGS) $(DEFINES) -MMD -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 $@ $<
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -MMD -c -o $@ $<
$(OBJDIR)/%.o: %.m
@mkdir -p $(dir $@)
@@ -185,43 +158,27 @@ $(OBJDIR)/%.o: %.rc $(HEADERS)
install: $(TARGET)
rm -f $(OBJDIR)/git_version.o
mkdir -p $(DESTDIR)$(BIN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(PREFIX)/bin 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(GLOBAL_CONFIG_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(PREFIX)/share/applications 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(MAN_DIR)/man6 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(MAN_DIR) 2>/dev/null || /bin/true
mkdir -p $(DESTDIR)$(PREFIX)/share/pixmaps 2>/dev/null || /bin/true
install -m755 $(TARGET) $(DESTDIR)$(BIN_DIR)
install -m755 tools/cg2glsl.py $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
install -m755 $(TARGET) $(DESTDIR)$(PREFIX)/bin
install -m755 tools/cg2glsl.py $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl
install -m644 retroarch.cfg $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
install -m644 retroarch.desktop $(DESTDIR)$(PREFIX)/share/applications
install -m644 docs/retroarch.6 $(DESTDIR)$(MAN_DIR)/man6
install -m644 docs/retroarch-cg2glsl.6 $(DESTDIR)$(MAN_DIR)/man6
install -m644 docs/retroarch.1 $(DESTDIR)$(MAN_DIR)
install -m644 docs/retroarch-cg2glsl.1 $(DESTDIR)$(MAN_DIR)
install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps
@if test -d media/assets; then \
echo "Installing media assets..."; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb; \
mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \
cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \
cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \
echo "Removing unneeded source image files.."; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/flatui/src; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/monochrome/src; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive/src; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/neoactive/src; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive_marked/src; \
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/dot-art/src; \
echo "Asset copying done."; \
fi
uninstall:
rm -f $(DESTDIR)$(BIN_DIR)/retroarch
rm -f $(DESTDIR)$(BIN_DIR)/retroarch-cg2glsl
rm -f $(DESTDIR)$(PREFIX)/bin/retroarch
rm -f $(DESTDIR)$(PREFIX)/bin/retroarch-cg2glsl
rm -f $(DESTDIR)$(GLOBAL_CONFIG_DIR)/retroarch.cfg
rm -f $(DESTDIR)$(PREFIX)/share/applications/retroarch.desktop
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch.6
rm -f $(DESTDIR)$(MAN_DIR)/man6/retroarch-cg2glsl.6
rm -f $(DESTDIR)$(MAN_DIR)/retroarch.1
rm -f $(DESTDIR)$(MAN_DIR)/retroarch-cg2glsl.1
rm -f $(DESTDIR)$(PREFIX)/share/pixmaps/retroarch.svg
rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch
clean:
rm -rf $(OBJDIR)
+277 -770
View File
File diff suppressed because it is too large. Load diff
+226 -91
View File
@@ -21,90 +21,224 @@ APP_RSF = ctr/tools/template.rsf
APP_SYSTEM_MODE = 64MB
APP_SYSTEM_MODE_EXT = 124MB
APP_BIG_TEXT_SECTION = 0
APP_USE_SVCHAX = 0
include 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
OBJS :=
OBJS += gfx/drivers/ctr_sprite.o
OBJS += ctr/ctr_system.o
OBJS += ctr/ctr_memory.o
OBJS += ctr/ctr_linear.o
OBJS += ctr/ctr_svchax.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_RGUI -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB
OBJS += griffin/griffin.o
else
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_7ZIP = 1
HAVE_BUILTINZLIB = 1
HAVE_LIBRETRODB = 1
HAVE_ZARCH = 0
HAVE_MATERIALUI = 1
HAVE_XMB = 1
include Makefile.common
BLACKLIST :=
BLACKLIST += input/input_overlay.o
BLACKLIST += tasks/task_overlay.o
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
OBJ += gfx/drivers/ctr_gfx.o
OBJ += gfx/drivers_font/ctr_font.o
OBJ += menu/drivers_display/menu_display_ctr.o
OBJ += input/drivers/ctr_input.o
OBJ += input/drivers_joypad/ctr_joypad.o
OBJ += audio/drivers/ctr_csnd_audio.o
OBJ += audio/drivers/ctr_dsp_audio.o
OBJ += frontend/drivers/platform_ctr.o
OBJ += gfx/video_filters/2xsai.o
OBJ += gfx/video_filters/super2xsai.o
OBJ += gfx/video_filters/supereagle.o
OBJ += gfx/video_filters/2xbr.o
OBJ += gfx/video_filters/darken.o
OBJ += gfx/video_filters/epx.o
OBJ += gfx/video_filters/scale2x.o
OBJ += gfx/video_filters/blargg_ntsc_snes.o
OBJ += gfx/video_filters/lq2x.o
OBJ += gfx/video_filters/phosphor2x.o
OBJ += libretro-common/audio/dsp_filters/echo.o
OBJ += libretro-common/audio/dsp_filters/eq.o
OBJ += libretro-common/audio/dsp_filters/chorus.o
OBJ += libretro-common/audio/dsp_filters/iir.o
OBJ += libretro-common/audio/dsp_filters/panning.o
OBJ += libretro-common/audio/dsp_filters/phaser.o
OBJ += libretro-common/audio/dsp_filters/reverb.o
OBJ += libretro-common/audio/dsp_filters/wahwah.o
OBJS += libretro-common/file/file_extract.o
OBJS += verbosity.o
OBJS += performance.o
OBJS += libretro-common/compat/compat_getopt.o
OBJS += libretro-common/compat/compat_strcasestr.o
OBJS += libretro-common/compat/compat_strl.o
OBJS += libretro-common/compat/compat_fnmatch.o
OBJS += libretro-common/memmap/memalign.o
OBJS += libretro-common/file/config_file.o
OBJS += libretro-common/file/config_file_userdata.o
OBJS += core_options.o
OBJS += cheats.o
OBJS += libretro-common/hash/rhash.o
OBJS += gfx/video_context_driver.o
OBJS += gfx/drivers_context/gfx_null_ctx.o
OBJS += gfx/image/image.o
OBJS += libretro-common/formats/tga/rtga.o
OBJS += libretro-common/formats/png/rpng.o
OBJS += libretro-common/formats/png/rpng_encode.o
OBJS += libretro-common/formats/bmp/rbmp_encode.o
OBJS += libretro-common/gfx/math/matrix_4x4.o
OBJS += libretro-common/gfx/math/matrix_3x3.o
OBJS += gfx/drivers/ctr_gfx.o
OBJS += gfx/drivers/nullgfx.o
OBJS += gfx/font_driver.o
OBJS += gfx/drivers_font_renderer/bitmapfont.o
OBJS += input/input_autodetect.o
OBJS += input/input_joypad_driver.o
OBJS += input/input_hid_driver.o
OBJS += input/input_config.o
OBJS += input/input_keymaps.o
OBJS += input/input_remapping.o
OBJS += input/input_keyboard.o
OBJS += input/drivers/ctr_input.o
OBJS += input/drivers_joypad/ctr_joypad.o
OBJS += input/autoconf/builtin_ctr.o
OBJS += input/drivers/nullinput.o
OBJS += input/drivers_joypad/null_joypad.o
OBJS += input/drivers_joypad/hid_joypad.o
OBJS += input/drivers_hid/null_hid.o
OBJS += gfx/video_state_tracker.o
OBJS += libretro-common/queues/fifo_buffer.o
OBJS += audio/audio_resampler_driver.o
OBJS += audio/drivers_resampler/sinc.o
OBJS += audio/drivers_resampler/nearest.o
OBJS += audio/drivers_resampler/cc_resampler.o
OBJS += camera/drivers/nullcamera.o
OBJS += location/drivers/nulllocation.o
OBJS += audio/drivers/ctr_csnd_audio.o
OBJS += audio/drivers/ctr_dsp_audio.o
OBJS += audio/drivers/nullaudio.o
OBJS += gfx/video_driver.o
OBJS += gfx/video_common.o
OBJS += input/input_driver.o
OBJS += audio/audio_driver.o
OBJS += camera/camera_driver.o
OBJS += location/location_driver.o
OBJS += driver.o
OBJS += libretro-common/gfx/scaler/scaler_filter.o
OBJS += libretro-common/gfx/scaler/pixconv.o
OBJS += libretro-common/gfx/scaler/scaler.o
OBJS += libretro-common/gfx/scaler/scaler_int.o
OBJS += gfx/video_filters/2xsai.o
OBJS += gfx/video_filters/super2xsai.o
OBJS += gfx/video_filters/supereagle.o
OBJS += gfx/video_filters/2xbr.o
OBJS += gfx/video_filters/darken.o
OBJS += gfx/video_filters/epx.o
OBJS += gfx/video_filters/scale2x.o
OBJS += gfx/video_filters/blargg_ntsc_snes.o
OBJS += gfx/video_filters/lq2x.o
OBJS += gfx/video_filters/phosphor2x.o
OBJS += audio/audio_filters/echo.o
OBJS += audio/audio_filters/eq.o
OBJS += audio/audio_filters/chorus.o
OBJS += audio/audio_filters/iir.o
OBJS += audio/audio_filters/panning.o
OBJS += audio/audio_filters/phaser.o
OBJS += audio/audio_filters/reverb.o
OBJS += audio/audio_filters/wahwah.o
OBJS += libretro-common/dynamic/dylib.o
OBJS += dynamic.o
OBJS += gfx/video_filter.o
OBJS += audio/audio_dsp_filter.o
OBJS += cores/dynamic_dummy.o
OBJS += content.o
OBJS += libretro-common/file/file_path.o
OBJS += file_path_special.o
OBJS += libretro-common/file/dir_list.o
OBJS += libretro-common/file/retro_dirent.o
OBJS += libretro-common/file/retro_file.o
OBJS += libretro-common/file/retro_stat.o
OBJS += dir_list_special.o
OBJS += string_list_special.o
OBJS += libretro-common/string/string_list.o
OBJS += libretro-common/string/stdstring.o
OBJS += file_ops.o
OBJS += libretro-common/file/nbio/nbio_stdio.o
OBJS += libretro-common/file/file_list.o
OBJS += libretro-common/queues/message_queue.o
OBJS += patch.o
OBJS += configuration.o
OBJS += rewind.o
OBJS += frontend/frontend_driver.o
OBJS += frontend/drivers/platform_ctr.o
OBJS += frontend/drivers/platform_null.o
OBJS += core_info.o
OBJS += ui/ui_companion_driver.o
OBJS += ui/drivers/ui_null.o
OBJS += frontend/frontend.o
OBJS += libretro_version_1.o
OBJS += retroarch.o
OBJS += runloop.o
OBJS += tasks/tasks.o
OBJS += msg_hash.o
OBJS += intl/msg_hash_de.o
OBJS += intl/msg_hash_es.o
OBJS += intl/msg_hash_eo.o
OBJS += intl/msg_hash_fr.o
OBJS += intl/msg_hash_it.o
OBJS += intl/msg_hash_nl.o
OBJS += intl/msg_hash_pt.o
OBJS += intl/msg_hash_pl.o
OBJS += intl/msg_hash_us.o
OBJS += movie.o
OBJS += record/record_driver.o
OBJS += record/drivers/record_null.o
OBJS += tasks/task_decompress.o
OBJS += tasks/task_file_transfer.o
OBJS += screenshot.o
OBJS += playlist.o
OBJS += menu/menu_driver.o
OBJS += menu/menu_hash.o
OBJS += menu/menu_input.o
OBJS += menu/menu_entry.o
OBJS += menu/menu_entries.o
OBJS += menu/menu_setting.o
OBJS += menu/menu_cbs.o
OBJS += menu/cbs/menu_cbs_ok.o
OBJS += menu/cbs/menu_cbs_cancel.o
OBJS += menu/cbs/menu_cbs_select.o
OBJS += menu/cbs/menu_cbs_start.o
OBJS += menu/cbs/menu_cbs_info.o
OBJS += menu/cbs/menu_cbs_refresh.o
OBJS += menu/cbs/menu_cbs_left.o
OBJS += menu/cbs/menu_cbs_right.o
OBJS += menu/cbs/menu_cbs_title.o
OBJS += menu/cbs/menu_cbs_deferred_push.o
OBJS += menu/cbs/menu_cbs_scan.o
OBJS += menu/cbs/menu_cbs_get_value.o
OBJS += menu/cbs/menu_cbs_up.o
OBJS += menu/cbs/menu_cbs_down.o
OBJS += menu/cbs/menu_cbs_contentlist_switch.o
OBJS += menu/menu_shader.o
OBJS += menu/menu_navigation.o
OBJS += menu/menu_display.o
OBJS += menu/menu_displaylist.o
OBJS += menu/menu_animation.o
OBJS += menu/intl/menu_hash_de.o
OBJS += menu/intl/menu_hash_es.o
OBJS += menu/intl/menu_hash_eo.o
OBJS += menu/intl/menu_hash_fr.o
OBJS += menu/intl/menu_hash_it.o
OBJS += menu/intl/menu_hash_nl.o
OBJS += menu/intl/menu_hash_pl.o
OBJS += menu/intl/menu_hash_pt.o
OBJS += menu/intl/menu_hash_us.o
OBJS += menu/drivers/null.o
OBJS += menu/drivers/menu_generic.o
OBJS += menu/drivers_display/menu_display_null.o
OBJS += menu/drivers/rgui.o
OBJS += command_event.o
OBJS += deps/zlib/adler32.o
OBJS += deps/zlib/compress.o
OBJS += deps/zlib/crc32.o
OBJS += deps/zlib/deflate.o
OBJS += deps/zlib/gzclose.o
OBJS += deps/zlib/gzlib.o
OBJS += deps/zlib/gzread.o
OBJS += deps/zlib/gzwrite.o
OBJS += deps/zlib/inffast.o
OBJS += deps/zlib/inflate.o
OBJS += deps/zlib/inftrees.o
OBJS += deps/zlib/trees.o
OBJS += deps/zlib/uncompr.o
OBJS += deps/zlib/zutil.o
OBJS += deps/zlib/ioapi.o
OBJS += deps/zlib/unzip.o
OBJS += audio/audio_utils.o
endif
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitpro")
ifeq ($(strip $(DEVKITARM)),)
$(error "Please set DEVKITARM in your environment. export DEVKITARM=<path to>devkitARM")
endif
ifeq ($(strip $(CTRULIB)),)
CTRULIB = $(DEVKITPRO)/libctru
$(error "Please set CTRULIB in your environment. export CTRULIB=<path to>ctrulib")
endif
ifeq ($(strip $(AEMSTRO)),)
$(error "Please set AEMSTRO in your environment. export AEMSTRO=<path to>aemstro")
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)
@@ -142,15 +276,16 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_END := -Wl,--no-whole-archive
endif
CFLAGS += -I. -Ideps/libz -Ideps/7zip -Ilibretro-common/include
CFLAGS += -I. -Ideps/zlib -Ideps/7zip -Ilibretro-common/include
CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE -DSINC_LOWEST_QUALITY
CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES)
CFLAGS += -DHAVE_GRIFFIN=1 -DHAVE_FILTERS_BUILTIN -DHAVE_MENU -DHAVE_RGUI
CFLAGS += -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_BUILTIN_AUTOCONFIG
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)
LDFLAGS = -specs=ctr/3dsx_custom.specs -g $(ARCH) -Wl,-Map,$(notdir $*.map)
CFLAGS += -std=gnu99 -ffast-math
@@ -174,11 +309,16 @@ endif
all: $(TARGET)
$(TARGET): $(TARGET_3DSX) $(TARGET_3DS) $(TARGET_CIA) $(TARGET).core
$(TARGET): $(TARGET_3DSX) $(TARGET_3DS) $(TARGET_CIA)
$(TARGET).3dsx: $(TARGET).elf
$(TARGET).elf: $(OBJ) libretro_ctr.a
$(TARGET).elf: $(OBJS) libretro_ctr.a
PREFIX := $(DEVKITPRO)/devkitARM/bin/arm-none-eabi-
ctr_sprite_shader_shbin.h: gfx/drivers/ctr_sprite.o
gfx/drivers/ctr_gfx.c: ctr_sprite_shader_shbin.h
griffin/griffin.o: gfx/drivers/ctr_gfx.c
PREFIX := $(DEVKITARM)/bin/arm-none-eabi-
CC := $(PREFIX)gcc
CXX := $(PREFIX)g++
@@ -200,15 +340,14 @@ else
BANNERTOOL = ctr/tools/bannertool.exe
endif
%.o: %.vsh %.gsh
$(DEVKITPRO)/devkitARM/bin/picasso $^ -o $*.shbin
$(DEVKITPRO)/devkitARM/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.shader
python $(AEMSTRO)/aemstro_as.py $< $(notdir $<).shbin
$(DEVKITARM)/bin/bin2s $(notdir $<).shbin | $(PREFIX)as -o $@
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"_end[];" > `(echo $(notdir $<).shbin | tr . _)`.h
echo "extern const u8" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`"[];" >> `(echo $(notdir $<).shbin | tr . _)`.h
echo "extern const u32" `(echo $(notdir $<).shbin | sed -e 's/^\([0-9]\)/_\1/' | tr . _)`_size";" >> `(echo $(notdir $<).shbin | tr . _)`.h
rm $(notdir $<).shbin
%.o: %.vsh
$(DEVKITPRO)/devkitARM/bin/picasso $^ -o $*.shbin
$(DEVKITPRO)/devkitARM/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.cpp
$(CXX) -c -o $@ $< $(CXXFLAGS) $(INCDIRS)
@@ -239,7 +378,7 @@ endif
-3dsxtool $< $@ $(_3DSXFLAGS)
$(TARGET).elf: ctr/3dsx_custom_crt0.o
$(LD) $(LDFLAGS) $(OBJ) $(LIBDIRS) $(LIBS) -o $@
$(LD) $(LDFLAGS) $(OBJS) $(LIBDIRS) $(LIBS) -o $@
$(NM) -CSn $@ > $(notdir $*.lst)
$(TARGET).bnr: $(APP_BANNER) $(APP_AUDIO)
@@ -254,23 +393,19 @@ $(TARGET).3ds: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(TARGET).cia: $(TARGET).elf $(TARGET).bnr $(TARGET).icn $(APP_RSF)
$(MAKEROM) -f cia -o $@ $(MAKEROM_ARGS_COMMON) -DAPP_ENCRYPTED=false
$(TARGET).core: $(TARGET).elf
echo $(APP_UNIQUE_ID) > $(TARGET).core
clean:
rm -f $(OBJ)
rm -f $(OBJS)
rm -f $(TARGET).3dsx
rm -f $(TARGET).elf
rm -f $(TARGET).3ds
rm -f $(TARGET).cia
rm -f $(TARGET).core
rm -f $(TARGET).smdh
rm -f $(TARGET).bnr
rm -f $(TARGET).icn
rm -f *_shader_shbin.h
rm -f ctr/ctr_config_*.o
rm -f ctr/3dsx_custom_crt0.o
.PHONY: clean
-202
View File
@@ -1,202 +0,0 @@
TARGET := retroarch_3ds_salamander
LIBRETRO =
DEBUG = 0
BUILD_3DSX = 0
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 = ctr/assets/default.png
APP_BANNER = ctr/assets/libretro_banner.png
APP_AUDIO = ctr/assets/silent.wav
APP_RSF = 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 \
frontend/drivers/platform_null.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/file/file_path.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/hash/rhash.o \
file_path_str.o \
verbosity.o
ifeq ($(strip $(DEVKITPRO)),)
$(error "Please set DEVKITPRO in your environment. export DEVKITPRO=<path to>devkitpro")
endif
ifeq ($(strip $(CTRULIB)),)
CTRULIB = $(DEVKITPRO)/ctrulib
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/libz -Ideps/7zip -Ilibretro-common/include
#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 := $(DEVKITPRO)/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)
ifneq ($(findstring Linux,$(shell uname -a)),)
MAKEROM = ctr/tools/makerom-linux
BANNERTOOL = ctr/tools/bannertool-linux
else ifneq ($(findstring Darwin,$(shell uname -a)),)
MAKEROM = ctr/tools/makerom-mac
BANNERTOOL = ctr/tools/bannertool-mac
else
MAKEROM = ctr/tools/makerom.exe
BANNERTOOL = ctr/tools/bannertool.exe
endif
%.o: %.vsh %.gsh
$(DEVKITPRO)/devkitARM/bin/picasso $^ -o $*.shbin
$(DEVKITPRO)/devkitARM/bin/bin2s $*.shbin | $(PREFIX)as -o $@
rm $*.shbin
%.o: %.vsh
$(DEVKITPRO)/devkitARM/bin/picasso $^ -o $*.shbin
$(DEVKITPRO)/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)
smdhtool --create "$(APP_TITLE)" "$(APP_DESCRIPTION)" "$(APP_AUTHOR)" $(APP_ICON) $@
$(TARGET).3dsx: $(TARGET).elf
ifeq ($(APP_BIG_TEXT_SECTION), 1)
cp ctr/big_text_section.xml $(TARGET).xml
else
rm -f $(TARGET).xml
endif
-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
+21 -41
View File
@@ -1,28 +1,21 @@
TARGET := retroarch.js
TARGET = retroarch.js
EOPT = USE_ZLIB=1 USE_SDL=2 # Emscripten specific options
EOPTS = $(addprefix -s $(EMPTY), $(EOPT)) # Add '-s ' to each option
PTHREAD = 0
OS = Emscripten
OBJ :=
DEFINES := -DRARCH_INTERNAL -DHAVE_OVERLAY -DHAVE_MAIN -s USE_PTHREADS=$(PTHREAD)
DEFINES := -DRARCH_INTERNAL -DHAVE_OVERLAY -DHAVE_MAIN
DEFINES += -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_EGL -DHAVE_OVERLAY -DHAVE_GLSL -DHAVE_FILTERS_BUILTIN
HAVE_CC_RESAMPLER = 1
HAVE_EGL = 1
HAVE_OPENGLES = 1
HAVE_RJPEG = 0
HAVE_RPNG = 1
HAVE_OPENGL = 1
HAVE_GLES = 1
HAVE_EMSCRIPTEN = 1
HAVE_RGUI = 1
HAVE_SDL = 0
HAVE_SDL2 = 1
HAVE_ZLIB = 1
HAVE_FBO = 1
WANT_ZLIB = 1
MEMORY = 536870912
MEMORY = 268435456
LTO = 0
# XXX: setting this to 1/2 currently crashes Firefox nightly
PRECISE_F32 = 2
@@ -30,25 +23,12 @@ ifneq ($(NATIVE_ZLIB),)
WANT_ZLIB = 0
endif
ifeq ($(HAVE_SDL2), 1)
DEFINES += -DHAVE_SDL2
endif
#if you compile with SDL2 flag add this Emscripten flag "-s USE_SDL=2" to LDFLAGS:
LIBS := -s USE_SDL=2 -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s USE_ZLIB=1 -s TOTAL_MEMORY=$(MEMORY) \
LIBS :=
LDFLAGS := -L. --no-heap-copy -s USE_ZLIB=1 -s TOTAL_MEMORY=$(MEMORY) -s OUTLINING_LIMIT=50000 \
-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_rwebinput.js \
--js-library emscripten/library_rwebcam.js
ifneq ($(PTHREAD), 0)
LDFLAGS += -s USE_PTHREADS=$(PTHREAD) -s PTHREAD_POOL_SIZE=2
endif
ifeq ($(ASYNC), 1)
LDFLAGS += -s ASYNCIFY=$(ASYNC)
endif
include Makefile.common
@@ -63,16 +43,16 @@ OBJ += gfx/video_filters/blargg_ntsc_snes.o
OBJ += gfx/video_filters/lq2x.o
OBJ += gfx/video_filters/phosphor2x.o
OBJ += libretro-common/audio/dsp_filters/echo.o
OBJ += libretro-common/audio/dsp_filters/eq.o
OBJ += libretro-common/audio/dsp_filters/chorus.o
OBJ += libretro-common/audio/dsp_filters/iir.o
OBJ += libretro-common/audio/dsp_filters/panning.o
OBJ += libretro-common/audio/dsp_filters/phaser.o
OBJ += libretro-common/audio/dsp_filters/reverb.o
OBJ += libretro-common/audio/dsp_filters/wahwah.o
OBJ += audio/audio_filters/echo.o
OBJ += audio/audio_filters/eq.o
OBJ += audio/audio_filters/chorus.o
OBJ += audio/audio_filters/iir.o
OBJ += audio/audio_filters/panning.o
OBJ += audio/audio_filters/phaser.o
OBJ += audio/audio_filters/reverb.o
OBJ += audio/audio_filters/wahwah.o
CFLAGS += -Ideps/libz/
CFLAGS += -Ideps/zlib/
libretro = libretro_emscripten.bc
ifneq ($(V), 1)
@@ -92,7 +72,7 @@ else
CFLAGS += -O2
endif
CFLAGS += -DHAVE_RPNG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \
CFLAGS += -DWANT_RPNG -Wall -Wno-unused-result -Wno-unused-variable -I. -Ilibretro-common/include -std=gnu99 -s USE_ZLIB=1 \
-s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_take_screenshot']"
all: $(TARGET)
@@ -103,15 +83,15 @@ $(TARGET): $(OBJ)
%.o: %.c
@$(if $(Q), $(shell echo echo CC $<),)
$(Q)$(CC) $(CFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
$(Q)$(CC) $(CFLAGS) $(DEFINES) -c -o $@ $<
%.o: %.cpp
@$(if $(Q), $(shell echo echo CXX $<),)
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) $(EOPTS) -c -o $@ $<
$(Q)$(CXX) $(CXXFLAGS) $(DEFINES) -c -o $@ $<
clean:
rm -f *.o
rm -f deps/libz/*.o
rm -f deps/zlib/*.o
rm -f frontend/*.o
rm -f menu/*.o
rm -f menu/disp/*.o
+34 -98
View File
@@ -1,15 +1,12 @@
ROOT_DIR := .
DEPS_DIR := $(ROOT_DIR)/deps
DEBUG = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
HAVE_CC_RESAMPLER = 1
WHOLE_ARCHIVE_LINK = 0
BIG_STACK = 1
DEBUG = 0
HAVE_LOGGER = 0
HAVE_FILE_LOGGER = 0
WHOLE_ARCHIVE_LINK = 0
BIG_STACK = 1
PC_DEVELOPMENT_IP_ADDRESS = 255.255.255.255
PC_DEVELOPMENT_UDP_PORT = 3490
RARCH_CONSOLE = 0
USBGECKO = 0
RARCH_CONSOLE = 0
USBGECKO = 0
ifneq ($(EMSCRIPTEN),)
platform = emscripten
@@ -89,7 +86,7 @@ else ifeq ($(libogc_platform), 1)
EXT_TARGET := $(TARGET_NAME)_$(platform).dol
EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf
INCLUDE += -I. -I$(DEVKITPRO)/libogc/include -Ideps/libz
INCLUDE += -I. -I$(DEVKITPRO)/libogc/include -Ideps/zlib
ifeq ($(platform), ngc)
LIBDIRS += -L$(DEVKITPRO)/libogc/lib/cube
@@ -125,22 +122,18 @@ ifeq ($(HAVE_LOGGER), 1)
endif
endif
CFLAGS += -DGEKKO -U__INT32_TYPE__ -U __UINT32_TYPE__ -D__INT32_TYPE__=int
CFLAGS += -DGEKKO
HAVE_FILTERS_BUILTIN := 1
HAVE_THREADS := 1
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_OVERLAY := 1
HAVE_BUILTIN_AUTOCONFIG := 1
HAVE_ZLIB := 1
WANT_ZLIB := 1
HAVE_7ZIP := 1
RARCH_CONSOLE = 1
ifeq ($(platform), wii)
HAVE_LANGEXTRA := 1
HAVE_WIIUSB_HID := 1
HAVE_RARCH_EXEC := 1
HAVE_RSOUND := 1
@@ -192,11 +185,7 @@ else ifeq ($(platform), psp1)
BUILD_PRX = 1
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_KERNEL_PRX := 1
HAVE_LANGEXTRA := 1
RARCH_CONSOLE = 1
ifeq ($(BUILD_PRX), 1)
@@ -211,51 +200,26 @@ else ifeq ($(platform), vita)
EXT_TARGET := $(TARGET_NAME)_$(platform).velf
EXT_INTER_TARGET := $(TARGET_NAME)_$(platform).elf
MACHDEP := -DVITA
WANT_ZLIB := 1
INCLUDE += -Ideps/libvita2d/include
INCLUDE += -Ideps/libz
PLATCFLAGS := -mfloat-abi=hard -fsingle-precision-constant \
-mword-relocations -fno-unwind-tables -fno-asynchronous-unwind-tables -ftree-vectorize -fno-optimize-sibling-calls
LIBS += -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub\
-lSceSysmodule_stub -lSceCtrl_stub -lSceTouch_stub -lSceAudio_stub -lSceFiber_stub\
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub \
-lSceMotion_stub -lSceAppMgr_stub -lpng -lm -lc
PLATCFLAGS := -O3 -mfloat-abi=hard -ffast-math -fsingle-precision-constant
LIBS += -lSceKernel_stub -lSceDisplay_stub -lSceGxm_stub -lSceNet_stub -lSceNetCtl_stub\
-lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub -lUVLoader_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lfreetype -lz -lm -lc -lpng
PLATOBJS += $(DEPS_DIR)/libvita2d/shader/clear_v_gxp.o \
$(DEPS_DIR)/libvita2d/shader/clear_f_gxp.o \
$(DEPS_DIR)/libvita2d/shader/color_v_gxp.o \
$(DEPS_DIR)/libvita2d/shader/color_f_gxp.o \
$(DEPS_DIR)/libvita2d/shader/texture_v_gxp.o \
$(DEPS_DIR)/libvita2d/shader/texture_f_gxp.o \
$(DEPS_DIR)/libvita2d/shader/texture_tint_f_gxp.o
PLATOBJS += \
libretro-common/audio/conversion/s16_to_float_neon.o \
libretro-common/audio/conversion/float_to_s16_neon.o \
memory/neon/memcpy-neon.o \
libretro-common/audio/resampler/drivers/sinc_resampler_neon.o \
audio/drivers_resampler/cc_resampler_neon.o
PLATOBJS += audio/audio_utils_neon.o audio/drivers_resampler/sinc_resampler_neon.o \
audio/drivers_resampler/cc_resampler_neon.o
LIBDIRS += -L.
LDFLAGS += -Wl,-q
HAVE_FILTERS_BUILTIN := 1
HAVE_LANGEXTRA := 1
HAVE_BUILTIN_AUTOCONFIG := 1
HAVE_RPNG := 1
HAVE_RJPEG := 1
HAVE_RBMP := 1
HAVE_RTGA := 1
HAVE_ZLIB := 1
HAVE_7ZIP := 1
HAVE_VITA2D := 1
HAVE_NETWORKING := 1
HAVE_NETPLAY := 1
HAVE_OVERLAY := 1
HAVE_MATERIALUI := 1
HAVE_XMB := 1
HAVE_STB_FONT :=1
RARCH_CONSOLE = 1
HAVE_THREADS := 1
HAVE_LIBRETRODB := 1
endif
@@ -298,8 +262,8 @@ ifeq ($(BIG_STACK),1)
CFLAGS += -DBIG_STACK
endif
ifeq ($(HAVE_RJPEG), 1)
CFLAGS += -DHAVE_RJPEG
ifeq ($(HAVE_RPNG), 1)
CFLAGS += -DWANT_RPNG
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
@@ -311,29 +275,13 @@ CFLAGS += -DHAVE_RARCH_EXEC
endif
ifeq ($(HAVE_ZLIB), 1)
CFLAGS += -DHAVE_ZLIB
endif
ifeq ($(WANT_ZLIB), 1)
CFLAGS += -DWANT_ZLIB
CFLAGS += -DHAVE_ZLIB -DWANT_ZLIB
endif
ifeq ($(HAVE_RPNG), 1)
CFLAGS += -DHAVE_RPNG
endif
ifeq ($(HAVE_RBMP), 1)
CFLAGS += -DHAVE_RBMP
endif
ifeq ($(HAVE_RTGA), 1)
CFLAGS += -DHAVE_RTGA
endif
ifeq ($(HAVE_IMAGEVIEWER), 1)
CFLAGS += -DHAVE_IMAGEVIEWER
endif
ifeq ($(HAVE_7ZIP), 1)
CFLAGS += -DHAVE_7ZIP
endif
@@ -342,10 +290,18 @@ ifeq ($(HAVE_OVERLAY), 1)
CFLAGS += -DHAVE_OVERLAY
endif
ifeq ($(HAVE_BUILTIN_AUTOCONFIG), 1)
CFLAGS += -DHAVE_BUILTIN_AUTOCONFIG
endif
ifeq ($(HAVE_NETWORKING), 1)
CFLAGS += -DHAVE_NETWORKING
endif
ifeq ($(HAVE_NETPLAY), 1)
CFLAGS += -DHAVE_NETPLAY
endif
ifeq ($(RARCH_CONSOLE), 1)
CFLAGS += -DRARCH_CONSOLE
endif
@@ -356,22 +312,6 @@ endif
CFLAGS += -std=gnu99 -DSINC_LOWER_QUALITY -DHAVE_RGUI -DHAVE_MENU -DHAVE_GRIFFIN=1 -Wno-char-subscripts -DRARCH_INTERNAL
ifeq ($(HAVE_MATERIALUI), 1)
CFLAGS += -DHAVE_MATERIALUI
endif
ifeq ($(HAVE_XMB), 1)
CFLAGS += -DHAVE_XMB
endif
ifeq ($(HAVE_STB_FONT), 1)
CFLAGS += -DHAVE_STB_FONT
endif
ifeq ($(HAVE_LANGEXTRA), 1)
CFLAGS += -DHAVE_LANGEXTRA
endif
ifeq ($(HAVE_FILTERS_BUILTIN), 1)
CFLAGS += -DHAVE_FILTERS_BUILTIN
endif
@@ -381,9 +321,10 @@ CFLAGS += -DHAVE_THREADS
ifeq ($(platform), psp1)
LIBS += -lpthread-psp
endif
ifeq ($(platform), vita)
LIBS += -lpthread
endif
ifeq ($(HAVE_VITA2D), 1)
LIBS := -lvita2d $(LIBS)
endif
ifeq ($(HAVE_RSOUND), 1)
@@ -398,8 +339,6 @@ ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g -DDEBUG
else ifeq ($(platform), psp1)
CFLAGS += -O2
else ifeq ($(platform), vita)
CFLAGS += -O3
else
CFLAGS += -O3
endif
@@ -410,11 +349,8 @@ all: $(EXT_TARGET)
$(ELF2DOL) $< $@
%.velf: %.elf
ifneq ($(DEBUG), 1)
arm-vita-eabi-strip -g $<
endif
vita-elf-create $< $@
vita-make-fself -c -s $@ eboot.bin
vita-elf-create $< $@ $(VITASDK)/bin/db.json $(VITASDK)/bin/extra.json
%.elf32: %.elf
ifeq ($(platform), xenon360)
@@ -427,7 +363,7 @@ ifeq ($(platform),psp1)
endif
$(EXT_INTER_TARGET): $(OBJ)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(PLATEXTRA) $(LIBS)
$(CXX) -o $@ $(LDFLAGS) $(LIBDIRS) $(OBJ) $(LIBS)
%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
+2 -2
View File
@@ -10,12 +10,12 @@ 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
OBJ = griffin/griffin.o audio/resamplers/sinc_resampler_neon.o audio/audio_utils_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 += -D__ARM_ARCH_6__ -DSINC_LOWER_QUALITY -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DHAVE_RPNG -DHAVE_RJPEG -DWANT_ZLIB -DHAVE_OVERLAY -DHAVE_ALSA -DHAVE_ZLIB -D__linux__
DEFINES += -D__ARM_ARCH_6__ -DSINC_LOWER_QUALITY -DHAVE_OPENGL -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DHAVE_GLSL -DHAVE_DYNAMIC -DWANT_RPNG -DWANT_ZLIB -DHAVE_OVERLAY -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
+8 -5
View File
@@ -15,6 +15,7 @@ DEBUG = 0
HAVE_GCMGL = 0
HAVE_LOGGER = 0
HAVE_FREETYPE = 0
HAVE_RLAUNCH = 0
WHOLE_ARCHIVE_LINK = 0
CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001
@@ -33,7 +34,7 @@ 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/libz -Ilibretro-common/include
INCDIRS = -I. -Idefines -Ideps/zlib -Ilibretro-common/include
# system platform
system_platform = unix
@@ -63,7 +64,11 @@ endif
PPU_SRCS = griffin/griffin.c
DEFINES += -DHAVE_MENU -DHAVE_RGUI -DHAVE_XMB -DHAVE_LIBRETRODB -DHAVE_MATERIALUI -DHAVE_SHADERPIPELINE -DRARCH_INTERNAL -DMSB_FIRST -DHAVE_OVERLAY -DHAVE_CC_RESAMPLER -DHAVE_STB_VORBIS
ifeq ($(HAVE_RLAUNCH), 1)
DEFINES += -DHAVE_RLAUNCH
endif
DEFINES += -DHAVE_MENU -DHAVE_RGUI -DRARCH_INTERNAL -DMSB_FIRST -DHAVE_OVERLAY
ifeq ($(HAVE_GCMGL), 1)
DEFINES += -DHAVE_GCMGL
@@ -101,9 +106,7 @@ PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -l
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_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DHAVE_7Z -DWANT_ZLIB -DSINC_LOWER_QUALITY -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
#DEFINES += -DHAVE_IMAGEVIEWER
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_7Z -DWANT_ZLIB -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=1 -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_BUILTIN_AUTOCONFIG
ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g
+6 -1
View File
@@ -13,6 +13,7 @@ DEBUG = 0
HAVE_GCMGL = 1
HAVE_LOGGER = 0
HAVE_FREETYPE = 0
HAVE_RLAUNCH = 0
WHOLE_ARCHIVE_LINK = 0
CONTENT_ID_FULL = UP0001-SSNE10000_00-0000000000000001
@@ -61,6 +62,10 @@ endif
PPU_SRCS = griffin/griffin.c
ifeq ($(HAVE_RLAUNCH), 1)
DEFINES += -DHAVE_RLAUNCH
endif
DEFINES += -DHAVE_RGUI -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_MENU -DRARCH_INTERNAL
ifeq ($(HAVE_GCMGL), 1)
@@ -99,7 +104,7 @@ PPU_LDLIBS = $(FONT_LIBS) $(GL_LIBS) $(WHOLE_START) -lretro_ps3 $(WHOLE_END) -l
PPU_RANLIB = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-ranlib.exe
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DSINC_LOWER_QUALITY -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
DEFINES += -DHAVE_THREADS -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_RSOUND -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DSINC_LOWER_QUALITY -D__CELLOS_LV2__ -DHAVE_NETPLAY=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)
ifeq ($(DEBUG), 1)
PPU_OPTIMIZE_LV := -O0 -g
+6 -9
View File
@@ -18,29 +18,26 @@ endif
STRIP = $(CELL_SDK)/host-win32/ppu/bin/ppu-lv2-strip.exe
PPU_CFLAGS += -I. -Ilibretro-common/include -Ideps/libz -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
PPU_CFLAGS += -I. -Ilibretro-common/include -Ideps/zlib -D__CELLOS_LV2__ -DIS_SALAMANDER -DRARCH_CONSOLE -DHAVE_SYSUTILS -DHAVE_SYSMODULES -DHAVE_RARCH_EXEC
PPU_SRCS = frontend/frontend_salamander.c \
frontend/frontend_driver.c \
frontend/drivers/platform_ps3.c \
frontend/drivers/platform_null.c \
libretro-common/file/file_path.c \
libretro-common/lists/dir_list.c \
libretro-common/lists/string_list.c \
libretro-common/file/dir_list.c \
libretro-common/file/retro_dirent.c \
libretro-common/file/retro_stat.c \
libretro-common/hash/rhash.c \
libretro-common/string/stdstring.c \
libretro-common/string/string_list.c \
libretro-common/compat/compat_strl.c \
libretro-common/compat/compat_strcasestr.c \
libretro-common/streams/file_stream.c \
libretro-common/file/retro_file.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
PPU_SRCS += netlogger.c
endif
PPU_TARGET = retroarch-salamander_ps3.elf
+3 -2
View File
@@ -17,7 +17,7 @@ ELF_TARGET := retroarch_psl1ght.elf
EBOOT_PATH = pkg/ps3/USRDIR/EBOOT.BIN
CORE_PATH = pkg/ps3/USRDIR/cores/CORE.SELF
INCLUDE := -I. -I$(PS3DEV)/ppu/include -Ideps/libz -Ips3/gcmgl/include/export -Ips3/include
INCLUDE := -I. -I$(PS3DEV)/ppu/include -Ideps/zlib -Ips3/gcmgl/include/export -Ips3/include
LIBDIRS := -L$(PS3DEV)/ppu/lib -L$(PS3DEV)/portlibs/ppu/lib -L.
MACHDEP := -D__CELLOS_LV2__ -D__PSL1GHT__
@@ -83,13 +83,14 @@ OBJ = griffin/griffin.o
ifeq ($(HAVE_LOGGER), 1)
CFLAGS += -DHAVE_LOGGER
CFLAGS += -Ilogger/netlogger
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
CFLAGS += -DHAVE_FILE_LOGGER
endif
SHARED_FLAGS := -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_GCMGL -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -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
SHARED_FLAGS := -DRARCH_CONSOLE -DHAVE_OPENGL -DHAVE_OVERLAY -DHAVE_HEADSET -DHAVE_OPENGLES -DHAVE_OPENGLES1 -DHAVE_PSGL -DHAVE_CG -DHAVE_CG_RUNTIME_COMPILER -DHAVE_GCMGL -DHAVE_FBO -DHAVE_SYSMODULES -DHAVE_SYSUTILS -DHAVE_RARCH_EXEC -DHAVE_MOUSE -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_GRIFFIN=1 -DHAVE_NETPLAY=1 -DHAVE_SOCKET_LEGACY=1 -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -Wno-char-subscripts
CFLAGS += -std=gnu99 $(SHARED_FLAGS)
CXXFLAGS += $(SHARED_FLAGS)
+2 -2
View File
@@ -19,11 +19,11 @@ ifeq ($(WHOLE_ARCHIVE_LINK), 1)
WHOLE_END := -Wl,--no-whole-archive
endif
INCDIR = deps/libz deps/7zip libretro-common/include
INCDIR = deps/zlib deps/7zip libretro-common/include
CFLAGS = $(OPTIMIZE_LV) -G0 -std=gnu99 -ffast-math
ASFLAGS = $(CFLAGS)
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX -DHAVE_LANGEXTRA -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DWANT_ZLIB -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DSINC_LOWEST_QUALITY -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP -DHAVE_CC_RESAMPLER
RARCH_DEFINES = -DPSP -D_MIPS_ARCH_ALLEGREX -DHAVE_ZLIB -DHAVE_RPNG -DWANT_ZLIB -DHAVE_GRIFFIN=1 -DRARCH_INTERNAL -DRARCH_CONSOLE -DHAVE_MENU -DHAVE_RGUI -DWANT_RPNG -DSINC_LOWEST_QUALITY -DHAVE_BUILTIN_AUTOCONFIG -DHAVE_FILTERS_BUILTIN -DHAVE_7ZIP
LIBDIR =
LDFLAGS =
+4 -5
View File
@@ -37,15 +37,14 @@ OBJS = frontend/frontend_salamander.o \
frontend/drivers/platform_null.o \
libretro-common/file/file_path.o \
libretro-common/string/stdstring.o \
libretro-common/lists/string_list.o \
libretro-common/lists/dir_list.o \
libretro-common/string/string_list.o \
libretro-common/file/dir_list.o \
libretro-common/file/retro_dirent.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/file/retro_file.o \
libretro-common/file/retro_stat.o \
libretro-common/hash/rhash.o \
file_path_str.o \
verbosity.o \
bootstrap/psp1/kernel_functions.o
-199
View File
@@ -1,199 +0,0 @@
TARGET := retroarch_vita
DEBUG ?= 0
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 :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1
DEFINES += -DHAVE_NEON -DHAVE_MENU -DHAVE_XMB -DHAVE_MATERIALUI -DHAVE_LIBRETRODB
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_CC_RESAMPLER
ifeq ($(DEBUG), 1)
DEFINES += -DHAVE_NETLOGGER
endif
else
HAVE_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_NETWORKING := 1
HAVE_SOCKET_LEGACY := 1
HAVE_MENU := 1
HAVE_MENU_COMMON := 1
HAVE_OVERLAY := 1
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
RARCH_CONSOLE := 1
ifeq ($(DEBUG), 1)
HAVE_NETLOGGER = 1
endif
include Makefile.common
BLACKLIST :=
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
OBJ += input/drivers/psp_input.o
OBJ += input/drivers_joypad/psp_joypad.o
OBJ += audio/drivers/psp_audio.o
OBJ += frontend/drivers/platform_psp.o
OBJ += gfx/video_filters/2xsai.o
OBJ += gfx/video_filters/super2xsai.o
OBJ += gfx/video_filters/supereagle.o
OBJ += gfx/video_filters/2xbr.o
OBJ += gfx/video_filters/darken.o
OBJ += gfx/video_filters/epx.o
OBJ += gfx/video_filters/scale2x.o
OBJ += gfx/video_filters/blargg_ntsc_snes.o
OBJ += gfx/video_filters/lq2x.o
OBJ += gfx/video_filters/phosphor2x.o
OBJ += libretro-common/audio/dsp_filters/echo.o
OBJ += libretro-common/audio/dsp_filters/eq.o
OBJ += libretro-common/audio/dsp_filters/chorus.o
OBJ += libretro-common/audio/dsp_filters/iir.o
OBJ += libretro-common/audio/dsp_filters/panning.o
OBJ += libretro-common/audio/dsp_filters/phaser.o
OBJ += libretro-common/audio/dsp_filters/reverb.o
OBJ += libretro-common/audio/dsp_filters/wahwah.o
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 := $(CXX)
INCDIRS := -I. -Ideps/libz -Ideps/7zip -Ilibretro-common/include
LIBDIRS := -L.
ARCHFLAGS := -march=armv7-a -mfpu=neon -mfloat-abi=hard -DVITA
CFLAGS += $(ARCHFLAGS) -mword-relocations -fno-optimize-sibling-calls
ifeq ($(DEBUG), 1)
CFLAGS += -O2 -g
else
CFLAGS += -O3
endif
ASFLAGS := $(CFLAGS)
LDFLAGS := -Wl,-q
CFLAGS += -Wall -ffast-math
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 \
-lSceSysmodule_stub -lSceCtrl_stub -lSceTouch_stub -lSceAudio_stub \
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_stub \
-lSceFiber_stub -lSceMotion_stub -lSceAppMgr_stub -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
vita-elf-create $< $@
%.self: %.velf
vita-make-fself -c -s $< $@
%.vpk: %.self
vita-mksfoex -s TITLE_ID=$(VITA_TITLE_ID) "$(VITA_TITLE_NAME)" param.sfo
vita-pack-vpk -s param.sfo -b $< $@
clean:
rm -f $(OBJ) $(TARGET).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
.PHONY: clean all send vpksend
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend)
-82
View File
@@ -1,82 +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\
-lSceSysmodule_stub -lSceCtrl_stub -lSceAudio_stub -lSceFiber_stub\
-lScePower_stub -lSceRtc_stub -lSceCommonDialog_stub -lScePgf_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 \
frontend/drivers/platform_null.o \
libretro-common/file/file_path.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/compat/compat_strcasestr.o \
libretro-common/file/config_file.o \
libretro-common/streams/file_stream.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)" 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."
+6 -9
View File
@@ -29,7 +29,7 @@ ELF2DOL = $(DEVKITPPC)/bin/elf2dol$(EXE_EXT)
DOL_TARGET := retroarch-salamander_wii.dol
ELF_TARGET := retroarch-salamander_wii.elf
INCLUDE := -I. -I$(DEVKITPRO)/libogc/include -Ilibretro-common/include -Ideps/libz
INCLUDE := -I. -I$(DEVKITPRO)/libogc/include -Ilibretro-common/include -Ideps/zlib
LIBDIRS := -L$(DEVKITPRO)/libogc/lib/wii -L.
MACHDEP := -DGEKKO -DHW_RVL -mrvl -mcpu=750 -meabi -mhard-float
@@ -47,23 +47,20 @@ OBJ = frontend/frontend_salamander.o \
libretro-common/file/file_path.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/string/string_list.o \
libretro-common/file/dir_list.o \
libretro-common/file/retro_file.o \
libretro-common/file/retro_dirent.o \
libretro-common/file/retro_stat.o \
libretro-common/compat/compat_strl.o \
libretro-common/compat/compat_strcasestr.o \
libretro-common/file/config_file.o \
file_path_str.o \
verbosity.o \
$(APP_BOOTER_DIR)/app_booter.binobj
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
OBJ += logger/netlogger.o
endif
ifeq ($(HAVE_FILE_LOGGER), 1)
-245
View File
@@ -1,245 +0,0 @@
TARGET := retroarch_wiiu
BUILD_HBL_ELF = 1
BUILD_RPX = 1
DEBUG = 0
GRIFFIN_BUILD = 0
WHOLE_ARCHIVE_LINK = 0
PC_DEVELOPMENT_IP_ADDRESS ?=
PC_DEVELOPMENT_TCP_PORT ?=
OBJ :=
OBJ += wiiu/system/memory.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/controller_patcher/ControllerPatcher.o
OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o
OBJ += wiiu/controller_patcher/ConfigReader.o
OBJ += wiiu/controller_patcher/config/ConfigParser.o
OBJ += wiiu/controller_patcher/config/ConfigValues.o
OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o
OBJ += wiiu/controller_patcher/network/TCPServer.o
OBJ += wiiu/controller_patcher/network/UDPClient.o
OBJ += wiiu/controller_patcher/network/UDPServer.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o
OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o
OBJ += wiiu/controller_patcher/utils/CPRetainVars.o
OBJ += wiiu/controller_patcher/utils/CPStringTools.o
OBJ += wiiu/controller_patcher/utils/PadConst.o
OBJ += wiiu/controller_patcher/utils/FSHelper.o
OBJ += wiiu/tex_shader.o
OBJ += wiiu/hbl.o
DEFINES :=
ifeq ($(GRIFFIN_BUILD), 1)
OBJ += griffin/griffin.o
DEFINES += -DHAVE_GRIFFIN=1 -DHAVE_MENU -DHAVE_RGUI -DHAVE_LIBRETRODB
DEFINES += -DHAVE_ZLIB -DHAVE_RPNG -DHAVE_RJPEG -DHAVE_RBMP -DHAVE_RTGA -DWANT_ZLIB -DHAVE_CC_RESAMPLER
DEFINES += -DHAVE_STB_FONT -DHAVE_STB_VORBIS -DHAVE_LANGEXTRA -DHAVE_LIBRETRODB -DHAVE_NETWORKING
# DEFINES += -DWANT_IFADDRS
# DEFINES += -DHAVE_FREETYPE
DEFINES += -DHAVE_XMB -DHAVE_MATERIALUI
else
HAVE_MENU_COMMON = 1
HAVE_RTGA = 1
HAVE_RPNG = 1
HAVE_RJPEG = 1
HAVE_RBMP = 1
HAVE_RGUI = 1
HAVE_ZLIB = 1
HAVE_7ZIP = 1
HAVE_BUILTINZLIB = 1
HAVE_LIBRETRODB = 1
HAVE_ZARCH = 0
HAVE_MATERIALUI = 1
HAVE_XMB = 1
HAVE_STB_FONT = 1
# HAVE_FREETYPE = 1
HAVE_LANGEXTRA = 1
HAVE_LIBRETRODB = 1
HAVE_NETWORKING = 1
# WANT_IFADDRS = 1
include Makefile.common
BLACKLIST :=
BLACKLIST += input/input_overlay.o
BLACKLIST += tasks/task_overlay.o
BLACKLIST += $(LIBRETRO_COMM_DIR)/net/net_ifinfo.o
OBJ := $(filter-out $(BLACKLIST),$(OBJ))
OBJ += gfx/drivers/wiiu_gfx.o
OBJ += gfx/drivers_font/wiiu_font.o
OBJ += menu/drivers_display/menu_display_wiiu.o
OBJ += input/drivers/wiiu_input.o
OBJ += input/drivers_joypad/wiiu_joypad.o
OBJ += audio/drivers/wiiu_audio.o
OBJ += frontend/drivers/platform_wiiu.o
OBJ += gfx/video_filters/2xsai.o
OBJ += gfx/video_filters/super2xsai.o
OBJ += gfx/video_filters/supereagle.o
OBJ += gfx/video_filters/2xbr.o
OBJ += gfx/video_filters/darken.o
OBJ += gfx/video_filters/epx.o
OBJ += gfx/video_filters/scale2x.o
OBJ += gfx/video_filters/blargg_ntsc_snes.o
OBJ += gfx/video_filters/lq2x.o
OBJ += gfx/video_filters/phosphor2x.o
OBJ += libretro-common/audio/dsp_filters/echo.o
OBJ += libretro-common/audio/dsp_filters/eq.o
OBJ += libretro-common/audio/dsp_filters/chorus.o
OBJ += libretro-common/audio/dsp_filters/iir.o
OBJ += libretro-common/audio/dsp_filters/panning.o
OBJ += libretro-common/audio/dsp_filters/phaser.o
OBJ += libretro-common/audio/dsp_filters/reverb.o
OBJ += libretro-common/audio/dsp_filters/wahwah.o
endif
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
INCDIRS := -I. -Ideps/libz -Ideps/7zip -Ilibretro-common/include -Iwiiu -Iwiiu/include -I$(DEVKITPRO)/portlibs/ppc/include
LIBDIRS := -L. -L$(DEVKITPRO)/portlibs/ppc/lib
CFLAGS := -mwup -mcpu=750 -meabi -mhard-float
LDFLAGS :=
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
LDFLAGS := $(CFLAGS)
ASFLAGS := $(CFLAGS) -mregnames
CFLAGS += -ffast-math -Werror=implicit-function-declaration
#CFLAGS += -fomit-frame-pointer -mword-relocations
#CFLAGS += -Wall
#todo: remove -DWIIU and use the built-in macros instead (HW_WUP or __wiiu__).
CFLAGS += -DWIIU -DMSB_FIRST
CFLAGS += -DHAVE_MAIN
CFLAGS += -DHAVE_UPDATE_ASSETS
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_TCP_PORT),)
CFLAGS += -DPC_DEVELOPMENT_TCP_PORT=$(PC_DEVELOPMENT_TCP_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 -D_GNU_SOURCE
LDFLAGS += -Wl,--gc-sections
LIBS := $(WHOLE_START) -lretro_wiiu $(WHOLE_END) -lm -lfat -liosuhax
RPX_OBJ = wiiu/system/stubs_rpl.o
HBL_ELF_OBJ = wiiu/system/dynamic.o wiiu/system/stubs_elf.o
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
TARGETS :=
ifeq ($(BUILD_RPX), 1)
TARGETS += $(TARGET).rpx
endif
ifeq ($(BUILD_HBL_ELF), 1)
TARGETS += $(TARGET).elf
endif
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)
%.a:
$(AR) -rc $@ $^
%.depend: ;
$(ELF2RPL):
$(MAKE) -C wiiu/wut/elf2rpl/
$(TARGET).elf: $(OBJ) $(HBL_ELF_OBJ) libretro_wiiu.a wiiu/link_elf.ld
$(LD) $(OBJ) $(HBL_ELF_OBJ) $(LDFLAGS) $(HBL_ELF_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.ld
$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(TARGET).rpx: $(TARGET).rpx.elf $(ELF2RPL)
-$(ELF2RPL) $(TARGET).rpx.elf $@
clean:
rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
.PHONY: clean all
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
-175
View File
@@ -1,175 +0,0 @@
TARGET := retroarch_wiiu_salamander
BUILD_HBL_ELF = 1
BUILD_RPX = 1
DEBUG = 0
PC_DEVELOPMENT_IP_ADDRESS =
PC_DEVELOPMENT_TCP_PORT =
OBJ :=
OBJ += wiiu/system/memory.o
OBJ += wiiu/system/exception_handler.o
OBJ += wiiu/fs/sd_fat_devoptab.o
OBJ += wiiu/fs/fs_utils.o
OBJ += wiiu/hbl.o
OBJ += frontend/frontend_salamander.o
OBJ += frontend/frontend_driver.o
OBJ += frontend/drivers/platform_wiiu.o
OBJ += frontend/drivers/platform_null.o
OBJ += libretro-common/compat/compat_strcasestr.o
OBJ += libretro-common/file/file_path.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/hash/rhash.o
OBJ += file_path_str.o
OBJ += verbosity.o
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
INCDIRS := -I. -Ideps/libz -Ideps/7zip -Ilibretro-common/include -Iwiiu -Iwiiu/include -I$(DEVKITPRO)/portlibs/ppc/include
LIBDIRS := -L. -L$(DEVKITPRO)/portlibs/ppc/lib
CFLAGS := -mwup -mcpu=750 -meabi -mhard-float
LDFLAGS :=
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -g
else
CFLAGS += -O3
endif
LDFLAGS := $(CFLAGS)
ASFLAGS := $(CFLAGS) -mregnames
CFLAGS += -ffast-math -Werror=implicit-function-declaration
#CFLAGS += -fomit-frame-pointer -mword-relocations
#CFLAGS += -Wall
#todo: remove -DWIIU and use the built-in macros instead (HW_WUP or __wiiu__).
CFLAGS += -DWIIU -DMSB_FIRST
CFLAGS += -DHAVE_MAIN
CFLAGS += -DRARCH_CONSOLE -DIS_SALAMANDER
ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),)
CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS='"$(PC_DEVELOPMENT_IP_ADDRESS)"'
endif
ifneq ($(PC_DEVELOPMENT_TCP_PORT),)
CFLAGS += -DPC_DEVELOPMENT_TCP_PORT=$(PC_DEVELOPMENT_TCP_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
LDFLAGS += -Wl,--gc-sections
LIBS := $(WHOLE_START) -lretro_wiiu $(WHOLE_END) -lm -lfat -liosuhax
RPX_OBJ = wiiu/system/stubs_rpl.o
HBL_ELF_OBJ = wiiu/system/dynamic.o wiiu/system/stubs_elf.o
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
TARGETS :=
ifeq ($(BUILD_RPX), 1)
TARGETS += $(TARGET).rpx
endif
ifeq ($(BUILD_HBL_ELF), 1)
TARGETS += $(TARGET).elf
endif
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)
%.a:
$(AR) -rc $@ $^
%.depend: ;
$(ELF2RPL):
$(MAKE) -C wiiu/wut/elf2rpl/
$(TARGET).elf: $(OBJ) $(HBL_ELF_OBJ) libretro_wiiu.a wiiu/link_elf.ld
$(LD) $(OBJ) $(HBL_ELF_OBJ) $(LDFLAGS) $(HBL_ELF_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(TARGET).rpx.elf: $(OBJ) $(RPX_OBJ) libretro_wiiu.a wiiu/link_elf.ld
$(LD) $(OBJ) $(RPX_OBJ) $(LDFLAGS) $(RPX_LDFLAGS) $(LIBDIRS) $(LIBS) -o $@
$(TARGET).rpx: $(TARGET).rpx.elf $(ELF2RPL)
-$(ELF2RPL) $(TARGET).rpx.elf $@
clean:
rm -f $(OBJ) $(RPX_OBJ) $(HBL_ELF_OBJ) $(TARGET).elf $(TARGET).rpx.elf $(TARGET).rpx
rm -f $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
.PHONY: clean all
.PRECIOUS: %.depend
-include $(OBJ:.o=.depend) $(RPX_OBJ:.o=.depend) $(HBL_ELF_OBJ:.o=.depend)
+3 -2
View File
@@ -3,11 +3,11 @@ TARGET = retroarch.exe
HAVE_DINPUT = 1
HAVE_XAUDIO = 1
HAVE_DSOUND = 1
HAVE_WASAPI = 1
HAVE_OPENGL = 1
HAVE_FBO = 1
HAVE_DYLIB = 1
HAVE_D3D9 = 1
HAVE_NETPLAY = 1
HAVE_NETWORKING = 1
HAVE_STDIN_CMD = 1
HAVE_COMMAND = 1
@@ -15,6 +15,7 @@ HAVE_THREADS = 1
HAVE_RGUI = 1
HAVE_MATERIALUI = 1
HAVE_7ZIP = 1
HAVE_ZLIB_DEFLATE = 1
HAVE_PYTHON = 0
DYNAMIC = 1
@@ -33,7 +34,6 @@ HAVE_CG := 1
HAVE_LIBXML2 := 0
HAVE_ZLIB := 1
WANT_ZLIB := 1
HAVE_CC_RESAMPLER := 1
ifeq ($(HAVE_CG), 1)
CG_LIBS := -lcg -lcgGL
@@ -120,6 +120,7 @@ ifeq ($(DEBUG), 1)
else
CFLAGS += -O3 -ffast-math
CXXFLAGS += -O3 -ffast-math
LDCXXFLAGS += -s
endif
CFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I.
+1 -1
View File
@@ -18,7 +18,7 @@ So we will use
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:
Now we edit drivers/video/sunxi/disp/dev_fb.c, and uncoment 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:
+25 -31
View File
@@ -1,6 +1,3 @@
[![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.
@@ -17,15 +14,15 @@ A libretro core written in portable C or C++ can run seamlessly on many platform
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)
[libretro API header](https://github.com/libretro/RetroArch/blob/master/libretro.h)
## Binaries
Latest Windows binaries are currently hosted on the [buildbot](http://buildbot.libretro.com/).
Latest Windows 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](http://www.libretro.com/forums/),
To reach developers, either make an issue here on Github, make a thread on the [forum](http://www.libretro.com/forums/),
or visit our IRC channel: #retroarch @ irc.freenode.org.
## Documentation
@@ -54,7 +51,7 @@ RetroArch also emphasizes on being easy to integrate into various launcher front
RetroArch has been ported to the following platforms outside PC:
- PlayStation 3
- PlayStation3
- Xbox 360 (Libxenon/XeXDK)
- Xbox 1
- Wii, Gamecube (Libogc)
@@ -116,11 +113,10 @@ A sample configuration file is installed to /etc/retroarch.cfg. This is the syst
RetroArch will on startup create a config file in $XDG\_CONFIG\_HOME/retroarch/retroarch.cfg if doesn't 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.
To configure joypads, use the built-in menu or the <tt>retroarch-joyconfig</tt> command-line tool.
## Compiling and installing
**Linux**
<b>Linux</b><br/>
- Prerequisites:
```bash
sudo apt-get install -y make git-core curl g++ pkg-config libglu1-mesa-dev freeglut3-dev mesa-common-dev libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev
@@ -131,8 +127,7 @@ sudo apt-get install -y make git-core curl g++ pkg-config libglu1-mesa-dev freeg
make
```
**Mac**
<b>Mac</b><br/>
- Prerequisites: [XCode](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAA&url=https%3A%2F%2Fitunes.apple.com%2Fus%2Fapp%2Fxcode%2Fid497799835%3Fmt%3D12&ei=ZmfeVNPtIILVoASBnoCYBw&usg=AFQjCNGrxKmVtXUdvUU3MhqZhP4MHT6Gtg&sig2=RIXKsWQ79YTQBt_lK5fdKA&bvm=bv.85970519,d.cGU), [Cg](https://developer.nvidia.com/cg-toolkit-download).
- You can open the project (**pkg/apple/RetroArch.xcodeproj**) in the Xcode IDE and build (**&#8984;-B**) and run (**&#8984;-R**) it there. Or you can use the command line...
- Debug:
@@ -150,63 +145,62 @@ xcodebuild -target RetroArch -configuration Release -project pkg/apple/RetroArch
open ./pkg/apple/build/Release/RetroArch.app/
```
**PC**
<b>PC</b><br/>
Instructions for compiling on PC can be found in the [wiki](https://github.com/Themaister/RetroArch/wiki).
**PlayStation 3**
<b>PlayStation3</b><br/>
RetroArch PS3 needs to be compiled in the following order:
1) Compile RetroArch Salamander
make -f Makefile.ps3.salamander
<tt>make -f Makefile.ps3.salamander</tt>
2) Finally, compile RetroArch packed together with the GUI:
make -f Makefile.ps3
<tt>make -f Makefile.ps3</tt>
**PlayStation 3 - Creating a PKG installable file**
<b>PlayStation3 - Creating a PKG installable file</b><br />
You can add `pkg` as a parameter in order to make a PKG file - for example:
make -f Makefile.ps3 pkg
<tt>make -f Makefile.ps3 pkg</tt>
This creates an NPDRM package. This can be installed on debug PS3s.
To make a non-NPDRM package that can be installed on a jailbroken/CFW PS3 (such as PSGroove or PS3 CFWs and other 3.55 CFW derivatives), do:
make -f Makefile.ps3 pkg-signed
<tt>make -f Makefile.ps3 pkg-signed</tt>
If you're using Kmeaw 3.55 firmware, the package needs to be signed:
make -f Makefile.ps3 pkg-signed-cfw
<tt>make -f Makefile.ps3 pkg-signed-cfw</tt>
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch PS3. This file needs to be called ***`libretro_ps3.a`***.
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch PS3. This file needs to be called <em><b>`libretro_ps3.a`</b></em>.
**Xbox 360 (XeXDK)**
<b> Xbox 360 (XeXDK)</b><br />
You will need Microsoft Visual Studio 2010 installed (or higher) in order to compile RetroArch 360.
The solution file can be found at the following location:
pkg/msvc-360/RetroArch-360.sln
<tt>pkg/msvc-360/RetroArch-360.sln</tt>
NOTE: A pre-existing libretro library needs to be present in the `pkg/msvc-360/RetroArch-360/Release` directory in order to link RetroArch 360. This file needs to be
called ***`libretro_xdk360.lib`***.
called <em><b>`libretro_xdk360.lib`</b></em>.
**Xbox 360 (Libxenon)**
<b> Xbox 360 (Libxenon)</b><br />
You will need to have the libxenon libraries and a working Devkit Xenon toolchain installed in order to compile RetroArch 360 Libxenon.
make -f Makefile.xenon
<tt>make -f Makefile.xenon</tt>
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch 360 Libxenon. This file needs to be called ***`libretro_xenon360.a`***.
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch 360 Libxenon. This file needs to be called <em><b>`libretro_xenon360.a`</b></em>.
**Wii**
<b> Wii</b><br >
You will need to have the libogc libraries and a working Devkit PPC toolchain installed in order to compile RetroArch Wii.
make -f Makefile.griffin platform=wii
<tt>make -f Makefile.griffin platform=wii</tt>
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch Wii. This file needs to be called ***`libretro_wii.a`***.
NOTE: A pre-existing libretro library needs to be present in the root directory in order to link RetroArch Wii. This file needs to be called <em><b>`libretro_wii.a`</b></em>.
+445 -826
View File
File diff suppressed because it is too large. Load diff
+49 -151
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -20,29 +20,45 @@
#include <stdint.h>
#include <stddef.h>
#include <sys/types.h>
#include <boolean.h>
#include <audio/audio_mixer.h>
#include <retro_common_api.h>
#include "audio_dsp_filter.h"
RETRO_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
#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
enum audio_action
enum rarch_audio_ctl_state
{
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
RARCH_AUDIO_CTL_NONE = 0,
RARCH_AUDIO_CTL_INIT,
RARCH_AUDIO_CTL_DEINIT,
RARCH_AUDIO_CTL_DESTROY,
RARCH_AUDIO_CTL_DESTROY_DATA,
RARCH_AUDIO_CTL_START,
RARCH_AUDIO_CTL_STOP,
RARCH_AUDIO_CTL_FIND_DRIVER,
RARCH_AUDIO_CTL_SETUP_REWIND,
/* Sets audio monitor refresh rate to new value. */
RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE,
RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES,
RARCH_AUDIO_CTL_MUTE_TOGGLE,
RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE,
RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE,
RARCH_AUDIO_CTL_SET_CALLBACK,
RARCH_AUDIO_CTL_UNSET_CALLBACK,
RARCH_AUDIO_CTL_CALLBACK,
RARCH_AUDIO_CTL_HAS_CALLBACK,
RARCH_AUDIO_CTL_ALIVE,
RARCH_AUDIO_CTL_FRAME_IS_REVERSE,
RARCH_AUDIO_CTL_SET_OWN_DRIVER,
RARCH_AUDIO_CTL_UNSET_OWN_DRIVER,
RARCH_AUDIO_CTL_OWNS_DRIVER,
RARCH_AUDIO_CTL_SET_ACTIVE,
RARCH_AUDIO_CTL_UNSET_ACTIVE,
RARCH_AUDIO_CTL_IS_ACTIVE,
RARCH_AUDIO_CTL_RESAMPLER_DEINIT,
RARCH_AUDIO_CTL_RESAMPLER_INIT,
RARCH_AUDIO_CTL_RESAMPLER_PROCESS
};
typedef struct audio_driver
@@ -51,8 +67,7 @@ typedef struct audio_driver
*
* Returns: audio driver handle on success, otherwise NULL.
**/
void *(*init)(const char *device, unsigned rate,
unsigned latency, unsigned block_frames, unsigned *new_rate);
void *(*init)(const char *device, unsigned rate, unsigned latency);
/*
* @data : Pointer to audio data handle.
@@ -60,110 +75,39 @@ typedef struct audio_driver
* @size : Size of audio buffer.
*
* Write samples to audio driver.
*
* Write data in buffer to audio driver.
* A frame here is defined as one combined sample of left and right
* channels. (I.e. 44.1kHz, 16-bit stereo has 88.2k samples/s, and
* 44.1k frames/s.)
*
* Samples are interleaved in format LRLRLRLRLR ...
* If the driver returns true in use_float(), a floating point
* format will be used, with range [-1.0, 1.0].
* If not, signed 16-bit samples in native byte ordering will be used.
*
* This function returns the number of frames successfully written.
* If an error occurs, -1 should be returned.
* Note that non-blocking behavior that cannot write at this time
* should return 0 as returning -1 will terminate the driver.
*
* Unless said otherwise with set_nonblock_state(), all writes
* are blocking, and it should block till it has written all frames.
*/
**/
ssize_t (*write)(void *data, const void *buf, size_t size);
/* Temporarily pauses the audio driver. */
/* Stops driver. */
bool (*stop)(void *data);
/* Resumes audio driver from the paused state. */
bool (*start)(void *data, bool is_shutdown);
/* Starts driver. */
bool (*start)(void *data);
/* Is the audio driver currently running? */
bool (*alive)(void *data);
/* Should we care about blocking in audio thread? Fast forwarding.
*
* If state is true, nonblocking operation is assumed.
* This is typically used for fast-forwarding. If driver cannot
* implement nonblocking writes, this can be disregarded, but should
* log a message to stderr.
* */
/* Should we care about blocking in audio thread? Fast forwarding. */
void (*set_nonblock_state)(void *data, bool toggle);
/* Stops and frees driver data. */
/* Frees driver data. */
void (*free)(void *data);
/* Defines if driver will take standard floating point samples,
* or int16_t samples.
*
* If true is returned, the audio driver is capable of using
* floating point data. This will likely increase performance as the
* resampler unit uses floating point. The sample range is
* [-1.0, 1.0].
* */
* or int16_t samples. */
bool (*use_float)(void *data);
/* Human-readable identifier. */
const char *ident;
/* Optional. Get audio device list (allocates, caller has to free this) */
void *(*device_list_new)(void *data);
/* Optional. Frees audio device list */
void (*device_list_free)(void *data, void *data2);
/* Optional. */
size_t (*write_avail)(void *data);
size_t (*buffer_size)(void *data);
} audio_driver_t;
enum audio_mixer_state
{
AUDIO_STREAM_STATE_NONE = 0,
AUDIO_STREAM_STATE_STOPPED,
AUDIO_STREAM_STATE_PLAYING,
AUDIO_STREAM_STATE_PLAYING_LOOPED
};
typedef struct audio_mixer_stream_params
{
float volume;
enum audio_mixer_type type;
enum audio_mixer_state state;
void *buf;
size_t bufsize;
audio_mixer_stop_cb_t cb;
} audio_mixer_stream_params_t;
void audio_driver_destroy_data(void);
void audio_driver_set_own_driver(void);
void audio_driver_unset_own_driver(void);
void audio_driver_set_active(void);
void audio_driver_destroy(void);
void audio_driver_deinit_resampler(void);
bool audio_driver_free_devices_list(void);
bool audio_driver_new_devices_list(void);
bool audio_driver_enable_callback(void);
bool audio_driver_disable_callback(void);
bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data);
/**
* audio_driver_find_handle:
@@ -202,7 +146,7 @@ void audio_driver_sample_rewind(int16_t left, int16_t right);
size_t audio_driver_sample_batch_rewind(const int16_t *data, size_t frames);
bool audio_driver_mixer_extension_supported(const char *ext);
void audio_driver_set_volume_gain(float gain);
void audio_driver_dsp_filter_free(void);
@@ -210,56 +154,10 @@ void audio_driver_dsp_filter_init(const char *device);
void audio_driver_set_buffer_size(size_t bufsize);
bool audio_driver_get_devices_list(void **ptr);
void audio_driver_setup_rewind(void);
void audio_driver_monitor_adjust_system_rates(void);
bool audio_driver_set_callback(const void *data);
bool audio_driver_callback(void);
bool audio_driver_has_callback(void);
/* Sets audio monitor rate to new value. */
void audio_driver_monitor_set_rate(void);
bool audio_driver_find_driver(void);
bool audio_driver_toggle_mute(void);
bool audio_driver_start(bool is_shutdown);
bool audio_driver_stop(void);
bool audio_driver_owns_driver(void);
void audio_driver_unset_callback(void);
void audio_driver_frame_is_reverse(void);
void audio_set_float(enum audio_action action, float val);
void audio_set_bool(enum audio_action action, bool val);
void audio_unset_bool(enum audio_action action, bool val);
float *audio_get_float_ptr(enum audio_action action);
bool *audio_get_bool_ptr(enum audio_action action);
bool audio_driver_deinit(void);
bool audio_driver_init(void);
bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params);
extern audio_driver_t audio_rsound;
extern audio_driver_t audio_oss;
extern audio_driver_t audio_alsa;
extern audio_driver_t audio_alsathread;
extern audio_driver_t audio_tinyalsa;
extern audio_driver_t audio_roar;
extern audio_driver_t audio_openal;
extern audio_driver_t audio_opensl;
@@ -268,18 +166,18 @@ extern audio_driver_t audio_sdl;
extern audio_driver_t audio_xa;
extern audio_driver_t audio_pulse;
extern audio_driver_t audio_dsound;
extern audio_driver_t audio_wasapi;
extern audio_driver_t audio_coreaudio;
extern audio_driver_t audio_xenon360;
extern audio_driver_t audio_ps3;
extern audio_driver_t audio_gx;
extern audio_driver_t audio_ax;
extern audio_driver_t audio_psp;
extern audio_driver_t audio_ctr_csnd;
extern audio_driver_t audio_ctr_dsp;
extern audio_driver_t audio_rwebaudio;
extern audio_driver_t audio_null;
RETRO_END_DECLS
#ifdef __cplusplus
}
#endif
#endif
@@ -1,23 +1,17 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2016 - Daniel De Matteis
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (dsp_filter.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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>
@@ -29,14 +23,16 @@
#include <file/file_path.h>
#include <file/config_file_userdata.h>
#include <features/features_cpu.h>
#include <lists/string_list.h>
#include <string/stdstring.h>
#include <libretro_dspfilter.h>
#include <file/dir_list.h>
#include <audio/dsp_filter.h>
#include "audio_dsp_filter.h"
#include "audio_filters/dspfilter.h"
struct retro_dsp_plug
#include "../frontend/frontend_driver.h"
#include "../performance.h"
#include "../dynamic.h"
struct rarch_dsp_plug
{
#ifdef HAVE_DYLIB
dylib_t lib;
@@ -44,30 +40,30 @@ struct retro_dsp_plug
const struct dspfilter_implementation *impl;
};
struct retro_dsp_instance
struct rarch_dsp_instance
{
const struct dspfilter_implementation *impl;
void *impl_data;
};
struct retro_dsp_filter
struct rarch_dsp_filter
{
config_file_t *conf;
struct retro_dsp_plug *plugs;
struct rarch_dsp_plug *plugs;
unsigned num_plugs;
struct retro_dsp_instance *instances;
struct rarch_dsp_instance *instances;
unsigned num_instances;
};
static const struct dspfilter_implementation *find_implementation(
retro_dsp_filter_t *dsp, const char *ident)
rarch_dsp_filter_t *dsp, const char *ident)
{
unsigned i;
for (i = 0; i < dsp->num_plugs; i++)
{
if (string_is_equal(dsp->plugs[i].impl->short_ident, ident))
if (!strcmp(dsp->plugs[i].impl->short_ident, ident))
return dsp->plugs[i].impl;
}
@@ -83,32 +79,28 @@ static const struct dspfilter_config dspfilter_config = {
config_userdata_free,
};
static bool create_filter_graph(retro_dsp_filter_t *dsp, float sample_rate)
static bool create_filter_graph(rarch_dsp_filter_t *dsp, float sample_rate)
{
unsigned i;
struct retro_dsp_instance *instances = NULL;
unsigned filters = 0;
unsigned i, filters = 0;
if (!config_get_uint(dsp->conf, "filters", &filters))
return false;
instances = (struct retro_dsp_instance*)calloc(filters, sizeof(*instances));
if (!instances)
dsp->instances = (struct rarch_dsp_instance*)
calloc(filters, sizeof(*dsp->instances));
if (!dsp->instances)
return false;
dsp->instances = instances;
dsp->num_instances = filters;
for (i = 0; i < filters; i++)
{
struct config_file_userdata userdata;
struct dspfilter_info info;
char key[64];
char name[64];
char key[64] = {0};
char name[64] = {0};
key[0] = name[0] = '\0';
info.input_rate = sample_rate;
info.input_rate = sample_rate;
snprintf(key, sizeof(key), "filter%u", i);
@@ -124,8 +116,7 @@ static bool create_filter_graph(retro_dsp_filter_t *dsp, float sample_rate)
userdata.prefix[0] = key;
userdata.prefix[1] = dsp->instances[i].impl->short_ident;
dsp->instances[i].impl_data = dsp->instances[i].impl->init(&info,
&dspfilter_config, &userdata);
dsp->instances[i].impl_data = dsp->instances[i].impl->init(&info, &dspfilter_config, &userdata);
if (!dsp->instances[i].impl_data)
return false;
}
@@ -152,17 +143,18 @@ static const dspfilter_get_implementation_t dsp_plugs_builtin[] = {
chorus_dspfilter_get_implementation,
};
static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list)
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
{
unsigned i;
dspfilter_simd_mask_t mask = (dspfilter_simd_mask_t)cpu_features_get();
struct retro_dsp_plug *plugs = (struct retro_dsp_plug*)
calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*plugs));
dspfilter_simd_mask_t mask = retro_get_cpu_features();
if (!plugs)
(void)list;
dsp->plugs = (struct rarch_dsp_plug*)
calloc(ARRAY_SIZE(dsp_plugs_builtin), sizeof(*dsp->plugs));
if (!dsp->plugs)
return false;
dsp->plugs = plugs;
dsp->num_plugs = ARRAY_SIZE(dsp_plugs_builtin);
for (i = 0; i < ARRAY_SIZE(dsp_plugs_builtin); i++)
@@ -175,18 +167,17 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list)
return true;
}
#elif defined(HAVE_DYLIB)
static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list)
static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list)
{
unsigned i;
dspfilter_simd_mask_t mask = cpu_features_get();
dspfilter_simd_mask_t mask = retro_get_cpu_features();
for (i = 0; i < list->size; i++)
{
dspfilter_get_implementation_t cb;
const struct dspfilter_implementation *impl = NULL;
struct retro_dsp_plug *new_plugs = NULL;
dylib_t lib =
dylib_load(list->elems[i].data);
struct rarch_dsp_plug *new_plugs = NULL;
dylib_t lib = dylib_load(list->elems[i].data);
dspfilter_get_implementation_t cb;
if (!lib)
continue;
@@ -211,7 +202,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list)
continue;
}
new_plugs = (struct retro_dsp_plug*)
new_plugs = (struct rarch_dsp_plug*)
realloc(dsp->plugs, sizeof(*dsp->plugs) * (dsp->num_plugs + 1));
if (!new_plugs)
{
@@ -231,26 +222,34 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list)
}
#endif
retro_dsp_filter_t *retro_dsp_filter_new(
const char *filter_config,
void *string_data,
float sample_rate)
rarch_dsp_filter_t *rarch_dsp_filter_new(
const char *filter_config, float sample_rate)
{
config_file_t *conf = NULL;
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
char basedir[PATH_MAX_LENGTH];
char ext_name[PATH_MAX_LENGTH];
#endif
struct string_list *plugs = NULL;
retro_dsp_filter_t *dsp = (retro_dsp_filter_t*)calloc(1, sizeof(*dsp));
rarch_dsp_filter_t *dsp = NULL;
dsp = (rarch_dsp_filter_t*)calloc(1, sizeof(*dsp));
if (!dsp)
return NULL;
conf = config_file_new(filter_config);
if (!conf) /* Did not find config. */
dsp->conf = config_file_new(filter_config);
if (!dsp->conf) /* Did not find config. */
goto error;
dsp->conf = conf;
#if !defined(HAVE_FILTERS_BUILTIN) && defined(HAVE_DYLIB)
fill_pathname_basedir(basedir, filter_config, sizeof(basedir));
if (string_data)
plugs = (struct string_list*)string_data;
if (!frontend_driver_get_core_extension(ext_name, sizeof(ext_name)))
goto error;
plugs = dir_list_new(basedir, ext_name, false, false);
if (!plugs)
goto error;
#endif
#if defined(HAVE_DYLIB) || defined(HAVE_FILTERS_BUILTIN)
if (!append_plugs(dsp, plugs))
@@ -269,11 +268,11 @@ retro_dsp_filter_t *retro_dsp_filter_new(
error:
if (plugs)
string_list_free(plugs);
retro_dsp_filter_free(dsp);
rarch_dsp_filter_free(dsp);
return NULL;
}
void retro_dsp_filter_free(retro_dsp_filter_t *dsp)
void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp)
{
unsigned i;
if (!dsp)
@@ -301,8 +300,8 @@ void retro_dsp_filter_free(retro_dsp_filter_t *dsp)
free(dsp);
}
void retro_dsp_filter_process(retro_dsp_filter_t *dsp,
struct retro_dsp_data *data)
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp,
struct rarch_dsp_data *data)
{
unsigned i;
struct dspfilter_output output = {0};
+24 -23
View File
@@ -1,5 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2016 - Ali Bouhlel
* 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-
@@ -13,36 +14,36 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TEX_SHADER_H
#define TEX_SHADER_H
#include <wiiu/gx2.h>
#ifndef __AUDIO_DSP_FILTER_H__
#define __AUDIO_DSP_FILTER_H__
#ifdef __cplusplus
extern "C" {
#endif
typedef struct __attribute__((aligned(GX2_VERTEX_BUFFER_ALIGNMENT)))
{
GX2VertexShader vs;
GX2PixelShader ps;
GX2SamplerVar sampler;
struct
{
GX2AttribVar position;
GX2AttribVar tex_coord;
} attributes;
struct
{
GX2AttribStream position;
GX2AttribStream tex_coord;
} attribute_stream;
GX2FetchShader fs;
}tex_shader_t;
typedef struct rarch_dsp_filter rarch_dsp_filter_t;
extern tex_shader_t tex_shader;
rarch_dsp_filter_t *rarch_dsp_filter_new(const char *filter_config,
float sample_rate);
void rarch_dsp_filter_free(rarch_dsp_filter_t *dsp);
struct rarch_dsp_data
{
float *input;
unsigned input_frames;
/* Set by rarch_dsp_filter_process(). */
float *output;
unsigned output_frames;
};
void rarch_dsp_filter_process(rarch_dsp_filter_t *dsp,
struct rarch_dsp_data *data);
#ifdef __cplusplus
}
#endif
#endif // TEX_SHADER_H
#endif
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -3,8 +3,6 @@ extra_flags :=
use_neon := 0
build = release
DYLIB := so
PREFIX := /usr
INSTALLDIR := $(PREFIX)/lib/retroarch/filters/audio
ifeq ($(platform),)
platform = unix
@@ -59,7 +57,7 @@ endif
CC := $(compiler) -Wall
CXX := $(subst CC,++,$(compiler)) -std=gnu++0x -Wall
flags := $(CPPFLAGS) $(CFLAGS) -fPIC $(extra_flags) -I../../include
flags := $(CFLAGS) -fPIC $(extra_flags) -I../../libretro-common/include
asflags := $(ASFLAGS) -fPIC $(extra_flags)
objects :=
@@ -91,10 +89,3 @@ clean:
strip:
strip -s *.$(DYLIB)
install:
mkdir -p $(DESTDIR)$(INSTALLDIR)
cp -t $(DESTDIR)$(INSTALLDIR) $(targets) *.dsp
test-install:
DESTDIR=/tmp/build $(MAKE) install
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,31 +1,24 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (chorus.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#define CHORUS_MAX_DELAY 4096
#define CHORUS_DELAY_MASK (CHORUS_MAX_DELAY - 1)
@@ -46,20 +39,18 @@ struct chorus_data
static void chorus_free(void *data)
{
if (data)
free(data);
free(data);
}
static void chorus_process(void *data, struct dspfilter_output *output,
const struct dspfilter_input *input)
{
unsigned i;
float *out = NULL;
struct chorus_data *ch = (struct chorus_data*)data;
output->samples = input->samples;
output->frames = input->frames;
out = output->samples;
output->samples = input->samples;
output->frames = input->frames;
float *out = output->samples;
for (i = 0; i < input->frames; i++, out += 2)
{
@@ -74,27 +65,24 @@ static void chorus_process(void *data, struct dspfilter_output *output,
ch->lfo_ptr = 0;
delay_int = (unsigned)delay;
if (delay_int >= CHORUS_MAX_DELAY - 1)
delay_int = CHORUS_MAX_DELAY - 2;
delay_frac = delay - delay_int;
ch->old[0][ch->old_ptr] = in[0];
ch->old[1][ch->old_ptr] = in[1];
l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK];
l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK];
r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK];
r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK];
l_a = ch->old[0][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK];
l_b = ch->old[0][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK];
r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK];
r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK];
/* Lerp introduces aliasing of the chorus component,
* but doing full polyphase here is probably overkill. */
chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac;
chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac;
/* Lerp introduces aliasing of the chorus component, but doing full polyphase here is probably overkill. */
chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac;
chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac;
out[0] = ch->mix_dry * in[0] + ch->mix_wet * chorus_l;
out[1] = ch->mix_dry * in[1] + ch->mix_wet * chorus_r;
out[0] = ch->mix_dry * in[0] + ch->mix_wet * chorus_l;
out[1] = ch->mix_dry * in[1] + ch->mix_wet * chorus_r;
ch->old_ptr = (ch->old_ptr + 1) & CHORUS_DELAY_MASK;
}
@@ -150,8 +138,7 @@ static const struct dspfilter_implementation chorus_plug = {
#define dspfilter_get_implementation chorus_dspfilter_get_implementation
#endif
const struct dspfilter_implementation *
dspfilter_get_implementation(dspfilter_simd_mask_t mask)
const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask)
{
(void)mask;
return &chorus_plug;
@@ -1,31 +1,26 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2015 - Daniel De Matteis
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this libretro API header (libretro_dspfilter.h).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef LIBRETRO_DSPFILTER_API_H__
#define LIBRETRO_DSPFILTER_API_H__
#ifndef DSPFILTER_API_H__
#define DSPFILTER_API_H__
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
#ifdef __cplusplus
extern "C" {
#endif
#define DSPFILTER_SIMD_SSE (1 << 0)
#define DSPFILTER_SIMD_SSE2 (1 << 1)
@@ -182,6 +177,8 @@ struct dspfilter_implementation
const char *short_ident;
};
RETRO_END_DECLS
#ifdef __cplusplus
}
#endif
#endif
@@ -1,29 +1,23 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (echo.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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 <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#include "dspfilter.h"
struct echo_channel
{
@@ -55,13 +49,12 @@ static void echo_process(void *data, struct dspfilter_output *output,
const struct dspfilter_input *input)
{
unsigned i, c;
float *out = NULL;
struct echo_data *echo = (struct echo_data*)data;
output->samples = input->samples;
output->frames = input->frames;
output->samples = input->samples;
output->frames = input->frames;
out = output->samples;
float *out = output->samples;
for (i = 0; i < input->frames; i++, out += 2)
{
@@ -101,35 +94,25 @@ static void *echo_init(const struct dspfilter_info *info,
const struct dspfilter_config *config, void *userdata)
{
unsigned i, channels;
struct echo_channel *echo_channels = NULL;
float *delay = NULL;
float *feedback = NULL;
unsigned num_delay = 0;
unsigned num_feedback = 0;
float *delay = NULL, *feedback = NULL;
unsigned num_delay = 0, num_feedback = 0;
static const float default_delay[] = { 200.0f };
static const float default_delay[] = { 200.0f };
static const float default_feedback[] = { 0.5f };
struct echo_data *echo = (struct echo_data*)
calloc(1, sizeof(*echo));
struct echo_data *echo = (struct echo_data*)calloc(1, sizeof(*echo));
if (!echo)
return NULL;
config->get_float_array(userdata, "delay", &delay,
&num_delay, default_delay, 1);
config->get_float_array(userdata, "feedback", &feedback,
&num_feedback, default_feedback, 1);
config->get_float_array(userdata, "delay", &delay, &num_delay, default_delay, 1);
config->get_float_array(userdata, "feedback", &feedback, &num_feedback, default_feedback, 1);
config->get_float(userdata, "amp", &echo->amp, 0.2f);
channels = num_feedback = num_delay = MIN(num_delay, num_feedback);
echo_channels = (struct echo_channel*)calloc(channels,
sizeof(*echo_channels));
if (!echo_channels)
echo->channels = (struct echo_channel*)calloc(channels, sizeof(*echo->channels));
if (!echo->channels)
goto error;
echo->channels = echo_channels;
echo->num_channels = channels;
for (i = 0; i < channels; i++)
@@ -1,25 +1,17 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (eq.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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 <stdlib.h>
#include <string.h>
@@ -27,7 +19,8 @@
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <filters.h>
#include <libretro_dspfilter.h>
#include "dspfilter.h"
#include "fft/fft.c"
@@ -149,8 +142,7 @@ static void generate_response(fft_complex_t *response,
gains++;
}
/* Create a response by linear interpolation between
* known frequency sample points. */
// Create a response by linear interpolation between known frequency sample points.
for (i = 0; i <= samples; i++)
{
float gain;
@@ -212,11 +204,9 @@ static void create_filter(struct eq_data *eq, unsigned size_log2,
/* Get equivalent time-domain filter. */
fft_process_inverse(fft, time_filter, eq->filter, 1);
/* ifftshift() to create the correct linear phase filter.
* The filter response was designed with zero phase, which
* won't work unless we compensate
* for the repeating property of the FFT here
* by flipping left and right blocks. */
// ifftshift() to create the correct linear phase filter.
// The filter response was designed with zero phase, which won't work unless we compensate
// for the repeating property of the FFT here by flipping left and right blocks.
for (i = 0; i < half_block_size; i++)
{
float tmp = time_filter[i + half_block_size];
@@ -1,30 +1,22 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (fft.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "fft.h"
#include <math.h>
#include <stdlib.h>
#include "fft.h"
#include <retro_miscellaneous.h>
struct fft
@@ -136,8 +128,8 @@ void fft_free(fft_t *fft)
static void butterfly(fft_complex_t *a, fft_complex_t *b, fft_complex_t mod)
{
mod = fft_complex_mul(mod, *b);
*b = fft_complex_sub(*a, mod);
*a = fft_complex_add(*a, mod);
*b = fft_complex_sub(*a, mod);
*a = fft_complex_add(*a, mod);
}
static void butterflies(fft_complex_t *butterfly_buf,
@@ -149,8 +141,7 @@ static void butterflies(fft_complex_t *butterfly_buf,
{
int phase_step = (int)samples * phase_dir / (int)step_size;
for (j = i; j < i + step_size; j++)
butterfly(&butterfly_buf[j], &butterfly_buf[j + step_size],
phase_lut[phase_step * (int)(j - i)]);
butterfly(&butterfly_buf[j], &butterfly_buf[j + step_size], phase_lut[phase_step * (int)(j - i)]);
}
}
@@ -189,9 +180,7 @@ void fft_process_inverse(fft_t *fft,
{
unsigned step_size;
unsigned samples = fft->size;
interleave_complex(fft->bitinverse_buffer, fft->interleave_buffer,
in, samples, 1);
interleave_complex(fft->bitinverse_buffer, fft->interleave_buffer, in, samples, 1);
for (step_size = 1; step_size < samples; step_size <<= 1)
{
+90
View File
@@ -0,0 +1,90 @@
/* 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/>.
*/
#ifndef RARCH_FFT_H__
#define RARCH_FFT_H__
#include <retro_inline.h>
typedef struct fft fft_t;
// C99 <complex.h> would be nice.
typedef struct
{
float real;
float imag;
} fft_complex_t;
static INLINE fft_complex_t fft_complex_mul(fft_complex_t a,
fft_complex_t b)
{
fft_complex_t out = {
a.real * b.real - a.imag * b.imag,
a.imag * b.real + a.real * b.imag,
};
return out;
}
static INLINE fft_complex_t fft_complex_add(fft_complex_t a,
fft_complex_t b)
{
fft_complex_t out = {
a.real + b.real,
a.imag + b.imag,
};
return out;
}
static INLINE fft_complex_t fft_complex_sub(fft_complex_t a,
fft_complex_t b)
{
fft_complex_t out = {
a.real - b.real,
a.imag - b.imag,
};
return out;
}
static INLINE fft_complex_t fft_complex_conj(fft_complex_t a)
{
fft_complex_t out = {
a.real, -a.imag,
};
return out;
}
fft_t *fft_new(unsigned block_size_log2);
void fft_free(fft_t *fft);
void fft_process_forward_complex(fft_t *fft,
fft_complex_t *out, const fft_complex_t *in, unsigned step);
void fft_process_forward(fft_t *fft,
fft_complex_t *out, const float *in, unsigned step);
void fft_process_inverse(fft_t *fft,
float *out, const fft_complex_t *in, unsigned step);
#endif
@@ -1,32 +1,25 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2014 - Brad Miller
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (iir.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#include <string/stdstring.h>
#define sqr(a) ((a) * (a))
@@ -67,29 +60,34 @@ static void iir_free(void *data)
static void iir_process(void *data, struct dspfilter_output *output,
const struct dspfilter_input *input)
{
float b0, b1, b2, a0, a1, a2;
float xn1_l, xn2_l, yn1_l, yn2_l;
float xn1_r, xn2_r, yn1_r, yn2_r;
unsigned i;
float *out;
struct iir_data *iir = (struct iir_data*)data;
float *out = output->samples;
float b0 = iir->b0;
float b1 = iir->b1;
float b2 = iir->b2;
float a0 = iir->a0;
float a1 = iir->a1;
float a2 = iir->a2;
output->samples = input->samples;
output->frames = input->frames;
float xn1_l = iir->l.xn1;
float xn2_l = iir->l.xn2;
float yn1_l = iir->l.yn1;
float yn2_l = iir->l.yn2;
out = output->samples;
float xn1_r = iir->r.xn1;
float xn2_r = iir->r.xn2;
float yn1_r = iir->r.yn1;
float yn2_r = iir->r.yn2;
b0 = iir->b0;
b1 = iir->b1;
b2 = iir->b2;
a0 = iir->a0;
a1 = iir->a1;
a2 = iir->a2;
output->samples = input->samples;
output->frames = input->frames;
xn1_l = iir->l.xn1;
xn2_l = iir->l.xn2;
yn1_l = iir->l.yn1;
yn2_l = iir->l.yn2;
xn1_r = iir->r.xn1;
xn2_r = iir->r.xn2;
yn1_r = iir->r.yn1;
yn2_r = iir->r.yn2;
for (i = 0; i < input->frames; i++, out += 2)
{
@@ -99,18 +97,18 @@ static void iir_process(void *data, struct dspfilter_output *output,
float l = (b0 * in_l + b1 * xn1_l + b2 * xn2_l - a1 * yn1_l - a2 * yn2_l) / a0;
float r = (b0 * in_r + b1 * xn1_r + b2 * xn2_r - a1 * yn1_r - a2 * yn2_r) / a0;
xn2_l = xn1_l;
xn1_l = in_l;
yn2_l = yn1_l;
yn1_l = l;
xn2_l = xn1_l;
xn1_l = in_l;
yn2_l = yn1_l;
yn1_l = l;
xn2_r = xn1_r;
xn1_r = in_r;
yn2_r = yn1_r;
yn1_r = r;
xn2_r = xn1_r;
xn1_r = in_r;
yn2_r = yn1_r;
yn1_r = r;
out[0] = l;
out[1] = r;
out[0] = l;
out[1] = r;
}
iir->l.xn1 = xn1_l;
@@ -124,7 +122,7 @@ static void iir_process(void *data, struct dspfilter_output *output,
iir->r.yn2 = yn2_r;
}
#define CHECK(x) if (string_is_equal(str, #x)) return x
#define CHECK(x) if (!strcmp(str, #x)) return x
static enum IIRFilter str_to_type(const char *str)
{
CHECK(LPF);
@@ -139,8 +137,7 @@ static enum IIRFilter str_to_type(const char *str)
CHECK(LSH);
CHECK(HSH);
CHECK(RIAA_CD);
return LPF; /* Fallback. */
return LPF; // Fallback.
}
static void make_poly_from_roots(
@@ -329,9 +326,9 @@ static void *iir_init(const struct dspfilter_info *info,
const struct dspfilter_config *config, void *userdata)
{
float freq, qual, gain;
enum IIRFilter filter = LPF;
char *type = NULL;
struct iir_data *iir = (struct iir_data*)calloc(1, sizeof(*iir));
enum IIRFilter filter;
char *type = NULL;
struct iir_data *iir = (struct iir_data*)calloc(1, sizeof(*iir));
if (!iir)
return NULL;
File renamed without changes.
+96
View File
@@ -0,0 +1,96 @@
/* 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 "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
struct panning_data
{
float left[2];
float right[2];
};
static void panning_free(void *data)
{
free(data);
}
static void panning_process(void *data, struct dspfilter_output *output,
const struct dspfilter_input *input)
{
unsigned i;
float *out;
struct panning_data *pan = (struct panning_data*)data;
output->samples = input->samples;
output->frames = input->frames;
out = output->samples;
for (i = 0; i < input->frames; i++, out += 2)
{
float left = out[0];
float right = out[1];
out[0] = left * pan->left[0] + right * pan->left[1];
out[1] = left * pan->right[0] + right * pan->right[1];
}
}
static void *panning_init(const struct dspfilter_info *info,
const struct dspfilter_config *config, void *userdata)
{
static const float default_left[] = { 1.0f, 0.0f };
static const float default_right[] = { 0.0f, 1.0f };
float *left = NULL, *right = NULL;
unsigned num_left = 0, num_right = 0;
struct panning_data *pan = (struct panning_data*)calloc(1, sizeof(*pan));
if (!pan)
return NULL;
config->get_float_array(userdata, "left_mix", &left, &num_left, default_left, 2);
config->get_float_array(userdata, "right_mix", &right, &num_right, default_right, 2);
memcpy(pan->left, (num_left == 2) ? left : default_left, sizeof(pan->left));
memcpy(pan->right, (num_right == 2) ? right : default_right, sizeof(pan->right));
config->free(left);
config->free(right);
return pan;
}
static const struct dspfilter_implementation panning = {
panning_init,
panning_process,
panning_free,
DSPFILTER_API_VERSION,
"Panning",
"panning",
};
#ifdef HAVE_FILTERS_BUILTIN
#define dspfilter_get_implementation panning_dspfilter_get_implementation
#endif
const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask)
{
(void)mask;
return &panning;
}
#undef dspfilter_get_implementation
@@ -1,31 +1,25 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2014 - Brad Miller
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (phaser.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#define phaserlfoshape 4.0
#define phaserlfoskipsamples 20
@@ -57,12 +51,12 @@ static void phaser_process(void *data, struct dspfilter_output *output,
{
unsigned i, c;
int s;
float m[2], tmp[2];
float m[2], tmp[2], *out;
struct phaser_data *ph = (struct phaser_data*)data;
float *out = output->samples;
output->samples = input->samples;
output->frames = input->frames;
output->samples = input->samples;
output->frames = input->frames;
out = output->samples;
for (i = 0; i < input->frames; i++, out += 2)
{
@@ -1,31 +1,24 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2014 - Brad Miller
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (reverb.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_inline.h>
#include <libretro_dspfilter.h>
struct comb
{
@@ -48,8 +41,8 @@ struct allpass
static INLINE float comb_process(struct comb *c, float input)
{
float output = c->buffer[c->bufidx];
c->filterstore = (output * c->damp2) + (c->filterstore * c->damp1);
float output = c->buffer[c->bufidx];
c->filterstore = (output * c->damp2) + (c->filterstore * c->damp1);
c->buffer[c->bufidx] = input + (c->filterstore * c->feedback);
@@ -63,8 +56,8 @@ static INLINE float comb_process(struct comb *c, float input)
static INLINE float allpass_process(struct allpass *a, float input)
{
float bufout = a->buffer[a->bufidx];
float output = -input + bufout;
float bufout = a->buffer[a->bufidx];
float output = -input + bufout;
a->buffer[a->bufidx] = input + bufout * a->feedback;
a->bufidx++;
@@ -136,9 +129,8 @@ static float revmodel_process(struct revmodel *rev, float in)
{
int i;
float mono_out = 0.0f;
float mono_in = in;
float input = mono_in * rev->gain;
float mono_in = in;
float input = mono_in * rev->gain;
for (i = 0; i < numcombs; i++)
mono_out += comb_process(&rev->combL[i], input);
@@ -212,19 +204,19 @@ static void revmodel_setmode(struct revmodel *rev, float value)
static void revmodel_init(struct revmodel *rev)
{
rev->combL[0].buffer = rev->bufcombL1; rev->combL[0].bufsize = combtuningL1;
rev->combL[1].buffer = rev->bufcombL2; rev->combL[1].bufsize = combtuningL2;
rev->combL[2].buffer = rev->bufcombL3; rev->combL[2].bufsize = combtuningL3;
rev->combL[3].buffer = rev->bufcombL4; rev->combL[3].bufsize = combtuningL4;
rev->combL[4].buffer = rev->bufcombL5; rev->combL[4].bufsize = combtuningL5;
rev->combL[5].buffer = rev->bufcombL6; rev->combL[5].bufsize = combtuningL6;
rev->combL[6].buffer = rev->bufcombL7; rev->combL[6].bufsize = combtuningL7;
rev->combL[7].buffer = rev->bufcombL8; rev->combL[7].bufsize = combtuningL8;
rev->combL[0].buffer = rev->bufcombL1; rev->combL[0].bufsize = combtuningL1;
rev->combL[1].buffer = rev->bufcombL2; rev->combL[1].bufsize = combtuningL2;
rev->combL[2].buffer = rev->bufcombL3; rev->combL[2].bufsize = combtuningL3;
rev->combL[3].buffer = rev->bufcombL4; rev->combL[3].bufsize = combtuningL4;
rev->combL[4].buffer = rev->bufcombL5; rev->combL[4].bufsize = combtuningL5;
rev->combL[5].buffer = rev->bufcombL6; rev->combL[5].bufsize = combtuningL6;
rev->combL[6].buffer = rev->bufcombL7; rev->combL[6].bufsize = combtuningL7;
rev->combL[7].buffer = rev->bufcombL8; rev->combL[7].bufsize = combtuningL8;
rev->allpassL[0].buffer = rev->bufallpassL1; rev->allpassL[0].bufsize = allpasstuningL1;
rev->allpassL[1].buffer = rev->bufallpassL2; rev->allpassL[1].bufsize = allpasstuningL2;
rev->allpassL[2].buffer = rev->bufallpassL3; rev->allpassL[2].bufsize = allpasstuningL3;
rev->allpassL[3].buffer = rev->bufallpassL4; rev->allpassL[3].bufsize = allpasstuningL4;
rev->allpassL[0].buffer = rev->bufallpassL1; rev->allpassL[0].bufsize = allpasstuningL1;
rev->allpassL[1].buffer = rev->bufallpassL2; rev->allpassL[1].bufsize = allpasstuningL2;
rev->allpassL[2].buffer = rev->bufallpassL3; rev->allpassL[2].bufsize = allpasstuningL3;
rev->allpassL[3].buffer = rev->bufallpassL4; rev->allpassL[3].bufsize = allpasstuningL4;
rev->allpassL[0].feedback = 0.5f;
rev->allpassL[1].feedback = 0.5f;
@@ -1,31 +1,25 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2014 - Brad Miller
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (wahwah.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#include "dspfilter.h"
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <retro_miscellaneous.h>
#include <libretro_dspfilter.h>
#define WAHWAH_LFO_SKIP_SAMPLES 30
@@ -54,11 +48,12 @@ static void wahwah_process(void *data, struct dspfilter_output *output,
const struct dspfilter_input *input)
{
unsigned i;
float *out;
struct wahwah_data *wah = (struct wahwah_data*)data;
float *out = output->samples;
output->samples = input->samples;
output->frames = input->frames;
out = output->samples;
for (i = 0; i < input->frames; i++, out += 2)
{
@@ -118,7 +113,7 @@ static void *wahwah_init(const struct dspfilter_info *info,
config->get_float(userdata, "resonance", &wah->res, 2.5f);
wah->lfoskip = wah->freq * 2.0 * M_PI / info->input_rate;
wah->phase = wah->startphase * M_PI / 180.0;
wah->phase = wah->startphase * M_PI / 180.0;
return wah;
}
@@ -137,8 +132,7 @@ static const struct dspfilter_implementation wahwah_plug = {
#define dspfilter_get_implementation wahwah_dspfilter_get_implementation
#endif
const struct dspfilter_implementation *
dspfilter_get_implementation(dspfilter_simd_mask_t mask)
const struct dspfilter_implementation *dspfilter_get_implementation(dspfilter_simd_mask_t mask)
{
(void)mask;
return &wahwah_plug;
@@ -1,38 +1,35 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* 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.
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (audio_resampler.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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 <string/stdstring.h>
#include <features/features_cpu.h>
#include <file/config_file_userdata.h>
#include <string/stdstring.h>
#include <audio/audio_resampler.h>
static const retro_resampler_t *resampler_drivers[] = {
&sinc_resampler,
#ifdef HAVE_CC_RESAMPLER
&CC_resampler,
#include "audio_resampler_driver.h"
#ifdef RARCH_INTERNAL
#include "../performance.h"
#endif
#ifndef DONT_HAVE_STRING_LIST
#include "../string_list_special.h"
#endif
static const rarch_resampler_t *resampler_drivers[] = {
&sinc_resampler,
&CC_resampler,
&nearest_resampler,
&null_resampler,
NULL,
@@ -90,12 +87,26 @@ const void *audio_resampler_driver_find_handle(int idx)
**/
const char *audio_resampler_driver_find_ident(int idx)
{
const retro_resampler_t *drv = resampler_drivers[idx];
const rarch_resampler_t *drv = resampler_drivers[idx];
if (!drv)
return NULL;
return drv->ident;
}
#ifndef DONT_HAVE_STRING_LIST
/**
* config_get_audio_resampler_driver_options:
*
* Get an enumerated list of all resampler driver names, separated by '|'.
*
* Returns: string listing of all resampler driver names, separated by '|'.
**/
const char* config_get_audio_resampler_driver_options(void)
{
return char_list_new_special(STRING_LIST_AUDIO_RESAMPLER_DRIVERS, NULL);
}
#endif
/**
* find_resampler_driver:
* @ident : Identifier of resampler driver to find.
@@ -105,7 +116,7 @@ const char *audio_resampler_driver_find_ident(int idx)
* Returns: resampler driver if resampler driver was found, otherwise
* NULL.
**/
static const retro_resampler_t *find_resampler_driver(const char *ident)
static const rarch_resampler_t *find_resampler_driver(const char *ident)
{
int i = find_resampler_driver_index(ident);
@@ -115,6 +126,28 @@ static const retro_resampler_t *find_resampler_driver(const char *ident)
return resampler_drivers[0];
}
#ifndef RARCH_INTERNAL
#ifdef __cplusplus
extern "C" {
#endif
retro_get_cpu_features_t perf_get_cpu_features_cb;
#ifdef __cplusplus
}
#endif
#endif
static resampler_simd_mask_t resampler_get_cpu_features(void)
{
#ifdef RARCH_INTERNAL
return retro_get_cpu_features();
#else
return perf_get_cpu_features_cb();
#endif
}
/**
* resampler_append_plugs:
* @re : Resampler handle
@@ -126,10 +159,10 @@ static const retro_resampler_t *find_resampler_driver(const char *ident)
* Returns: true (1) if successfully initialized, otherwise false (0).
**/
static bool resampler_append_plugs(void **re,
const retro_resampler_t **backend,
const rarch_resampler_t **backend,
double bw_ratio)
{
resampler_simd_mask_t mask = (resampler_simd_mask_t)cpu_features_get();
resampler_simd_mask_t mask = resampler_get_cpu_features();
*re = (*backend)->init(&resampler_config, bw_ratio, mask);
@@ -139,7 +172,7 @@ static bool resampler_append_plugs(void **re,
}
/**
* retro_resampler_realloc:
* rarch_resampler_realloc:
* @re : Resampler handle
* @backend : Resampler backend that is about to be set.
* @ident : Identifier name for resampler we want.
@@ -150,7 +183,7 @@ static bool resampler_append_plugs(void **re,
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
const char *ident, double bw_ratio)
{
if (*re && *backend)
@@ -160,11 +193,12 @@ bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
*backend = find_resampler_driver(ident);
if (!resampler_append_plugs(re, backend, bw_ratio))
{
if (!*re)
*backend = NULL;
return false;
}
goto error;
return true;
error:
if (!*re)
*backend = NULL;
return false;
}
@@ -1,35 +1,33 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* 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.
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (audio_resampler.h).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* You should have received a copy of the GNU General Public License along with RetroArch.
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __LIBRETRO_SDK_AUDIO_RESAMPLER_DRIVER_H
#define __LIBRETRO_SDK_AUDIO_RESAMPLER_DRIVER_H
#include <stdint.h>
#ifndef __AUDIO_RESAMPLER_DRIVER_H
#define __AUDIO_RESAMPLER_DRIVER_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stddef.h>
#include <stdint.h>
#include <math.h>
#include <boolean.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
#include <retro_miscellaneous.h>
#define RESAMPLER_SIMD_SSE (1 << 0)
#define RESAMPLER_SIMD_SSE2 (1 << 1)
@@ -116,7 +114,7 @@ typedef void (*resampler_free_t)(void *data);
/* Processes input data. */
typedef void (*resampler_process_t)(void *_data, struct resampler_data *data);
typedef struct retro_resampler
typedef struct rarch_resampler
{
resampler_init_t init;
resampler_process_t process;
@@ -131,7 +129,7 @@ typedef struct retro_resampler
/* Computer-friendly short version of ident.
* Lower case, no spaces and special characters, etc. */
const char *short_ident;
} retro_resampler_t;
} rarch_resampler_t;
typedef struct audio_frame_float
{
@@ -139,12 +137,21 @@ typedef struct audio_frame_float
float r;
} audio_frame_float_t;
extern retro_resampler_t sinc_resampler;
#ifdef HAVE_CC_RESAMPLER
extern retro_resampler_t CC_resampler;
extern rarch_resampler_t sinc_resampler;
extern rarch_resampler_t CC_resampler;
extern rarch_resampler_t nearest_resampler;
extern rarch_resampler_t null_resampler;
#ifndef DONT_HAVE_STRING_LIST
/**
* config_get_audio_resampler_driver_options:
*
* Get an enumerated list of all resampler driver names, separated by '|'.
*
* Returns: string listing of all resampler driver names, separated by '|'.
**/
const char* config_get_audio_resampler_driver_options(void);
#endif
extern retro_resampler_t nearest_resampler;
extern retro_resampler_t null_resampler;
/**
* audio_resampler_driver_find_handle:
@@ -165,7 +172,7 @@ const void *audio_resampler_driver_find_handle(int index);
const char *audio_resampler_driver_find_ident(int index);
/**
* retro_resampler_realloc:
* rarch_resampler_realloc:
* @re : Resampler handle
* @backend : Resampler backend that is about to be set.
* @ident : Identifier name for resampler we want.
@@ -176,9 +183,31 @@ const char *audio_resampler_driver_find_ident(int index);
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool retro_resampler_realloc(void **re, const retro_resampler_t **backend,
bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend,
const char *ident, double bw_ratio);
RETRO_END_DECLS
/* Convenience macros.
* freep makes sure to set handles to NULL to avoid double-free
* in rarch_resampler_realloc. */
#define rarch_resampler_freep(backend, handle) do { \
if (*(backend) && *(handle)) \
(*backend)->free(*handle); \
*backend = NULL; \
*handle = NULL; \
} while(0)
#define rarch_resampler_process(backend, handle, data) do { \
(backend)->process(handle, data); \
} while(0)
#ifndef RARCH_INTERNAL
#include "libretro.h"
extern retro_get_cpu_features_t perf_get_cpu_features_cb;
#endif
#ifdef __cplusplus
}
#endif
#endif
+14 -21
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -17,10 +17,11 @@
#include <stdlib.h>
#include <string.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include <rthreads/rthreads.h>
#include "audio_thread_wrapper.h"
#include "../performance.h"
#include "../verbosity.h"
typedef struct audio_thread
@@ -35,17 +36,14 @@ typedef struct audio_thread
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)
@@ -56,8 +54,7 @@ static void audio_thread_loop(void *data)
return;
RARCH_LOG("[Audio Thread]: Initializing audio driver.\n");
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency,
thr->block_frames, thr->new_rate);
thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency);
slock_lock(thr->lock);
thr->inited = thr->driver_data ? 1 : -1;
if (thr->inited > 0 && thr->driver->use_float)
@@ -84,8 +81,8 @@ static void audio_thread_loop(void *data)
if (!thr->alive)
{
scond_signal(thr->cond);
thr->stopped_ack = true;
slock_unlock(thr->lock);
thr->stopped_ack = true;
break;
}
@@ -101,11 +98,11 @@ static void audio_thread_loop(void *data)
scond_wait(thr->cond, thr->lock);
}
thr->driver->start(thr->driver_data, thr->is_shutdown);
thr->driver->start(thr->driver_data);
}
slock_unlock(thr->lock);
audio_driver_callback();
audio_driver_ctl(RARCH_AUDIO_CTL_CALLBACK, NULL);
}
RARCH_LOG("[Audio Thread]: Tearing down driver.\n");
@@ -193,22 +190,21 @@ static bool audio_thread_stop(void *data)
audio_thread_block(thr);
thr->is_paused = true;
audio_driver_disable_callback();
audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE, NULL);
return true;
}
static bool audio_thread_start(void *data, bool is_shutdown)
static bool audio_thread_start(void *data)
{
audio_thread_t *thr = (audio_thread_t*)data;
if (!thr)
return false;
audio_driver_enable_callback();
audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE, NULL);
thr->is_paused = false;
thr->is_shutdown = is_shutdown;
thr->is_paused = false;
audio_thread_unblock(thr);
return true;
@@ -264,7 +260,7 @@ static const audio_driver_t audio_thread = {
};
/**
* audio_init_thread:
* rarch_threaded_audio_init:
* @out_driver : output driver
* @out_data : output audio data
* @device : audio device (optional)
@@ -279,10 +275,9 @@ static const audio_driver_t audio_thread = {
*
* Returns: true (1) if successful, otherwise false (0).
**/
bool audio_init_thread(const audio_driver_t **out_driver,
bool rarch_threaded_audio_init(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)
unsigned latency, const audio_driver_t *drv)
{
audio_thread_t *thr = (audio_thread_t*)calloc(1, sizeof(*thr));
if (!thr)
@@ -291,9 +286,7 @@ bool audio_init_thread(const audio_driver_t **out_driver,
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;
+4 -6
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -22,12 +22,11 @@
#include "audio_driver.h"
/**
* audio_init_thread:
* rarch_threaded_audio_init:
* @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
*
@@ -37,9 +36,8 @@
*
* 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,
bool rarch_threaded_audio_init(const audio_driver_t **out_driver, void **out_data,
const char *device, unsigned out_rate, unsigned latency,
const audio_driver_t *driver);
#endif
+435
View File
@@ -0,0 +1,435 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2014-2016 - Ali Bouhlel ( [email protected] )
*
* 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 <boolean.h>
#include "audio_utils.h"
#if defined(__SSE2__)
#include <emmintrin.h>
#elif defined(__ALTIVEC__)
#include <altivec.h>
#endif
#ifdef RARCH_INTERNAL
#include "../performance.h"
#endif
/**
* audio_convert_s16_to_float_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* C implementation callback function.
**/
void audio_convert_s16_to_float_C(float *out,
const int16_t *in, size_t samples, float gain)
{
size_t i;
gain = gain / 0x8000;
for (i = 0; i < samples; i++)
out[i] = (float)in[i] * gain;
}
/**
* audio_convert_float_to_s16_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* C implementation callback function.
**/
void audio_convert_float_to_s16_C(int16_t *out,
const float *in, size_t samples)
{
size_t i;
for (i = 0; i < samples; i++)
{
int32_t val = (int32_t)(in[i] * 0x8000);
out[i] = (val > 0x7FFF) ? 0x7FFF :
(val < -0x8000 ? -0x8000 : (int16_t)val);
}
}
#if defined(__SSE2__)
/**
* audio_convert_s16_to_float_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* SSE2 implementation callback function.
**/
void audio_convert_s16_to_float_SSE2(float *out,
const int16_t *in, size_t samples, float gain)
{
size_t i;
float fgain = gain / UINT32_C(0x80000000);
__m128 factor = _mm_set1_ps(fgain);
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{
__m128i input = _mm_loadu_si128((const __m128i *)in);
__m128i regs_l = _mm_unpacklo_epi16(_mm_setzero_si128(), input);
__m128i regs_r = _mm_unpackhi_epi16(_mm_setzero_si128(), input);
__m128 output_l = _mm_mul_ps(_mm_cvtepi32_ps(regs_l), factor);
__m128 output_r = _mm_mul_ps(_mm_cvtepi32_ps(regs_r), factor);
_mm_storeu_ps(out + 0, output_l);
_mm_storeu_ps(out + 4, output_r);
}
audio_convert_s16_to_float_C(out, in, samples - i, gain);
}
/**
* audio_convert_float_to_s16_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* SSE2 implementation callback function.
**/
void audio_convert_float_to_s16_SSE2(int16_t *out,
const float *in, size_t samples)
{
size_t i;
__m128 factor = _mm_set1_ps((float)0x8000);
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{
__m128 input_l = _mm_loadu_ps(in + 0);
__m128 input_r = _mm_loadu_ps(in + 4);
__m128 res_l = _mm_mul_ps(input_l, factor);
__m128 res_r = _mm_mul_ps(input_r, factor);
__m128i ints_l = _mm_cvtps_epi32(res_l);
__m128i ints_r = _mm_cvtps_epi32(res_r);
__m128i packed = _mm_packs_epi32(ints_l, ints_r);
_mm_storeu_si128((__m128i *)out, packed);
}
audio_convert_float_to_s16_C(out, in, samples - i);
}
#elif defined(__ALTIVEC__)
/**
* audio_convert_s16_to_float_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* AltiVec implementation callback function.
**/
void audio_convert_s16_to_float_altivec(float *out,
const int16_t *in, size_t samples, float gain)
{
size_t samples_in = samples;
/* Unaligned loads/store is a bit expensive, so we
* optimize for the good path (very likely). */
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
{
size_t i;
const vector float gain_vec = { gain, gain , gain, gain };
const vector float zero_vec = { 0.0f, 0.0f, 0.0f, 0.0f};
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{
vector signed short input = vec_ld(0, in);
vector signed int hi = vec_unpackh(input);
vector signed int lo = vec_unpackl(input);
vector float out_hi = vec_madd(vec_ctf(hi, 15), gain_vec, zero_vec);
vector float out_lo = vec_madd(vec_ctf(lo, 15), gain_vec, zero_vec);
vec_st(out_hi, 0, out);
vec_st(out_lo, 16, out);
}
samples_in -= i;
}
audio_convert_s16_to_float_C(out, in, samples_in, gain);
}
/**
* audio_convert_float_to_s16_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* AltiVec implementation callback function.
**/
void audio_convert_float_to_s16_altivec(int16_t *out,
const float *in, size_t samples)
{
int samples_in = samples;
/* Unaligned loads/store is a bit expensive,
* so we optimize for the good path (very likely). */
if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0)
{
size_t i;
for (i = 0; i + 8 <= samples; i += 8, in += 8, out += 8)
{
vector float input0 = vec_ld( 0, in);
vector float input1 = vec_ld(16, in);
vector signed int result0 = vec_cts(input0, 15);
vector signed int result1 = vec_cts(input1, 15);
vec_st(vec_packs(result0, result1), 0, out);
}
samples_in -= i;
}
audio_convert_float_to_s16_C(out, in, samples_in);
}
#elif defined(__ARM_NEON__) && !defined(VITA)
/* Avoid potential hard-float/soft-float ABI issues. */
void audio_convert_s16_float_asm(float *out, const int16_t *in,
size_t samples, const float *gain);
/**
* audio_convert_s16_to_float_neon:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* ARM NEON implementation callback function.
**/
static void audio_convert_s16_to_float_neon(float *out,
const int16_t *in, size_t samples, float gain)
{
size_t aligned_samples = samples & ~7;
if (aligned_samples)
audio_convert_s16_float_asm(out, in, aligned_samples, &gain);
/* Could do all conversion in ASM, but keep it simple for now. */
audio_convert_s16_to_float_C(out + aligned_samples, in + aligned_samples,
samples - aligned_samples, gain);
}
void audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples);
/**
* audio_convert_float_to_s16_neon:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* ARM NEON implementation callback function.
**/
static void audio_convert_float_to_s16_neon(int16_t *out,
const float *in, size_t samples)
{
size_t aligned_samples = samples & ~7;
if (aligned_samples)
audio_convert_float_s16_asm(out, in, aligned_samples);
audio_convert_float_to_s16_C(out + aligned_samples, in + aligned_samples,
samples - aligned_samples);
}
#elif defined(_MIPS_ARCH_ALLEGREX)
/**
* audio_convert_s16_to_float_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_s16_to_float_ALLEGREX(float *out,
const int16_t *in, size_t samples, float gain)
{
#ifdef DEBUG
/* Make sure the buffer is 16 byte aligned, this should be the
* default behaviour of malloc in the PSPSDK.
* Only the output buffer can be assumed to be 16-byte aligned. */
retro_assert(((uintptr_t)out & 0xf) == 0);
#endif
size_t i;
gain = gain / 0x8000;
__asm__ (
".set push \n"
".set noreorder \n"
"mtv %0, s200 \n"
".set pop \n"
::"r"(gain));
for (i = 0; i + 16 <= samples; i += 16)
{
__asm__ (
".set push \n"
".set noreorder \n"
"lv.s s100, 0(%0) \n"
"lv.s s101, 4(%0) \n"
"lv.s s110, 8(%0) \n"
"lv.s s111, 12(%0) \n"
"lv.s s120, 16(%0) \n"
"lv.s s121, 20(%0) \n"
"lv.s s130, 24(%0) \n"
"lv.s s131, 28(%0) \n"
"vs2i.p c100, c100 \n"
"vs2i.p c110, c110 \n"
"vs2i.p c120, c120 \n"
"vs2i.p c130, c130 \n"
"vi2f.q c100, c100, 16 \n"
"vi2f.q c110, c110, 16 \n"
"vi2f.q c120, c120, 16 \n"
"vi2f.q c130, c130, 16 \n"
"vmscl.q e100, e100, s200 \n"
"sv.q c100, 0(%1) \n"
"sv.q c110, 16(%1) \n"
"sv.q c120, 32(%1) \n"
"sv.q c130, 48(%1) \n"
".set pop \n"
:: "r"(in + i), "r"(out + i));
}
for (; i < samples; i++)
out[i] = (float)in[i] * gain;
}
/**
* audio_convert_float_to_s16_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
const float *in, size_t samples)
{
size_t i;
#ifdef DEBUG
/* Make sure the buffers are 16 byte aligned, this should be
* the default behaviour of malloc in the PSPSDK.
* Both buffers are allocated by RetroArch, so can assume alignment. */
retro_assert(((uintptr_t)in & 0xf) == 0);
retro_assert(((uintptr_t)out & 0xf) == 0);
#endif
for (i = 0; i + 8 <= samples; i += 8)
{
__asm__ (
".set push \n"
".set noreorder \n"
"lv.q c100, 0(%0) \n"
"lv.q c110, 16(%0) \n"
"vf2in.q c100, c100, 31 \n"
"vf2in.q c110, c110, 31 \n"
"vi2s.q c100, c100 \n"
"vi2s.q c102, c110 \n"
"sv.q c100, 0(%1) \n"
".set pop \n"
:: "r"(in + i), "r"(out + i));
}
for (; i < samples; i++)
{
int32_t val = (int32_t)(in[i] * 0x8000);
out[i] = (val > 0x7FFF) ? 0x7FFF :
(val < -0x8000 ? -0x8000 : (int16_t)val);
}
}
#endif
#ifndef RARCH_INTERNAL
#ifdef __cplusplus
extern "C" {
#endif
retro_get_cpu_features_t perf_get_cpu_features_cb;
#ifdef __cplusplus
}
#endif
#endif
static unsigned audio_convert_get_cpu_features(void)
{
#ifdef RARCH_INTERNAL
return retro_get_cpu_features();
#else
return perf_get_cpu_features_cb();
#endif
}
/**
* audio_convert_init_simd:
*
* Sets up function pointers for audio conversion
* functions based on CPU features.
**/
void audio_convert_init_simd(void)
{
unsigned cpu = audio_convert_get_cpu_features();
(void)cpu;
#if defined(__ARM_NEON__) && !defined(VITA)
audio_convert_s16_to_float_arm = (cpu & RETRO_SIMD_NEON) ?
audio_convert_s16_to_float_neon : audio_convert_s16_to_float_C;
audio_convert_float_to_s16_arm = (cpu & RETRO_SIMD_NEON) ?
audio_convert_float_to_s16_neon : audio_convert_float_to_s16_C;
#endif
}
+184
View File
@@ -0,0 +1,184 @@
/* 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/>.
*/
#ifndef AUDIO_UTILS_H
#define AUDIO_UTILS_H
#ifdef __cplusplus
extern "C" {
#endif
#include <stdint.h>
#include <stddef.h>
#ifdef HAVE_CONFIG_H
#include "../config.h"
#endif
#if defined(__SSE2__)
#define audio_convert_s16_to_float audio_convert_s16_to_float_SSE2
#define audio_convert_float_to_s16 audio_convert_float_to_s16_SSE2
/**
* audio_convert_s16_to_float_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* SSE2 implementation callback function.
**/
void audio_convert_s16_to_float_SSE2(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_SSE2:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* SSE2 implementation callback function.
**/
void audio_convert_float_to_s16_SSE2(int16_t *out,
const float *in, size_t samples);
#elif defined(__ALTIVEC__)
#define audio_convert_s16_to_float audio_convert_s16_to_float_altivec
#define audio_convert_float_to_s16 audio_convert_float_to_s16_altivec
/**
* audio_convert_s16_to_float_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* AltiVec implementation callback function.
**/
void audio_convert_s16_to_float_altivec(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_altivec:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* AltiVec implementation callback function.
**/
void audio_convert_float_to_s16_altivec(int16_t *out,
const float *in, size_t samples);
#elif defined(__ARM_NEON__) && !defined(VITA)
#define audio_convert_s16_to_float audio_convert_s16_to_float_arm
#define audio_convert_float_to_s16 audio_convert_float_to_s16_arm
void (*audio_convert_s16_to_float_arm)(float *out,
const int16_t *in, size_t samples, float gain);
void (*audio_convert_float_to_s16_arm)(int16_t *out,
const float *in, size_t samples);
#elif defined(_MIPS_ARCH_ALLEGREX)
#define audio_convert_s16_to_float audio_convert_s16_to_float_ALLEGREX
#define audio_convert_float_to_s16 audio_convert_float_to_s16_ALLEGREX
/**
* audio_convert_s16_to_float_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_s16_to_float_ALLEGREX(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_ALLEGREX:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* MIPS ALLEGREX implementation callback function.
**/
void audio_convert_float_to_s16_ALLEGREX(int16_t *out,
const float *in, size_t samples);
#else
#define audio_convert_s16_to_float audio_convert_s16_to_float_C
#define audio_convert_float_to_s16 audio_convert_float_to_s16_C
#endif
/**
* audio_convert_s16_to_float_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
* @gain : gain applied to the audio volume
*
* Converts audio samples from signed integer 16-bit
* to floating point.
*
* C implementation callback function.
**/
void audio_convert_s16_to_float_C(float *out,
const int16_t *in, size_t samples, float gain);
/**
* audio_convert_float_to_s16_C:
* @out : output buffer
* @in : input buffer
* @samples : size of samples to be converted
*
* Converts audio samples from floating point
* to signed integer 16-bit.
*
* C implementation callback function.
**/
void audio_convert_float_to_s16_C(int16_t *out,
const float *in, size_t samples);
/**
* audio_convert_init_simd:
*
* Sets up function pointers for audio conversion
* functions based on CPU features.
**/
void audio_convert_init_simd(void);
#ifdef __cplusplus
}
#endif
#endif
+98
View File
@@ -0,0 +1,98 @@
/* 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/>.
*/
#if defined(__ARM_NEON__)
#ifndef __MACH__
.arm
#endif
.align 4
.globl audio_convert_s16_float_asm
.globl _audio_convert_s16_float_asm
# audio_convert_s16_float_asm(float *out, const int16_t *in, size_t samples, const float *gain)
audio_convert_s16_float_asm:
_audio_convert_s16_float_asm:
# Hacky way to get a constant of 2^-15.
# Might be faster to just load a constant from memory.
# It's just done once however ...
vmov.f32 q8, #0.25
vmul.f32 q8, q8, q8
vmul.f32 q8, q8, q8
vmul.f32 q8, q8, q8
vadd.f32 q8, q8, q8
# Apply gain
vld1.f32 {d6[0]}, [r3]
vmul.f32 q8, q8, d6[0]
1:
# Preload here?
vld1.s16 {q0}, [r1]!
# Widen to 32-bit
vmovl.s16 q1, d0
vmovl.s16 q2, d1
# Convert to float
vcvt.f32.s32 q1, q1
vcvt.f32.s32 q2, q2
vmul.f32 q1, q1, q8
vmul.f32 q2, q2, q8
vst1.f32 {q1-q2}, [r0]!
# Guaranteed to get samples in multiples of 8.
subs r2, r2, #8
bne 1b
bx lr
.align 4
.globl audio_convert_float_s16_asm
.globl _audio_convert_float_s16_asm
# audio_convert_float_s16_asm(int16_t *out, const float *in, size_t samples)
audio_convert_float_s16_asm:
_audio_convert_float_s16_asm:
# Hacky way to get a constant of 2^15.
# ((2^4)^2)^2 * 0.5 = 2^15
vmov.f32 q8, #16.0
vmov.f32 q9, #0.5
vmul.f32 q8, q8, q8
vmul.f32 q8, q8, q8
vmul.f32 q8, q8, q9
1:
# Preload here?
vld1.f32 {q0-q1}, [r1]!
vmul.f32 q0, q0, q8
vmul.f32 q1, q1, q8
vcvt.s32.f32 q0, q0
vcvt.s32.f32 q1, q1
vqmovn.s32 d4, q0
vqmovn.s32 d5, q1
vst1.f32 {d4-d5}, [r0]!
# Guaranteed to get samples in multiples of 8.
subs r2, r2, #8
bne 1b
bx lr
#endif
+76 -157
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -16,12 +15,10 @@
#include <stdlib.h>
#include <lists/string_list.h>
#include <string/stdstring.h>
#include <alsa/asoundlib.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
typedef struct alsa
@@ -29,7 +26,6 @@ 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;
@@ -47,28 +43,27 @@ static bool find_float_format(snd_pcm_t *pcm, void *data)
if (snd_pcm_hw_params_test_format(pcm, params, SND_PCM_FORMAT_FLOAT) == 0)
{
RARCH_LOG("[ALSA]: Using floating point format.\n");
RARCH_LOG("ALSA: Using floating point format.\n");
return true;
}
RARCH_LOG("[ALSA]: Using signed 16-bit format.\n");
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)
static void *alsa_init(const char *device, unsigned rate, unsigned latency)
{
snd_pcm_format_t format;
snd_pcm_uframes_t buffer_size;
snd_pcm_hw_params_t *params = NULL;
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));
unsigned latency_usec = latency * 1000;
unsigned channels = 2;
unsigned periods = 4;
const char *alsa_dev = "default";
alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
if (!alsa)
return NULL;
@@ -93,23 +88,15 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency,
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)
if (snd_pcm_hw_params_set_rate(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;
@@ -126,17 +113,17 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency,
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);
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);
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");
RARCH_LOG("ALSA: Can pause: %s.\n", alsa->can_pause ? "yes" : "no");
if (snd_pcm_sw_params_malloc(&sw_params) < 0)
goto error;
@@ -157,7 +144,7 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency,
return alsa;
error:
RARCH_ERR("[ALSA]: Failed to initialize...\n");
RARCH_ERR("ALSA: Failed to initialize...\n");
if (params)
snd_pcm_hw_params_free(params);
@@ -167,92 +154,80 @@ error:
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 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_;
bool eagain_retry = true;
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);
snd_pcm_sframes_t size = snd_pcm_bytes_to_frames(alsa->pcm, size_);
if (alsa->nonblock)
while (size)
{
while (size)
snd_pcm_sframes_t frames;
if (!alsa->nonblock)
{
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)
{
RARCH_ERR("[ALSA]: (#1) Failed to recover from error (%s)\n",
snd_strerror(rc));
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;
}
frames = snd_pcm_writei(alsa->pcm, buf, size);
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));
return -1;
}
break;
}
else if (frames == -EAGAIN && !alsa->nonblock)
{
/* Definitely not supposed to happen. */
RARCH_WARN("[ALSA]: poll() was signaled, but EAGAIN returned from write.\n"
"Your ALSA driver might be subtly broken.\n");
if (eagain_retry)
{
eagain_retry = false;
continue;
}
return written;
}
else if (frames == -EAGAIN) /* Expected if we're running nonblock. */
return written;
else if (frames < 0)
{
RARCH_ERR("[ALSA]: Unknown error occured (%s).\n",
snd_strerror(frames));
return -1;
}
written += frames;
buf += (frames << 1) *
(alsa->has_float ? sizeof(float) : sizeof(int16_t));
size -= frames;
}
return written;
@@ -290,7 +265,7 @@ static void alsa_set_nonblock_state(void *data, bool state)
alsa->nonblock = state;
}
static bool alsa_start(void *data, bool is_shutdown)
static bool alsa_start(void *data)
{
alsa_t *alsa = (alsa_t*)data;
@@ -321,22 +296,26 @@ static void alsa_free(void *data)
{
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;
alsa_t *alsa = (alsa_t*)data;
snd_pcm_sframes_t avail = snd_pcm_avail(alsa->pcm);
if (avail < 0)
{
#if 0
RARCH_WARN("[ALSA]: snd_pcm_avail() failed: %s\n",
snd_strerror(avail));
#endif
return alsa->buffer_size;
}
return FRAMES_TO_BYTES(avail, alsa->frame_bits);
return snd_pcm_frames_to_bytes(alsa->pcm, avail);
}
static size_t alsa_buffer_size(void *data)
@@ -345,64 +324,6 @@ static size_t alsa_buffer_size(void *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 != NULL)
{
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_fast(io, "Output", 6)))
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,
@@ -413,8 +334,6 @@ audio_driver_t audio_alsa = {
alsa_free,
alsa_use_float,
"alsa",
alsa_device_list_new,
alsa_device_list_free,
alsa_write_avail,
alsa_buffer_size,
};
+12 -14
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -17,9 +17,9 @@
#define ALSA_PCM_NEW_HW_PARAMS_API
#define ALSA_PCM_NEW_SW_PARAMS_API
#include <sys/asoundlib.h>
#include <retro_math.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#define MAX_FRAG_SIZE 3072
#define DEFAULT_RATE 48000
@@ -46,14 +46,14 @@ typedef struct alsa
typedef long snd_pcm_sframes_t;
static void *alsa_qsa_init(const char *device,
unsigned rate, unsigned latency, unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
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_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
snd_pcm_channel_info_t pi;
snd_pcm_channel_setup_t setup = {0};
settings_t *settings = config_get_ptr();
alsa_t *alsa = (alsa_t*)calloc(1, sizeof(alsa_t));
if (!alsa)
return NULL;
@@ -122,8 +122,8 @@ static void *alsa_qsa_init(const char *device,
goto error;
}
if (block_frames)
alsa->buf_size = block_frames * 4;
if (settings->audio.block_frames)
alsa->buf_size = settings->audio.block_frames * 4;
else
alsa->buf_size = next_pow2(32 * latency);
@@ -164,9 +164,9 @@ error:
static int check_pcm_status(void *data, int channel_type)
{
snd_pcm_channel_status_t status;
alsa_t *alsa = (alsa_t*)data;
int ret = EOK;
snd_pcm_channel_status_t status;
int ret = EOK;
memset(&status, 0, sizeof (status));
status.channel = channel_type;
@@ -291,7 +291,7 @@ static bool alsa_qsa_alive(void *data)
return false;
}
static bool alsa_qsa_start(void *data, bool is_shutdown)
static bool alsa_qsa_start(void *data)
{
alsa_t *alsa = (alsa_t*)data;
@@ -377,8 +377,6 @@ audio_driver_t audio_alsa = {
alsa_qsa_free,
alsa_qsa_use_float,
"alsa",
NULL,
NULL,
alsa_qsa_write_avail,
alsa_qsa_buffer_size,
};
+21 -84
View File
@@ -16,19 +16,18 @@
#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 <queues/fifo_buffer.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#define TRY_ALSA(x) if (x < 0) \
goto error;
#define TRY_ALSA(x) if (x < 0) { \
goto error; \
}
typedef struct alsa_thread
{
@@ -52,8 +51,8 @@ typedef struct alsa_thread
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);
uint8_t *buf = (uint8_t *)calloc(1, alsa->period_size);
if (!buf)
{
RARCH_ERR("failed to allocate audio buffer");
@@ -91,7 +90,7 @@ static void alsa_worker_thread(void *data)
}
else if (frames < 0)
{
RARCH_ERR("[ALSA]: Unknown error occurred (%s).\n",
RARCH_ERR("[ALSA]: Unknown error occured (%s).\n",
snd_strerror(frames));
break;
}
@@ -131,9 +130,7 @@ static void alsa_thread_free(void *data)
{
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)
@@ -154,20 +151,21 @@ static void alsa_thread_free(void *data)
}
static void *alsa_thread_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
alsa_thread_t *alsa = (alsa_thread_t*)calloc(1, sizeof(alsa_thread_t));
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;
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;
@@ -284,8 +282,7 @@ static ssize_t alsa_thread_write(void *data, const void *buf, size_t size)
else
{
size_t write_amt = MIN(size - written, avail);
fifo_write(alsa->buffer,
(const char*)buf + written, write_amt);
fifo_write(alsa->buffer, (const char*)buf + written, write_amt);
slock_unlock(alsa->fifo_lock);
written += write_amt;
}
@@ -317,7 +314,7 @@ static void alsa_thread_set_nonblock_state(void *data, bool state)
alsa->nonblock = state;
}
static bool alsa_thread_start(void *data, bool is_shutdown)
static bool alsa_thread_start(void *data)
{
alsa_thread_t *alsa = (alsa_thread_t*)data;
@@ -345,64 +342,6 @@ static size_t alsa_thread_buffer_size(void *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 != NULL)
{
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_fast(io,"Output", 6)))
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_alsathread = {
alsa_thread_init,
alsa_thread_write,
@@ -413,8 +352,6 @@ audio_driver_t audio_alsathread = {
alsa_thread_free,
alsa_thread_use_float,
"alsathread",
alsa_device_list_new,
alsa_device_list_free,
alsa_thread_write_avail,
alsa_thread_buffer_size,
};
+48 -56
View File
@@ -27,20 +27,29 @@
#include <AudioUnit/AUComponent.h>
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include <rthreads/rthreads.h>
#include <retro_endianness.h>
#include <string/stdstring.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#if defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__)
#ifndef OSX_PPC
#define OSX_PPC
#endif
#endif
typedef struct coreaudio
{
slock_t *lock;
scond_t *cond;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#ifdef OSX_PPC
ComponentInstance dev;
#else
AudioComponentInstance dev;
@@ -65,7 +74,7 @@ static void coreaudio_free(void *data)
if (dev->dev_alive)
{
AudioOutputUnitStop(dev->dev);
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#ifdef OSX_PPC
CloseComponent(dev->dev);
#else
AudioComponentInstanceDispose(dev->dev);
@@ -86,19 +95,21 @@ static OSStatus audio_write_cb(void *userdata,
const AudioTimeStamp *time_stamp, UInt32 bus_number,
UInt32 number_frames, AudioBufferList *io_data)
{
void *outbuf;
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)
if (!io_data)
return noErr;
if (io_data->mNumberBuffers != 1)
return noErr;
write_avail = io_data->mBuffers[0].mDataByteSize;
outbuf = io_data->mBuffers[0].mData;
outbuf = io_data->mBuffers[0].mData;
slock_lock(dev->lock);
@@ -132,41 +143,35 @@ static void coreaudio_interrupt_listener(void *data, UInt32 interrupt_state)
static void choose_output_device(coreaudio_t *dev, const char* device)
{
unsigned i;
UInt32 deviceCount;
AudioObjectPropertyAddress propaddr;
AudioDeviceID *devices = NULL;
UInt32 size = 0;
AudioDeviceID *devices;
AudioObjectPropertyAddress propaddr =
{
kAudioHardwarePropertyDevices,
kAudioObjectPropertyScopeGlobal,
kAudioObjectPropertyElementMaster
};
propaddr.mSelector = kAudioHardwarePropertyDevices;
#if MAC_OS_X_VERSION_10_12
propaddr.mScope = kAudioObjectPropertyScopeOutput;
#else
propaddr.mScope = kAudioObjectPropertyScopeGlobal;
#endif
propaddr.mElement = kAudioObjectPropertyElementMaster;
UInt32 size = 0, deviceCount;
if (AudioObjectGetPropertyDataSize(kAudioObjectSystemObject,
&propaddr, 0, 0, &size) != noErr)
return;
deviceCount = size / sizeof(AudioDeviceID);
devices = (AudioDeviceID*)malloc(size);
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.mScope = kAudioDevicePropertyScopeOutput;
propaddr.mSelector = kAudioDevicePropertyDeviceName;
size = 1024;
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
@@ -184,14 +189,12 @@ done:
#endif
static void *coreaudio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
size_t fifo_size;
UInt32 i_size;
AudioStreamBasicDescription real_desc;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#ifdef OSX_PPC
Component comp;
#else
AudioComponent comp;
@@ -203,19 +206,21 @@ static void *coreaudio_init(const char *device,
AudioStreamBasicDescription stream_desc = {0};
bool component_unavailable = false;
static bool session_initialized = false;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
coreaudio_t *dev = NULL;
#ifdef OSX_PPC
ComponentDescription desc = {0};
#else
AudioComponentDescription desc = {0};
#endif
coreaudio_t *dev = (coreaudio_t*)
calloc(1, sizeof(*dev));
if (!dev)
return NULL;
settings_t *settings = config_get_ptr();
(void)session_initialized;
(void)device;
dev = (coreaudio_t*)calloc(1, sizeof(*dev));
if (!dev)
return NULL;
dev->lock = slock_new();
dev->cond = scond_new();
@@ -237,7 +242,7 @@ static void *coreaudio_init(const char *device,
#endif
desc.componentManufacturer = kAudioUnitManufacturer_Apple;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#ifdef OSX_PPC
comp = FindNextComponent(NULL, &desc);
#else
comp = AudioComponentFindNext(NULL, &desc);
@@ -245,7 +250,7 @@ static void *coreaudio_init(const char *device,
if (comp == NULL)
goto error;
#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))
#ifdef OSX_PPC
component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr);
#else
component_unavailable = (AudioComponentInstanceNew(comp, &dev->dev) != noErr);
@@ -259,7 +264,7 @@ static void *coreaudio_init(const char *device,
choose_output_device(dev, device);
#endif
dev->dev_alive = true;
dev->dev_alive = true;
/* Set audio format */
stream_desc.mSampleRate = rate;
@@ -294,7 +299,7 @@ static void *coreaudio_init(const char *device,
RARCH_LOG("[CoreAudio]: Using output sample rate of %.1f Hz\n",
(float)real_desc.mSampleRate);
*new_rate = real_desc.mSampleRate;
settings->audio.out_rate = real_desc.mSampleRate;
/* Set channel layout (fails on iOS). */
#ifndef TARGET_OS_IPHONE
@@ -315,11 +320,11 @@ static void *coreaudio_init(const char *device,
if (AudioUnitInitialize(dev->dev) != noErr)
goto error;
fifo_size = (latency * (*new_rate)) / 1000;
fifo_size *= 2 * sizeof(float);
dev->buffer_size = fifo_size;
fifo_size = (latency * settings->audio.out_rate) / 1000;
fifo_size *= 2 * sizeof(float);
dev->buffer_size = fifo_size;
dev->buffer = fifo_new(fifo_size);
dev->buffer = fifo_new(fifo_size);
if (!dev->buffer)
goto error;
@@ -339,9 +344,9 @@ error:
static ssize_t coreaudio_write(void *data, const void *buf_, size_t size)
{
coreaudio_t *dev = (coreaudio_t*)data;
coreaudio_t *dev = (coreaudio_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
size_t written = 0;
while (!g_interrupted && size > 0)
{
@@ -402,7 +407,7 @@ static bool coreaudio_stop(void *data)
return dev->is_paused ? true : false;
}
static bool coreaudio_start(void *data, bool is_shutdown)
static bool coreaudio_start(void *data)
{
coreaudio_t *dev = (coreaudio_t*)data;
if (!dev)
@@ -435,17 +440,6 @@ static size_t coreaudio_buffer_size(void *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,
@@ -456,8 +450,6 @@ audio_driver_t audio_coreaudio = {
coreaudio_free,
coreaudio_use_float,
"coreaudio",
coreaudio_device_list_new,
coreaudio_device_list_free,
coreaudio_write_avail,
coreaudio_buffer_size,
};
+36 -38
View File
@@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel
* Copyright (C) 2014-2016 - 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-
@@ -15,11 +15,11 @@
#include <3ds.h>
#include <string.h>
#include <malloc.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../performance.h"
#include "../../runloop.h"
typedef struct
{
@@ -48,40 +48,37 @@ typedef struct
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;
uint32_t samples_played;
uint64_t current_tick;
current_tick = svcGetSystemTick();
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)
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;
u32 paddr0 = 0, paddr1 = 0;
int encoding = (flags >> 12) & 3;
int loopMode = (flags >> 10) & 3;
if (!loopMode) flags |= SOUND_ONE_SHOT;
if (encoding != CSND_ENCODING_PSG)
{
if (data0)
paddr0 = osConvertVirtToPhys(data0);
if (data1)
paddr1 = osConvertVirtToPhys(data1);
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];
int adpcmIndex = ((u8*)data0)[-2];
CSND_SetAdpcmState(chn, 0, adpcmSample, adpcmIndex);
}
}
@@ -94,8 +91,7 @@ Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan,
if (loopMode == CSND_LOOPMODE_NORMAL && paddr1 > paddr0)
{
/* Now that the first block is playing,
* configure the size of the subsequent blocks */
// Now that the first block is playing, configure the size of the subsequent blocks
size -= paddr1 - paddr0;
CSND_SetBlock(chn, 1, paddr1, size);
}
@@ -103,11 +99,10 @@ Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan,
return 0;
}
static void *ctr_csnd_audio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *ctr_csnd_audio_init(const char *device, unsigned rate, unsigned latency)
{
ctr_csnd_audio_t *ctr = (ctr_csnd_audio_t*)calloc(1, sizeof(ctr_csnd_audio_t));
settings_t *settings = config_get_ptr();
if (!ctr)
return NULL;
@@ -116,7 +111,7 @@ static void *ctr_csnd_audio_init(const char *device, unsigned rate, unsigned lat
(void)rate;
(void)latency;
*new_rate = CTR_CSND_AUDIO_RATE;
settings->audio.out_rate = CTR_CSND_AUDIO_RATE;
ctr->l = linearAlloc(CTR_CSND_AUDIO_SIZE);
ctr->r = linearAlloc(CTR_CSND_AUDIO_SIZE);
@@ -149,9 +144,7 @@ static void ctr_csnd_audio_free(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
#if 0
csndExit();
#endif
// csndExit();
CSND_SetPlayState(0x8, 0);
CSND_SetPlayState(0x9, 0);
csndExecCmds(false);
@@ -165,16 +158,20 @@ static void ctr_csnd_audio_free(void *data)
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;
uint32_t samples_played = 0;
uint64_t current_tick = 0;
static struct retro_perf_counter ctraudio_f = {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;
rarch_perf_init(&ctraudio_f, "ctraudio_f");
retro_perf_start(&ctraudio_f);
ctr_csnd_audio_update_playpos(ctr);
if((((ctr->playpos - ctr->pos) & CTR_CSND_AUDIO_COUNT_MASK) < (CTR_CSND_AUDIO_COUNT >> 2)) ||
@@ -205,6 +202,8 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size)
GSPGPU_FlushDataCache(ctr->l, CTR_CSND_AUDIO_SIZE);
GSPGPU_FlushDataCache(ctr->r, CTR_CSND_AUDIO_SIZE);
retro_perf_stop(&ctraudio_f);
return size;
}
@@ -238,13 +237,14 @@ static bool ctr_csnd_audio_alive(void *data)
return ctr->playing;
}
static bool ctr_csnd_audio_start(void *data, bool is_shutdown)
static bool ctr_csnd_audio_start(void *data)
{
ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data;
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (is_shutdown)
if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
return true;
#if 0
@@ -300,8 +300,6 @@ audio_driver_t audio_ctr_csnd = {
ctr_csnd_audio_free,
ctr_csnd_audio_use_float,
"csnd",
NULL,
NULL,
ctr_csnd_audio_write_avail,
ctr_csnd_audio_buffer_size
};
+20 -14
View File
@@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel
* Copyright (C) 2014-2016 - 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-
@@ -15,9 +15,11 @@
#include <3ds.h>
#include <string.h>
#include <malloc.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../performance.h"
#include "../../runloop.h"
#include "../../ctr/ctr_debug.h"
typedef struct
@@ -35,11 +37,10 @@ typedef struct
#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)
static void *ctr_dsp_audio_init(const char *device, unsigned rate, unsigned latency)
{
ctr_dsp_audio_t *ctr = NULL;
ctr_dsp_audio_t *ctr;
settings_t *settings = config_get_ptr();
(void)device;
(void)rate;
@@ -53,12 +54,12 @@ static void *ctr_dsp_audio_init(const char *device, unsigned rate, unsigned late
if (!ctr)
return NULL;
*new_rate = 32730;
settings->audio.out_rate = 32730;
ctr->channel = 0;
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
ndspSetClippingMode(NDSP_CLIP_SOFT); /* ?? */
ndspSetClippingMode(NDSP_CLIP_SOFT); //??
ndspSetOutputCount(1);
ndspChnReset(ctr->channel);
ndspChnSetFormat(ctr->channel, NDSP_FORMAT_STEREO_PCM16);
@@ -94,9 +95,10 @@ static void ctr_dsp_audio_free(void *data)
static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
{
static struct retro_perf_counter ctraudio_dsp_f = {0};
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
u32 pos;
ctr_dsp_audio_t * ctr = (ctr_dsp_audio_t*)data;
uint32_t sample_pos = ndspChnGetSamplePos(ctr->channel);
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)) ||
@@ -114,6 +116,9 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
}
}
rarch_perf_init(&ctraudio_dsp_f, "ctraudio_dsp_f");
retro_perf_start(&ctraudio_dsp_f);
pos = ctr->pos << 2;
if((pos + size) > CTR_DSP_AUDIO_SIZE)
@@ -135,6 +140,8 @@ static ssize_t ctr_dsp_audio_write(void *data, const void *buf, size_t size)
ctr->pos += size >> 2;
ctr->pos &= CTR_DSP_AUDIO_COUNT_MASK;
retro_perf_stop(&ctraudio_dsp_f);
return size;
}
@@ -154,13 +161,14 @@ static bool ctr_dsp_audio_alive(void *data)
return ctr->playing;
}
static bool ctr_dsp_audio_start(void *data, bool is_shutdown)
static bool ctr_dsp_audio_start(void *data)
{
ctr_dsp_audio_t* ctr = (ctr_dsp_audio_t*)data;
/* Prevents restarting audio when the menu
* is toggled off on shutdown */
if (is_shutdown)
if (runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL))
return true;
ndspSetMasterVol(1.0);
@@ -206,8 +214,6 @@ audio_driver_t audio_ctr_dsp = {
ctr_dsp_audio_free,
ctr_dsp_audio_use_float,
"dsp",
NULL,
NULL,
ctr_dsp_audio_write_avail,
ctr_dsp_audio_buffer_size
};
+13 -20
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -31,11 +31,11 @@
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#ifdef _XBOX
@@ -68,8 +68,7 @@ typedef struct dsound
volatile bool thread_alive;
} dsound_t;
static INLINE unsigned write_avail(unsigned read_ptr,
unsigned write_ptr, unsigned buffer_size)
static INLINE unsigned write_avail(unsigned read_ptr, unsigned write_ptr, unsigned buffer_size)
{
return (read_ptr + buffer_size - write_ptr) % buffer_size;
}
@@ -92,8 +91,8 @@ struct audio_lock
static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr,
struct audio_lock *region)
{
const char *err = NULL;
HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
const char *err;
HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE,
&region->chunk1, &region->size1, &region->chunk2, &region->size2, 0);
if (res == DSERR_BUFFERLOST)
@@ -133,8 +132,7 @@ static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr,
static INLINE void release_region(dsound_t *ds, const struct audio_lock *region)
{
IDirectSoundBuffer_Unlock(ds->dsb, region->chunk1,
region->size1, region->chunk2, region->size2);
IDirectSoundBuffer_Unlock(ds->dsb, region->chunk1, region->size1, region->chunk2, region->size2);
}
static void dsound_thread(void *data)
@@ -238,9 +236,8 @@ static bool dsound_start_thread(dsound_t *ds)
static void dsound_clear_buffer(dsound_t *ds)
{
void *ptr;
DWORD size;
void *ptr = NULL;
IDirectSoundBuffer_SetCurrentPosition(ds->dsb, 0);
if (IDirectSoundBuffer_Lock(ds->dsb, 0, 0, &ptr, &size,
@@ -303,9 +300,7 @@ static BOOL CALLBACK enumerate_cb(LPGUID guid, LPCSTR desc, LPCSTR module, LPVOI
return TRUE;
}
static void *dsound_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *dsound_init(const char *device, unsigned rate, unsigned latency)
{
WAVEFORMATEX wfx = {0};
DSBUFFERDESC bufdesc = {0};
@@ -382,7 +377,7 @@ static void *dsound_init(const char *device, unsigned rate, unsigned latency,
return ds;
error:
RARCH_ERR("[DirectSound] Error occurred in init.\n");
RARCH_ERR("[DirectSound] Error occured in init.\n");
dsound_free(ds);
return NULL;
}
@@ -397,7 +392,7 @@ static bool dsound_stop(void *data)
return (ds->is_paused) ? true : false;
}
static bool dsound_start(void *data, bool is_shutdown)
static bool dsound_start(void *data)
{
dsound_t *ds = (dsound_t*)data;
@@ -429,8 +424,8 @@ static void dsound_set_nonblock_state(void *data, bool state)
static ssize_t dsound_write(void *data, const void *buf_, size_t size)
{
size_t written = 0;
dsound_t *ds = (dsound_t*)data;
size_t written = 0;
dsound_t *ds = (dsound_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
if (!ds->thread_alive)
@@ -494,8 +489,6 @@ audio_driver_t audio_dsound = {
dsound_free,
dsound_use_float,
"dsound",
NULL,
NULL,
dsound_write_avail,
dsound_buffer_size,
};
+11 -13
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -28,6 +28,7 @@
#include <retro_inline.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../defines/gx_defines.h"
typedef struct
@@ -44,8 +45,8 @@ typedef struct
bool is_paused;
} gx_audio_t;
static volatile gx_audio_t *gx_audio_data = NULL;
static volatile bool stop_audio = false;
static volatile gx_audio_t *gx_audio_data;
static volatile bool stop_audio;
static void dma_callback(void)
{
@@ -68,10 +69,9 @@ static void dma_callback(void)
}
static void *gx_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
settings_t *settings = config_get_ptr();
gx_audio_t *wa = (gx_audio_t*)memalign(32, sizeof(*wa));
if (!wa)
return NULL;
@@ -86,12 +86,12 @@ static void *gx_audio_init(const char *device,
if (rate < 33000)
{
AISetDSPSampleRate(AI_SAMPLERATE_32KHZ);
*new_rate = 32000;
settings->audio.out_rate = 32000;
}
else
{
AISetDSPSampleRate(AI_SAMPLERATE_48KHZ);
*new_rate = 48000;
settings->audio.out_rate = 48000;
}
OSInitThreadQueue(&wa->cond);
@@ -118,9 +118,9 @@ static INLINE void copy_swapped(uint32_t * restrict dst,
static ssize_t gx_audio_write(void *data, const void *buf_, size_t size)
{
size_t frames = size >> 2;
size_t frames = size >> 2;
const uint32_t *buf = buf_;
gx_audio_t *wa = data;
gx_audio_t *wa = data;
while (frames)
{
@@ -173,7 +173,7 @@ static void gx_audio_set_nonblock_state(void *data, bool state)
wa->nonblock = state;
}
static bool gx_audio_start(void *data, bool is_shutdown)
static bool gx_audio_start(void *data)
{
gx_audio_t *wa = (gx_audio_t*)data;
@@ -241,8 +241,6 @@ audio_driver_t audio_gx = {
gx_audio_free,
gx_audio_use_float,
"gx",
NULL,
NULL,
gx_audio_write_avail,
gx_audio_buffer_size,
};
+35 -56
View File
@@ -13,11 +13,12 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <jack/jack.h>
#include <jack/types.h>
#include <jack/ringbuffer.h>
@@ -40,29 +41,25 @@ typedef struct jack
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_nframes_t f, 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]);
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)
@@ -70,17 +67,14 @@ static int process_cb(jack_nframes_t nframes, void *data)
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);
assert(out);
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;
}
@@ -92,19 +86,16 @@ static void shutdown_cb(void *data)
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);
char *save = NULL;
int parsed = 0;
settings_t *settings = config_get_ptr();
const char *con = strtok_r(settings->audio.device, ",", &save);
if (con)
dest_ports[parsed++] = strdup(con);
@@ -115,16 +106,15 @@ static int parse_ports(char **dest_ports, const char **jports)
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)
static size_t find_buffersize(jack_t *jd, int latency)
{
jack_latency_range_t range;
int i, buffer_frames, min_buffer_frames;
int jack_latency = 0;
int frames = latency * out_rate / 1000;
int i, buffer_frames, min_buffer_frames, jack_latency = 0;
settings_t *settings = config_get_ptr();
int frames = latency * settings->audio.out_rate / 1000;
for (i = 0; i < 2; i++)
{
@@ -133,12 +123,12 @@ static size_t find_buffersize(jack_t *jd, int latency, unsigned out_rate)
jack_latency = range.max;
}
RARCH_LOG("[JACK]: Jack latency is %d frames.\n", jack_latency);
RARCH_LOG("JACK: Jack latency is %d frames.\n", jack_latency);
buffer_frames = frames - 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);
RARCH_LOG("JACK: Minimum buffer size is %d frames.\n", min_buffer_frames);
if (buffer_frames < min_buffer_frames)
buffer_frames = min_buffer_frames;
@@ -146,30 +136,27 @@ static size_t find_buffersize(jack_t *jd, int latency, unsigned out_rate)
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)
static void *ja_init(const char *device, unsigned rate, unsigned latency)
{
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));
char *dest_ports[2];
size_t bufsize = 0;
int parsed = 0;
settings_t *settings = config_get_ptr();
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 == NULL)
goto error;
*new_rate = jack_get_sample_rate(jd->client);
settings->audio.out_rate = jack_get_sample_rate(jd->client);
jack_set_process_callback(jd->client, process_cb, jd);
jack_on_shutdown(jd->client, shutdown_cb, jd);
@@ -178,27 +165,27 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
jd->ports[1] = jack_port_register(jd->client, "right", JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
if (jd->ports[0] == NULL || jd->ports[1] == NULL)
{
RARCH_ERR("[JACK]: Failed to register ports.\n");
RARCH_ERR("Failed to register ports.\n");
goto error;
}
jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput);
if (jports == NULL)
{
RARCH_ERR("[JACK]: Failed to get ports.\n");
RARCH_ERR("Failed to get ports.\n");
goto error;
}
bufsize = find_buffersize(jd, latency, *new_rate);
bufsize = find_buffersize(jd, latency);
jd->buffer_size = bufsize;
RARCH_LOG("[JACK]: Internal buffer size: %d frames.\n", (int)(bufsize / sizeof(jack_default_audio_sample_t)));
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] == NULL)
{
RARCH_ERR("[JACK]: Failed to create buffers.\n");
RARCH_ERR("Failed to create buffers.\n");
goto error;
}
}
@@ -207,7 +194,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
if (jack_activate(jd->client) < 0)
{
RARCH_ERR("[JACK]: Failed to activate Jack...\n");
RARCH_ERR("Failed to activate Jack...\n");
goto error;
}
@@ -215,7 +202,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
{
if (jack_connect(jd->client, jack_port_name(jd->ports[i]), dest_ports[i]))
{
RARCH_ERR("[JACK]: Failed to connect to Jack port.\n");
RARCH_ERR("Failed to connect to Jack port.\n");
goto error;
}
}
@@ -227,20 +214,18 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency,
return jd;
error:
for (i = 0; i < parsed; i++)
free(dest_ports[i]);
if (jports != NULL)
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;
size_t j, frames, written = 0;
jack_default_audio_sample_t out_deinterleaved_buffer[2][AUDIO_CHUNK_SIZE_NONBLOCKING * AUDIO_MAX_RATIO];
size_t frames = FRAMES(size);
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)
@@ -273,14 +258,12 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size)
}
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;
@@ -319,7 +302,7 @@ static void ja_set_nonblock_state(void *data, bool state)
jd->nonblock = state;
}
static bool ja_start(void *data, bool is_shutdown)
static bool ja_start(void *data)
{
jack_t *jd = (jack_t*)data;
if (jd)
@@ -344,12 +327,10 @@ static void ja_free(void *data)
if (jd->buffer[i] != NULL)
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);
}
@@ -381,8 +362,6 @@ audio_driver_t audio_jack = {
ja_free,
ja_use_float,
"jack",
NULL,
NULL,
ja_write_avail,
ja_buffer_size,
};
+2 -8
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -17,16 +16,13 @@
#include "../audio_driver.h"
#include "../../verbosity.h"
static void *null_audio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *null_audio_init(const char *device, unsigned rate, unsigned latency)
{
RARCH_ERR("Using the null audio driver. RetroArch will be silent.");
(void)device;
(void)rate;
(void)latency;
(void)new_rate;
return (void*)-1;
}
@@ -55,7 +51,7 @@ static bool null_audio_alive(void *data)
return true;
}
static bool null_audio_start(void *data, bool is_shutdown)
static bool null_audio_start(void *data)
{
(void)data;
return true;
@@ -89,8 +85,6 @@ audio_driver_t audio_null = {
null_audio_free,
null_audio_use_float,
"null",
NULL,
NULL,
null_audio_write_avail,
NULL
};
+5 -13
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -14,7 +13,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#include <stdlib.h>
#include <string.h>
#include <time.h>
@@ -30,10 +28,8 @@
#include <windows.h>
#endif
#include <retro_miscellaneous.h>
#include <retro_timers.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#define BUFSIZE 1024
@@ -82,9 +78,7 @@ static void al_free(void *data)
free(al);
}
static void *al_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *al_init(const char *device, unsigned rate, unsigned latency)
{
al_t *al;
@@ -176,9 +170,9 @@ static size_t al_fill_internal_buf(al_t *al, const void *buf, size_t size)
static ssize_t al_write(void *data, const void *buf_, size_t size)
{
al_t *al = (al_t*)data;
al_t *al = (al_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
size_t written = 0;
while (size)
{
@@ -236,7 +230,7 @@ static void al_set_nonblock_state(void *data, bool state)
al->nonblock = state;
}
static bool al_start(void *data, bool is_shutdown)
static bool al_start(void *data)
{
al_t *al = (al_t*)data;
if (al)
@@ -273,8 +267,6 @@ audio_driver_t audio_openal = {
al_free,
al_use_float,
"openal",
NULL,
NULL,
al_write_avail,
al_buffer_size,
};
+51 -51
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -22,6 +22,7 @@
#include <rthreads/rthreads.h>
#include "../audio_driver.h"
#include "../../configuration.h"
/* Helper macros, COM-style. */
#define SLObjectItf_Realize(a, ...) ((*(a))->Realize(a, __VA_ARGS__))
@@ -97,26 +98,31 @@ static void sl_free(void *data)
free(sl);
}
static void *sl_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *sl_init(const char *device, unsigned rate, unsigned latency)
{
unsigned i;
SLDataFormat_PCM fmt_pcm = {0};
SLDataSource audio_src = {0};
SLDataSink audio_sink = {0};
SLInterfaceID id;
SLboolean req;
SLresult res;
sl_t *sl;
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));
settings_t *settings = config_get_ptr();
(void)device;
id = SL_IID_ANDROIDSIMPLEBUFFERQUEUE;
req = SL_BOOLEAN_TRUE;
res = 0;
sl = (sl_t*)calloc(1, sizeof(sl_t));
if (!sl)
goto error;
RARCH_LOG("[OpenSL]: Requested audio latency: %u ms.", latency);
RARCH_LOG("[SLES]: 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));
@@ -125,15 +131,15 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
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;
if (settings->audio.block_frames)
sl->buf_size = settings->audio.block_frames * 4;
else
sl->buf_size = next_pow2(32 * latency);
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;
sl->buf_count = (latency * 4 * rate + 500) / 1000;
sl->buf_count = (sl->buf_count + sl->buf_size / 2) / sl->buf_size;
sl->buffer = (uint8_t**)calloc(sizeof(uint8_t*), sl->buf_count);
sl->buffer = (uint8_t**)calloc(sizeof(uint8_t*), sl->buf_count);
if (!sl->buffer)
goto error;
@@ -144,27 +150,27 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
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",
RARCH_LOG("[SLES]: 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. */
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;
audio_src.pLocator = &loc_bufq;
audio_src.pFormat = &fmt_pcm;
loc_bufq.locatorType = SL_DATALOCATOR_ANDROIDSIMPLEBUFFERQUEUE;
loc_bufq.numBuffers = sl->buf_count;
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;
audio_sink.pLocator = &loc_outmix;
GOTO_IF_FAIL(SLEngineItf_CreateAudioPlayer(sl->engine, &sl->buffer_queue_object,
&audio_src, &audio_sink,
@@ -174,15 +180,14 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
GOTO_IF_FAIL(SLObjectItf_GetInterface(sl->buffer_queue_object, SL_IID_ANDROIDSIMPLEBUFFERQUEUE,
&sl->buffer_queue));
sl->cond = scond_new();
sl->lock = slock_new();
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;
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);
@@ -192,17 +197,15 @@ static void *sl_init(const char *device, unsigned rate, unsigned latency,
return sl;
error:
RARCH_ERR("[OpenSL]: Couldn't initialize OpenSL ES driver, error code: [%d].\n", (int)res);
RARCH_ERR("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;
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;
}
@@ -221,19 +224,18 @@ static void sl_set_nonblock_state(void *data, bool state)
sl->nonblock = state;
}
static bool sl_start(void *data, bool is_shutdown)
static bool sl_start(void *data)
{
sl_t *sl = (sl_t*)data;
sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_PLAYING)
== SL_RESULT_SUCCESS) ? false : true;
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;
sl_t *sl = (sl_t*)data;
size_t written = 0;
const uint8_t *buf = (const uint8_t*)buf_;
while (size)
@@ -266,10 +268,10 @@ static ssize_t sl_write(void *data, const void *buf_, size_t size)
if (sl->buffer_ptr >= sl->buf_size)
{
SLresult res = (*sl->buffer_queue)->Enqueue(sl->buffer_queue, sl->buffer[sl->buffer_index], 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;
sl->buffer_ptr = 0;
if (res != SL_RESULT_SUCCESS)
{
@@ -311,8 +313,6 @@ audio_driver_t audio_opensl = {
sl_free,
sl_use_float,
"opensl",
NULL,
NULL,
sl_write_avail,
sl_buffer_size,
};
+33 -31
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -13,7 +12,6 @@
* 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>
@@ -34,6 +32,7 @@
#endif
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
#ifdef HAVE_OSS_BSD
@@ -42,17 +41,17 @@
#define DEFAULT_OSS_DEV "/dev/dsp"
#endif
static bool oss_is_paused = false;
static bool oss_is_paused;
static void *oss_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_out_rate)
static void *oss_init(const char *device, unsigned rate, unsigned latency)
{
int frags, frag, channels, format, new_rate;
int *fd = (int*)calloc(1, sizeof(int));
int *fd = (int*)calloc(1, sizeof(int));
settings_t *settings = config_get_ptr();
const char *oss_device = device ? device : DEFAULT_OSS_DEV;
if (!fd)
if (fd == NULL)
return NULL;
if ((*fd = open(oss_device, O_WRONLY)) < 0)
@@ -63,38 +62,47 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency,
}
frags = (latency * rate * 4) / (1000 * (1 << 10));
frag = (frags << 16) | 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;
format = is_little_endian() ? AFMT_S16_LE : AFMT_S16_BE;
if (ioctl(*fd, SNDCTL_DSP_CHANNELS, &channels) < 0)
goto error;
{
close(*fd);
free(fd);
perror("ioctl");
return NULL;
}
if (ioctl(*fd, SNDCTL_DSP_SETFMT, &format) < 0)
goto error;
{
close(*fd);
free(fd);
perror("ioctl");
return NULL;
}
new_rate = rate;
if (ioctl(*fd, SNDCTL_DSP_SPEED, &new_rate) < 0)
goto error;
{
close(*fd);
free(fd);
perror("ioctl");
return NULL;
}
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;
settings->audio.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)
@@ -120,14 +128,12 @@ static bool oss_stop(void *data)
{
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_RESET, 0) < 0)
return false;
ioctl(*fd, SNDCTL_DSP_RESET, 0);
oss_is_paused = true;
return true;
}
static bool oss_start(void *data, bool is_shutdown)
static bool oss_start(void *data)
{
(void)data;
oss_is_paused = false;
@@ -157,9 +163,7 @@ static void oss_free(void *data)
{
int *fd = (int*)data;
if (ioctl(*fd, SNDCTL_DSP_RESET, 0) < 0)
return;
ioctl(*fd, SNDCTL_DSP_RESET, 0);
close(*fd);
free(fd);
}
@@ -171,7 +175,7 @@ static size_t oss_write_avail(void *data)
if (ioctl(*fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
{
RARCH_ERR("[OSS]: SNDCTL_DSP_GETOSPACE failed ...\n");
RARCH_ERR("SNDCTL_DSP_GETOSPACE failed ...\n");
return 0;
}
@@ -185,7 +189,7 @@ static size_t oss_buffer_size(void *data)
if (ioctl(*fd, SNDCTL_DSP_GETOSPACE, &info) < 0)
{
RARCH_ERR("[OSS]: SNDCTL_DSP_GETOSPACE failed ...\n");
RARCH_ERR("SNDCTL_DSP_GETOSPACE failed ...\n");
return 1; /* Return something non-zero to avoid SIGFPE. */
}
@@ -208,8 +212,6 @@ audio_driver_t audio_oss = {
oss_free,
oss_use_float,
"oss",
NULL,
NULL,
oss_write_avail,
oss_buffer_size,
};
+13 -14
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -17,9 +17,10 @@
#include <stdlib.h>
#include <string.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../defines/ps3_defines.h"
@@ -51,7 +52,7 @@ static void event_loop(uint64_t data)
sys_event_queue_t id;
sys_ipc_key_t key;
sys_event_t event;
ps3_audio_t *aud = (ps3_audio_t*)(uintptr_t)data;
ps3_audio_t *aud = data;
cellAudioCreateNotifyEventQueue(&id, &key);
cellAudioSetNotifyEventQueue(key);
@@ -77,23 +78,23 @@ static void event_loop(uint64_t data)
}
static void *ps3_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
CellAudioPortParam params;
ps3_audio_t *data = calloc(1, sizeof(*data));
if (!data)
return NULL;
ps3_audio_t *data = NULL;
(void)latency;
(void)device;
(void)rate;
data = calloc(1, sizeof(*data));
if (!data)
return NULL;
cellAudioInit();
params.numChannels = AUDIO_CHANNELS;
params.numBlocks = AUDIO_BLOCKS;
params.numBlocks = AUDIO_BLOCKS;
#if 0
#ifdef HAVE_HEADSET
if(global->console.sound.mode == SOUND_MODE_HEADSET)
@@ -177,7 +178,7 @@ static bool ps3_audio_stop(void *data)
return true;
}
static bool ps3_audio_start(void *data, bool is_shutdown)
static bool ps3_audio_start(void *data)
{
ps3_audio_t *aud = data;
if (!aud->started)
@@ -209,7 +210,7 @@ static void ps3_audio_free(void *data)
ps3_audio_t *aud = data;
aud->quit_thread = true;
ps3_audio_start(aud, false);
ps3_audio_start(aud);
sys_ppu_thread_join(aud->thread, &val);
ps3_audio_stop(aud);
@@ -246,8 +247,6 @@ audio_driver_t audio_ps3 = {
ps3_audio_free,
ps3_audio_use_float,
"ps3",
NULL,
NULL,
ps3_audio_write_avail,
NULL
};
+53 -111
View File
@@ -1,7 +1,7 @@
/* 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
* Copyright (C) 2011-2016 - Daniel De Matteis
* Copyright (C) 2014-2016 - 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-
@@ -17,8 +17,6 @@
#include <stdint.h>
#include <malloc.h>
#include <stdio.h>
#include <string.h>
#ifdef VITA
#include <psp2/kernel/processmgr.h>
@@ -31,26 +29,19 @@
#endif
#include "../audio_driver.h"
#include "../../configuration.h"
typedef struct psp_audio
{
bool nonblocking;
uint32_t* buffer;
uint32_t* zeroBuffer;
SceUID thread;
int rate;
volatile bool running;
volatile uint16_t read_pos;
volatile uint16_t write_pos;
#ifdef VITA
char lock[32] __attribute__ ((aligned (8)));
char cond_lock[32] __attribute__ ((aligned (8)));
char cond[32] __attribute__ ((aligned (8)));
#endif
volatile uint16_t readPos;
volatile uint16_t writePos;
} psp_audio_t;
#define AUDIO_OUT_COUNT 512u
@@ -58,7 +49,7 @@ typedef struct psp_audio
#define AUDIO_BUFFER_SIZE_MASK (AUDIO_BUFFER_SIZE-1)
#ifdef VITA
#define PSP_THREAD_STOPPED SCE_THREAD_STOPPED
#define PSP_THREAD_STOPPED PSP2_THREAD_STOPPED
#else
#define SceKernelThreadInfo SceKernelThreadRunStatus
#define sceKernelGetThreadInfo sceKernelReferThreadRunStatus
@@ -67,61 +58,48 @@ typedef struct psp_audio
static int audioMainLoop(SceSize args, void* argp)
{
psp_audio_t* psp = *((psp_audio_t**)argp);
#ifdef VITA
int port = sceAudioOutOpenPort(
SCE_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
psp->rate, SCE_AUDIO_OUT_MODE_STEREO);
int port = sceAudioOutOpenPort(PSP2_AUDIO_OUT_PORT_TYPE_MAIN, AUDIO_OUT_COUNT,
psp->rate, PSP2_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;
#ifdef VITA
sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0);
#endif
cond = ((uint16_t)(psp->write_pos - read_pos) & AUDIO_BUFFER_SIZE_MASK)
/* Get a non-volatile copy. */
uint16_t readPos = psp->readPos;
bool cond = ((uint16_t)(psp->writePos - readPos) & AUDIO_BUFFER_SIZE_MASK)
< (AUDIO_OUT_COUNT * 2);
#ifndef VITA
#ifdef VITA
sceAudioOutOutput(port,
cond ? psp->zeroBuffer : (psp->buffer + readPos));
#else
sceAudioSRCOutputBlocking(PSP_AUDIO_VOLUME_MAX, cond ? (psp->zeroBuffer)
: (psp->buffer + read_pos));
: (psp->buffer + readPos));
#endif
if (!cond)
{
read_pos += AUDIO_OUT_COUNT;
read_pos &= AUDIO_BUFFER_SIZE_MASK;
psp->read_pos = read_pos;
readPos += AUDIO_OUT_COUNT;
readPos &= AUDIO_BUFFER_SIZE_MASK;
psp->readPos = readPos;
}
#ifdef VITA
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
sceKernelSignalLwCond((struct SceKernelLwCondWork*)&psp->cond);
sceAudioOutOutput(port,
cond ? (psp->zeroBuffer)
: (psp->buffer + read_pos_2));
#endif
}
#ifdef VITA
sceAudioOutReleasePort(port);
#else
sceAudioSRCChRelease();
sceKernelExitThread(0);
#endif
sceKernelExitThread(0);
return 0;
}
static void *psp_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
psp_audio_t *psp = (psp_audio_t*)calloc(1, sizeof(psp_audio_t));
@@ -131,31 +109,27 @@ static void *psp_audio_init(const char *device,
(void)device;
(void)latency;
/* Cache aligned, not necessary but helpful. */
psp->buffer = (uint32_t*)
memalign(64, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
memset(psp->buffer, 0, AUDIO_BUFFER_SIZE * sizeof(uint32_t));
psp->zeroBuffer = (uint32_t*)
memalign(64, AUDIO_OUT_COUNT * sizeof(uint32_t));
memset(psp->zeroBuffer, 0, AUDIO_OUT_COUNT * sizeof(uint32_t));
psp->read_pos = 0;
psp->write_pos = 0;
psp->readPos = 0;
psp->writePos = 0;
psp->rate = rate;
#if defined(VITA)
sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)&psp->lock, "audio_get_lock", 0, 0, 0);
sceKernelCreateLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock, "audio_get_cond_lock", 0, 0, 0);
sceKernelCreateLwCond((struct SceKernelLwCondWork*)&psp->cond, "audio_get_cond", 0, (struct SceKernelLwMutexWork*)&psp->cond_lock, 0);
psp->thread = sceKernelCreateThread
("audioMainLoop", audioMainLoop, 0x10000100, 0x10000, 0, 0, NULL);
#else
psp->thread = sceKernelCreateThread
("audioMainLoop", audioMainLoop, 0x08, 0x10000, 0, NULL);
#endif
psp->nonblocking = false;
psp->running = true;
sceKernelStartThread(psp->thread, sizeof(psp_audio_t*), &psp);
@@ -172,61 +146,47 @@ static void psp_audio_free(void *data)
psp->running = false;
#if defined(VITA)
sceKernelWaitThreadEnd(psp->thread, NULL, &timeout);
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->lock);
sceKernelDeleteLwMutex((struct SceKernelLwMutexWork*)&psp->cond_lock);
sceKernelDeleteLwCond((struct SceKernelLwCondWork*)&psp->cond);
#else
sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif
free(psp->buffer);
sceKernelDeleteThread(psp->thread);
free(psp->buffer);
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);
uint16_t sampleCount;
psp_audio_t* psp = (psp_audio_t*)data;
uint16_t writePos = psp->writePos;
sampleCount= size / sizeof(uint32_t);
#if 0
if (psp->nonblocking)
{
if (AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size)
return 0;
/* TODO */
}
#ifdef VITA
while (AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK) < size)
sceKernelWaitLwCond((struct SceKernelLwCondWork*)&psp->cond, 0);
sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0);
#endif
if((write_pos + sampleCount) > AUDIO_BUFFER_SIZE)
if((writePos + sampleCount) > AUDIO_BUFFER_SIZE)
{
memcpy(psp->buffer + write_pos, buf,
(AUDIO_BUFFER_SIZE - write_pos) * sizeof(uint32_t));
memcpy(psp->buffer + writePos, buf,
(AUDIO_BUFFER_SIZE - writePos) * sizeof(uint32_t));
memcpy(psp->buffer, (uint32_t*) buf +
(AUDIO_BUFFER_SIZE - write_pos),
(write_pos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
(AUDIO_BUFFER_SIZE - writePos),
(writePos + sampleCount - AUDIO_BUFFER_SIZE) * sizeof(uint32_t));
}
else
memcpy(psp->buffer + write_pos, buf, size);
memcpy(psp->buffer + writePos, buf, size);
write_pos += sampleCount;
write_pos &= AUDIO_BUFFER_SIZE_MASK;
psp->write_pos = write_pos;
writePos += sampleCount;
writePos &= AUDIO_BUFFER_SIZE_MASK;
psp->writePos = writePos;
#ifdef VITA
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
return size;
#else
return sampleCount;
#endif
return sampleCount;
}
static bool psp_audio_alive(void *data)
@@ -244,9 +204,6 @@ static bool psp_audio_stop(void *data)
SceUInt timeout = 100000;
psp_audio_t* psp = (psp_audio_t*)data;
if(psp && !psp->running)
return true;
info.size = sizeof(SceKernelThreadInfo);
if (sceKernelGetThreadInfo(
@@ -262,16 +219,14 @@ static bool psp_audio_stop(void *data)
#else
sceKernelWaitThreadEnd(psp->thread, &timeout);
#endif
return true;
}
static bool psp_audio_start(void *data, bool is_shutdown)
static bool psp_audio_start(void *data)
{
SceKernelThreadInfo info;
psp_audio_t* psp = (psp_audio_t*)data;
if(psp && psp->running)
return true;
info.size = sizeof(SceKernelThreadInfo);
@@ -304,27 +259,16 @@ static bool psp_audio_use_float(void *data)
static size_t psp_write_avail(void *data)
{
size_t val;
/* TODO */
psp_audio_t* psp = (psp_audio_t*)data;
#ifdef VITA
sceKernelLockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1, 0);
#endif
val = AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->write_pos - psp->read_pos) & AUDIO_BUFFER_SIZE_MASK);
#ifdef VITA
sceKernelUnlockLwMutex((struct SceKernelLwMutexWork*)&psp->lock, 1);
#endif
return val;
return AUDIO_BUFFER_SIZE - ((uint16_t)
(psp->writePos - psp->readPos) & AUDIO_BUFFER_SIZE_MASK);
}
static size_t psp_buffer_size(void *data)
{
/* TODO */
return AUDIO_BUFFER_SIZE /** sizeof(uint32_t)*/;
return AUDIO_BUFFER_SIZE;
}
@@ -342,8 +286,6 @@ audio_driver_t audio_psp = {
#else
"psp",
#endif
NULL,
NULL,
psp_write_avail,
psp_buffer_size
psp_buffer_size,
};
+18 -27
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -23,6 +22,7 @@
#include <retro_endianness.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
typedef struct
@@ -125,7 +125,6 @@ static void stream_latency_update_cb(pa_stream *s, void *data)
static void underrun_update_cb(pa_stream *s, void *data)
{
#if 0
pa_t *pa = (pa_t*)data;
(void)s;
@@ -133,7 +132,6 @@ static void underrun_update_cb(pa_stream *s, void *data)
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)
@@ -143,23 +141,19 @@ static void buffer_attr_cb(pa_stream *s, void *data)
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)
static void *pulse_init(const char *device, unsigned rate, unsigned latency)
{
pa_sample_spec spec;
pa_buffer_attr buffer_attr = {0};
pa_sample_spec spec;
pa_t *pa;
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));
pa = (pa_t*)calloc(1, sizeof(*pa));
if (!pa)
goto error;
@@ -185,11 +179,11 @@ static void *pulse_init(const char *device, unsigned rate,
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.format = is_little_endian() ? PA_SAMPLE_FLOAT32LE : PA_SAMPLE_FLOAT32BE;
spec.channels = 2;
spec.rate = rate;
spec.rate = rate;
pa->stream = pa_stream_new(pa->context, "audio", &spec, NULL);
pa->stream = pa_stream_new(pa->context, "audio", &spec, NULL);
if (!pa->stream)
goto unlock_error;
@@ -200,13 +194,12 @@ static void *pulse_init(const char *device, unsigned rate,
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;
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)
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);
@@ -238,9 +231,9 @@ error:
static ssize_t pulse_write(void *data, const void *buf_, size_t size)
{
pa_t *pa = (pa_t*)data;
pa_t *pa = (pa_t*)data;
const uint8_t *buf = (const uint8_t*)buf_;
size_t written = 0;
size_t written = 0;
pa_threaded_mainloop_lock(pa->mainloop);
while (size)
@@ -291,7 +284,7 @@ static bool pulse_alive(void *data)
return !pa->is_paused;
}
static bool pulse_start(void *data, bool is_shutdown)
static bool pulse_start(void *data)
{
bool ret;
pa_t *pa = (pa_t*)data;
@@ -350,8 +343,6 @@ audio_driver_t audio_pulse = {
pulse_free,
pulse_use_float,
"pulse",
NULL,
NULL,
pulse_write_avail,
pulse_buffer_size,
};
+7 -13
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -24,21 +23,19 @@
#include <boolean.h>
#include "../audio_driver.h"
#include "../../verbosity.h"
#include "../../configuration.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)
static void *ra_init(const char *device, unsigned rate, unsigned latency)
{
int err;
roar_vs_t *vss = NULL;
roar_t *roar = (roar_t*)calloc(1, sizeof(roar_t));
roar_vs_t *vss;
roar_t *roar = (roar_t*)calloc(1, sizeof(roar_t));
if (!roar)
return NULL;
@@ -62,7 +59,7 @@ 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;
roar_t *roar = (roar_t*)data;
if (size == 0)
return 0;
@@ -72,8 +69,7 @@ static ssize_t ra_write(void *data, const void *buf, size_t 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 ((rc = roar_vs_write(roar->vss, (const char*)buf + written, write_amt, &err)) < (ssize_t)write_amt)
{
if (roar->nonblocking)
return rc;
@@ -110,7 +106,7 @@ static void ra_set_nonblock_state(void *data, bool state)
roar->nonblocking = state;
}
static bool ra_start(void *data, bool is_shutdown)
static bool ra_start(void *data)
{
roar_t *roar = (roar_t*)data;
if (roar)
@@ -146,8 +142,6 @@ audio_driver_t audio_roar = {
ra_free,
ra_use_float,
"roar",
NULL,
NULL,
ra_write_avail,
NULL
};
+17 -22
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -18,7 +17,7 @@
#include <boolean.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include <rthreads/rthreads.h>
#include "../audio_driver.h"
@@ -56,26 +55,28 @@ static void err_cb(void *userdata)
scond_signal(rsd->cond);
}
static void *rs_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *rs_init(const char *device, unsigned rate, unsigned latency)
{
int channels, format;
rsound_t *rd = NULL;
rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
rsd_t *rsd = (rsd_t*)calloc(1, sizeof(rsd_t));
if (!rsd)
return NULL;
rsound_t *rd;
if (rsd_init(&rd) < 0)
goto error;
{
free(rsd);
return NULL;
}
rsd->cond_lock = slock_new();
rsd->cond = scond_new();
rsd->cond = scond_new();
rsd->buffer = fifo_new(1024 * 4);
rsd->buffer = fifo_new(1024 * 4);
channels = 2;
format = RSD_S16_NE;
channels = 2;
format = RSD_S16_NE;
rsd_set_param(rd, RSD_CHANNELS, &channels);
rsd_set_param(rd, RSD_SAMPLERATE, &rate);
@@ -91,15 +92,12 @@ static void *rs_init(const char *device, unsigned rate, unsigned latency,
if (rsd_start(rd) < 0)
{
free(rsd);
goto error;
rsd_free(rd);
return NULL;
}
rsd->rd = rd;
return rsd;
error:
rsd_free(rd);
return NULL;
}
static ssize_t rs_write(void *data, const void *buf, size_t size)
@@ -177,7 +175,7 @@ static bool rs_alive(void *data)
return false;
}
static bool rs_start(void *data, bool is_shutdown)
static bool rs_start(void *data)
{
rsd_t *rsd = (rsd_t*)data;
if (rsd_start(rsd->rd) < 0)
@@ -203,13 +201,12 @@ static void rs_free(void *data)
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);
size_t val = fifo_write_avail(rsd->buffer);
rsd_callback_unlock(rsd->rd);
return val;
}
@@ -236,8 +233,6 @@ audio_driver_t audio_rsound = {
rs_free,
rs_use_float,
"rsound",
NULL,
NULL,
rs_write_avail,
rs_buffer_size,
};
+12 -5
View File
@@ -16,6 +16,14 @@
#ifndef __RSOUND_H
#define __RSOUND_H
#ifdef __cplusplus
extern "C" {
#endif
#if 0
#define STANDALONE
#endif
#include <sys/types.h>
#include <unistd.h>
#include <rthreads/rthreads.h>
@@ -24,10 +32,7 @@
#include <stdint.h>
#include <stddef.h>
#include <retro_common_api.h>
#include <queues/fifo_queue.h>
RETRO_BEGIN_DECLS
#include <queues/fifo_buffer.h>
#ifdef _WIN32
#define RSD_DEFAULT_HOST "127.0.0.1" /* Stupid Windows. */
@@ -318,6 +323,8 @@ 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
#ifdef __cplusplus
}
#endif
#endif
+11 -14
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -19,6 +18,7 @@
#include <boolean.h>
#include "../audio_driver.h"
#include "../../configuration.h"
/* forward declarations */
unsigned RWebAudioSampleRate(void);
@@ -37,17 +37,16 @@ static void rwebaudio_free(void *data)
RWebAudioFree();
}
static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *rwebaudio_init(const char *device, unsigned rate, unsigned latency)
{
settings_t *settings = config_get_ptr();
void *data = RWebAudioInit(latency);
(void)device;
(void)rate;
if (data)
*new_rate = RWebAudioSampleRate();
settings->audio.out_rate = RWebAudioSampleRate();
return data;
}
@@ -76,13 +75,19 @@ static bool rwebaudio_alive(void *data)
return !rwebaudio_is_paused;
}
static bool rwebaudio_start(void *data, bool is_shutdown)
static bool rwebaudio_start(void *data)
{
(void)data;
rwebaudio_is_paused = false;
return RWebAudioStart();
}
static bool rwebaudio_use_float(void *data)
{
(void)data;
return true;
}
static size_t rwebaudio_write_avail(void *data)
{
(void)data;
@@ -95,12 +100,6 @@ static size_t rwebaudio_buffer_size(void *data)
return RWebAudioBufferSize();
}
static bool rwebaudio_use_float(void *data)
{
(void)data;
return true;
}
audio_driver_t audio_rwebaudio = {
rwebaudio_init,
rwebaudio_write,
@@ -111,8 +110,6 @@ audio_driver_t audio_rwebaudio = {
rwebaudio_free,
rwebaudio_use_float,
"rwebaudio",
NULL,
NULL,
rwebaudio_write_avail,
rwebaudio_buffer_size,
};
+24 -41
View File
@@ -1,6 +1,5 @@
/* 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-
@@ -24,11 +23,11 @@
#include <boolean.h>
#include <rthreads/rthreads.h>
#include <queues/fifo_queue.h>
#include <queues/fifo_buffer.h>
#include <retro_inline.h>
#include <retro_math.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
typedef struct sdl_audio
@@ -36,23 +35,19 @@ 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);
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);
@@ -68,15 +63,14 @@ static INLINE int find_num_frames(int rate, int latency)
}
static void *sdl_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
int frames;
size_t bufsize;
void *tmp;
SDL_AudioSpec out;
SDL_AudioSpec spec = {0};
void *tmp = NULL;
SDL_AudioSpec spec = {0};
settings_t *settings = config_get_ptr();
sdl_audio_t *sdl = NULL;
(void)device;
@@ -97,34 +91,33 @@ static void *sdl_audio_init(const char *device,
* carry approximately half of the latency.
*
* SDL double buffers audio and we do as well. */
frames = find_num_frames(rate, latency / 4);
frames = find_num_frames(rate, latency / 4);
spec.freq = rate;
spec.format = AUDIO_S16SYS;
spec.freq = rate;
spec.format = AUDIO_S16SYS;
spec.channels = 2;
spec.samples = frames; /* This is in audio frames, not samples ... :( */
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;
RARCH_ERR("Failed to open SDL audio: %s\n", SDL_GetError());
free(sdl);
return 0;
}
*new_rate = out.freq;
settings->audio.out_rate = out.freq;
#ifdef HAVE_THREADS
sdl->lock = slock_new();
sdl->cond = scond_new();
#endif
sdl->lock = slock_new();
sdl->cond = scond_new();
RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n",
latency, (int)(out.samples * 4 * 1000 / (*new_rate)));
RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n",
latency, (int)(out.samples * 4 * 1000 / settings->audio.out_rate));
/* Create a buffer twice as big as needed and prefill the buffer. */
bufsize = out.samples * 4 * sizeof(int16_t);
tmp = calloc(1, bufsize);
bufsize = out.samples * 4 * sizeof(int16_t);
tmp = calloc(1, bufsize);
sdl->buffer = fifo_new(bufsize);
if (tmp)
@@ -135,15 +128,11 @@ static void *sdl_audio_init(const char *device,
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;
ssize_t ret = 0;
sdl_audio_t *sdl = (sdl_audio_t*)data;
if (sdl->nonblock)
@@ -171,11 +160,9 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size)
if (avail == 0)
{
SDL_UnlockAudio();
#ifdef HAVE_THREADS
slock_lock(sdl->lock);
scond_wait(sdl->cond, sdl->lock);
slock_unlock(sdl->lock);
#endif
}
else
{
@@ -207,7 +194,7 @@ static bool sdl_audio_alive(void *data)
return !sdl->is_paused;
}
static bool sdl_audio_start(void *data, bool is_shutdown)
static bool sdl_audio_start(void *data)
{
sdl_audio_t *sdl = (sdl_audio_t*)data;
sdl->is_paused = false;
@@ -233,10 +220,8 @@ static void sdl_audio_free(void *data)
if (sdl)
{
fifo_free(sdl->buffer);
#ifdef HAVE_THREADS
slock_free(sdl->lock);
scond_free(sdl->cond);
#endif
}
free(sdl);
}
@@ -268,8 +253,6 @@ audio_driver_t audio_sdl = {
#else
"sdl",
#endif
NULL,
NULL,
sdl_audio_write_avail,
NULL
};
File diff suppressed because it is too large. Load diff
-993
View File
@@ -1,993 +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>
#ifdef _WIN32_WINNT
#undef _WIN32_WINNT
#endif
#define _WIN32_WINNT 0x0600
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <winerror.h>
#include <initguid.h>
#include <mmdeviceapi.h>
#include <mmreg.h>
#include <audioclient.h>
#include <propidl.h>
#include <lists/string_list.h>
#include <queues/fifo_queue.h>
#include "../audio_driver.h"
#include "../../verbosity.h"
#include "../../configuration.h"
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); /* DEVPROP_TYPE_STRING */
#define WASAPI_WARN(bool_exp, err_str, warn_exp)\
if (!(bool_exp)) {\
wasapi_warn(err_str);\
warn_exp; }
#define WASAPI_CHECK(bool_exp, err_str, err_exp)\
if (!(bool_exp)) {\
wasapi_err(err_str);\
err_exp; }
#define WASAPI_HR_CHECK(hr, fun_str, err_exp)\
if (FAILED(hr)) {\
wasapi_com_err(fun_str, hr);\
err_exp; }
#define WASAPI_HR_WARN(hr, fun_str, warn_exp)\
if (FAILED(hr)) {\
wasapi_com_warn(fun_str, hr);\
warn_exp; }
#define WASAPI_SR_CHECK(bool_exp, fun_str, err_exp)\
if (!(bool_exp)) {\
wasapi_sys_err(fun_str);\
err_exp; }
#define WASAPI_RELEASE(iface)\
if(iface) {\
iface->lpVtbl->Release(iface);\
iface = NULL; }\
#define WASAPI_FREE(ptr)\
if(ptr) {\
free(ptr);\
ptr = NULL; }\
#define WASAPI_CO_FREE(ptr)\
if(ptr) {\
CoTaskMemFree(ptr);\
ptr = NULL; }\
typedef struct
{
IMMDevice *device;
IAudioClient *client;
IAudioRenderClient *renderer;
HANDLE write_event;
fifo_buffer_t *buffer; /* NULL in unbuffered shared mode */
size_t frame_size; /* 4 or 8 only */
size_t engine_buffer_size;
bool exclusive;
bool blocking;
bool running;
} wasapi_t;
static void wasapi_log(const char *msg)
{
RARCH_LOG("[WASAPI]: %s.\n", msg);
}
static void wasapi_warn(const char *warn)
{
RARCH_WARN("[WASAPI]: %s.\n", warn);
}
static void wasapi_err(const char *err)
{
RARCH_ERR("[WASAPI]: %s.\n", err);
}
static void wasapi_com_warn(const char *fun, HRESULT hr)
{
RARCH_WARN("[WASAPI]: %s failed with error 0x%.8X.\n", fun, hr);
}
static void wasapi_com_err(const char *fun, HRESULT hr)
{
RARCH_ERR("[WASAPI]: %s failed with error 0x%.8X.\n", fun, hr);
}
static void wasapi_sys_err(const char *fun)
{
RARCH_ERR("[WASAPI]: %s failed with error %d.\n", fun, GetLastError());
}
static bool wasapi_check_device_id(IMMDevice *device, const char *id)
{
HRESULT hr;
bool result = false;
LPWSTR dev_id = NULL, dev_cmp_id = NULL;
int id_length = MultiByteToWideChar(CP_ACP, 0, id, -1, NULL, 0);
WASAPI_SR_CHECK(id_length > 0, "MultiByteToWideChar", goto error);
dev_cmp_id = (LPWSTR)malloc(id_length * sizeof(WCHAR));
WASAPI_CHECK(dev_cmp_id, "Out of memory", goto error);
id_length = MultiByteToWideChar(CP_ACP, 0, id, -1, dev_cmp_id, id_length);
WASAPI_SR_CHECK(id_length > 0, "MultiByteToWideChar", goto error);
hr = device->lpVtbl->GetId(device, &dev_id);
WASAPI_HR_CHECK(hr, "IMMDevice::GetId", goto error);
result = lstrcmpW(dev_cmp_id, dev_id) == 0 ? true : false;
WASAPI_CO_FREE(dev_id);
WASAPI_FREE(dev_cmp_id);
return result;
error:
WASAPI_CO_FREE(dev_id);
WASAPI_FREE(dev_cmp_id);
return false;
}
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
wasapi_log("Initializing default device ..");
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
WASAPI_HR_CHECK(hr, "CoCreateInstance", goto error);
if (id)
{
hr = enumerator->lpVtbl->EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
WASAPI_HR_CHECK(hr, "IMMDeviceEnumerator::EnumAudioEndpoints",
goto error);
hr = collection->lpVtbl->GetCount(collection, &dev_count);
WASAPI_HR_CHECK(hr, "IMMDeviceCollection::GetCount", goto error);
for (i = 0; i < dev_count; ++i)
{
hr = collection->lpVtbl->Item(collection, i, &device);
WASAPI_HR_CHECK(hr, "IMMDeviceCollection::Item", continue);
if (wasapi_check_device_id(device, id))
break;
WASAPI_RELEASE(device);
}
}
else
{
hr = enumerator->lpVtbl->GetDefaultAudioEndpoint(enumerator,
eRender, eConsole, &device);
WASAPI_HR_CHECK(hr, "IMMDeviceEnumerator::GetDefaultAudioEndpoint",
goto error);
}
if (!device)
goto error;
WASAPI_RELEASE(collection);
WASAPI_RELEASE(enumerator);
wasapi_log("Device initialized");
return device;
error:
WASAPI_RELEASE(collection);
WASAPI_RELEASE(enumerator);
if (id)
wasapi_warn("Failed to initialize device");
else
wasapi_err("Failed to initialize device");
return NULL;
}
static unsigned wasapi_pref_rate(unsigned i)
{
const unsigned r[] = { 48000, 44100, 96000, 192000 };
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 = device->lpVtbl->Activate(device, &IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
WASAPI_HR_CHECK(hr, "IMMDevice::Activate", 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);
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
if (hr == AUDCLNT_E_ALREADY_INITIALIZED)
{
client->lpVtbl->Release(client);
hr = device->lpVtbl->Activate(device, &IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL);
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_SHARED,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
0, 0, (WAVEFORMATEX*)&wf, NULL);
}
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
{
i = 2; /* break from outer loop too */
break;
}
wasapi_warn("Unsupported format");
rate_res = wasapi_pref_rate(j);
if (rate_res == *rate) /* requested rate is allready tested */
rate_res = wasapi_pref_rate(++j); /* skip it */
}
}
WASAPI_HR_CHECK(hr, "IAudioClient::Initialize", goto error);
*float_fmt = float_fmt_res;
*rate = rate_res;
return client;
error:
WASAPI_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 = device->lpVtbl->Activate(
device, &IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL);
hr = client->lpVtbl->GetDevicePeriod(client, NULL, &minimum_period);
WASAPI_HR_CHECK(hr, "IAudioClient::GetDevicePeriod", 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);
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
if (hr == AUDCLNT_E_BUFFER_SIZE_NOT_ALIGNED)
{
hr = client->lpVtbl->GetBufferSize(client, &buffer_length);
WASAPI_HR_CHECK(hr, "IAudioClient::GetBufferSize", goto error);
client->lpVtbl->Release(client);
hr = device->lpVtbl->Activate(device, &IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL);
buffer_duration = 10000.0 * 1000.0 / rate_res * buffer_length + 0.5;
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
}
if (hr == AUDCLNT_E_ALREADY_INITIALIZED)
{
client->lpVtbl->Release(client);
hr = device->lpVtbl->Activate(device, &IID_IAudioClient,
CLSCTX_ALL, NULL, (void**)&client);
WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL);
hr = client->lpVtbl->Initialize(client, AUDCLNT_SHAREMODE_EXCLUSIVE,
AUDCLNT_STREAMFLAGS_EVENTCALLBACK | AUDCLNT_STREAMFLAGS_NOPERSIST,
buffer_duration, buffer_duration, (WAVEFORMATEX*)&wf, NULL);
}
if (hr != AUDCLNT_E_UNSUPPORTED_FORMAT)
{
WASAPI_WARN(hr != AUDCLNT_E_DEVICE_IN_USE,
"Device already in use", goto error);
WASAPI_WARN(hr != AUDCLNT_E_EXCLUSIVE_MODE_NOT_ALLOWED,
"Exclusive mode disabled", goto error);
i = 2; /* break from outer loop too */
break;
}
wasapi_warn("Unsupported format");
rate_res = wasapi_pref_rate(j);
if (rate_res == *rate) /* requested rate is allready tested */
rate_res = wasapi_pref_rate(++j); /* skip it */
}
}
WASAPI_HR_CHECK(hr, "IAudioClient::Initialize", goto error);
*float_fmt = float_fmt_res;
*rate = rate_res;
return client;
error:
WASAPI_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;
}
}
WASAPI_CHECK(client, "Failed to initialize client", return NULL);
/* next calls are allowed to fail (we losing info only) */
if (*exclusive)
hr = client->lpVtbl->GetDevicePeriod(client, NULL, &device_period);
else
hr = client->lpVtbl->GetDevicePeriod(client, &device_period, NULL);
if (FAILED(hr))
wasapi_com_warn("IAudioClient::GetDevicePeriod", hr);
if (!*exclusive)
{
hr = client->lpVtbl->GetStreamLatency(client, &stream_latency);
if (FAILED(hr))
wasapi_com_warn("IAudioClient::GetStreamLatency", hr);
}
hr = client->lpVtbl->GetBufferSize(client, &buffer_length);
if (FAILED(hr))
wasapi_com_warn("IAudioClient::GetBufferSize", 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;
bool com_initialized = false;
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;
int sh_buffer_length = settings->ints.audio_wasapi_sh_buffer_length;
wasapi_t *w = (wasapi_t*)calloc(1, sizeof(wasapi_t));
w->exclusive = settings->bools.audio_wasapi_exclusive_mode;
WASAPI_CHECK(w, "Out of memory", return NULL);
hr = CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
WASAPI_HR_CHECK(hr, "CoInitializeEx", goto error);
com_initialized = true;
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 = w->client->lpVtbl->GetBufferSize(w->client, &frame_count);
WASAPI_HR_CHECK(hr, "IAudioClient::GetBufferSize", 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);
WASAPI_CHECK(w->buffer, "Out of memory", 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 = w->client->lpVtbl->GetDevicePeriod(w->client, &dev_period, NULL);
WASAPI_HR_CHECK(hr, "IAudioClient::GetDevicePeriod", goto error);
sh_buffer_length = dev_period * rate / 10000000;
}
w->buffer = fifo_new(sh_buffer_length * w->frame_size);
WASAPI_CHECK(w->buffer, "Out of memory", goto error);
RARCH_LOG("[WASAPI]: Intermediate buffer length is %u frames (%.1fms).\n",
sh_buffer_length, (double)sh_buffer_length * 1000.0 / rate);
}
else
wasapi_log("Intermediate buffer is off");
w->write_event = CreateEventA(NULL, FALSE, FALSE, NULL);
WASAPI_SR_CHECK(w->write_event, "CreateEventA", goto error);
hr = w->client->lpVtbl->SetEventHandle(w->client, w->write_event);
WASAPI_HR_CHECK(hr, "IAudioClient::SetEventHandle", goto error);
hr = w->client->lpVtbl->GetService(w->client,
&IID_IAudioRenderClient, (void**)&w->renderer);
WASAPI_HR_CHECK(hr, "IAudioClient::GetService", goto error);
hr = w->renderer->lpVtbl->GetBuffer(w->renderer, frame_count, &dest);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::GetBuffer", goto error);
hr = w->renderer->lpVtbl->ReleaseBuffer(w->renderer, frame_count,
AUDCLNT_BUFFERFLAGS_SILENT);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::ReleaseBuffer", goto error);
hr = w->client->lpVtbl->Start(w->client);
WASAPI_HR_CHECK(hr, "IAudioClient::Start", goto error);
w->running = true;
w->blocking = settings->bools.audio_sync;
return w;
error:
WASAPI_RELEASE(w->renderer);
WASAPI_RELEASE(w->client);
WASAPI_RELEASE(w->device);
if (w->write_event)
CloseHandle(w->write_event);
if (w->buffer)
fifo_free(w->buffer);
free(w);
if (com_initialized)
CoUninitialize();
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;
HRESULT hr = w->renderer->lpVtbl->GetBuffer(w->renderer, frame_count, &dest);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::GetBuffer", return false)
memcpy(dest, data, size);
hr = w->renderer->lpVtbl->ReleaseBuffer(w->renderer, frame_count, 0);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::ReleaseBuffer", 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;
HRESULT hr = w->renderer->lpVtbl->GetBuffer(w->renderer, frame_count, &dest);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::GetBuffer", return false)
fifo_read(w->buffer, dest, size);
hr = w->renderer->lpVtbl->ReleaseBuffer(w->renderer, frame_count, 0);
WASAPI_HR_CHECK(hr, "IAudioRenderClient::ReleaseBuffer", return false);
return true;
}
static ssize_t wasapi_write_sh(wasapi_t *w, const void * data, size_t size)
{
DWORD ir;
size_t read_avail;
size_t write_avail;
HRESULT hr;
bool br;
ssize_t writen = -1;
UINT32 padding = 0;
if (w->buffer)
{
write_avail = fifo_write_avail(w->buffer);
if (!write_avail)
{
if (w->blocking)
{
ir = WaitForSingleObject(w->write_event, INFINITE);
WASAPI_SR_CHECK(ir == WAIT_OBJECT_0, "WaitForSingleObject", return -1);
}
hr = w->client->lpVtbl->GetCurrentPadding(w->client, &padding);
WASAPI_HR_CHECK(hr, "IAudioClient::GetCurrentPadding", return -1);
read_avail = fifo_read_avail(w->buffer);
write_avail = w->engine_buffer_size - padding * w->frame_size;
writen = read_avail < write_avail ? read_avail : write_avail;
if (writen)
{
br = wasapi_flush_buffer(w, writen);
if (!br)
return -1;
}
}
write_avail = fifo_write_avail(w->buffer);
writen = size < write_avail ? size : write_avail;
if (writen)
fifo_write(w->buffer, data, writen);
}
else
{
if (w->blocking)
{
ir = WaitForSingleObject(w->write_event, INFINITE);
WASAPI_SR_CHECK(ir == WAIT_OBJECT_0, "WaitForSingleObject", return -1);
}
hr = w->client->lpVtbl->GetCurrentPadding(w->client, &padding);
WASAPI_HR_CHECK(hr, "IAudioClient::GetCurrentPadding", return -1);
write_avail = w->engine_buffer_size - padding * w->frame_size;
if (!write_avail)
return 0;
writen = size < write_avail ? size : write_avail;
if (writen)
{
br = wasapi_flush(w, data, writen);
if (!br)
return -1;
}
}
return writen;
}
static ssize_t wasapi_write_ex(wasapi_t *w, const void * data, size_t size)
{
DWORD ir;
size_t write_avail;
bool br = false;
ssize_t writen = 0;
write_avail = fifo_write_avail(w->buffer);
if (!write_avail)
{
ir = WaitForSingleObject(w->write_event, w->blocking ? INFINITE : 0);
if (ir != WAIT_OBJECT_0 && w->blocking)
{
wasapi_sys_err("WaitForSingleObject");
return -1;
}
if (ir != WAIT_OBJECT_0)
return 0;
br = wasapi_flush_buffer(w, w->engine_buffer_size);
if (!br)
return -1;
write_avail = w->engine_buffer_size;
}
writen = size < write_avail ? size : write_avail;
fifo_write(w->buffer, data, writen);
return writen;
}
static ssize_t wasapi_write(void *wh, const void *data, size_t size)
{
size_t writen;
ssize_t ir;
wasapi_t *w = (wasapi_t*)wh;
if (w->blocking)
{
for (writen = 0, ir = -1; writen < size; writen += ir)
{
if (w->exclusive)
ir = wasapi_write_ex(w, data + writen, size - writen);
else
ir = wasapi_write_sh(w, data + writen, size - writen);
if (ir == -1)
return -1;
}
}
else if (w->exclusive)
writen = wasapi_write_ex(w, data, size);
else
writen = wasapi_write_sh(w, data, size);
return writen;
}
static bool wasapi_stop(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
HRESULT hr = w->client->lpVtbl->Stop(w->client);
WASAPI_HR_CHECK(hr, "IAudioClient::Stop", return !w->running);
w->running = false;
return true;
}
static bool wasapi_start(void *wh, bool u)
{
wasapi_t *w = (wasapi_t*)wh;
HRESULT hr = w->client->lpVtbl->Start(w->client);
if (hr == AUDCLNT_E_NOT_STOPPED)
return true;
WASAPI_HR_CHECK(hr, "IAudioClient::Start", 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->blocking = !nonblock;
}
static void wasapi_free(void *wh)
{
wasapi_t *w = (wasapi_t*)wh;
HANDLE write_event = w->write_event;
DWORD ir;
WASAPI_RELEASE(w->renderer);
if (w->client)
w->client->lpVtbl->Stop(w->client);
WASAPI_RELEASE(w->client);
WASAPI_RELEASE(w->device);
CoUninitialize();
if (w->buffer)
fifo_free(w->buffer);
free(w);
ir = WaitForSingleObject(write_event, 20);
if (ir == WAIT_FAILED)
wasapi_sys_err("WaitForSingleObject");
/* If event isn't signaled log and leak */
WASAPI_CHECK(ir == WAIT_OBJECT_0, "Memory leak in wasapi_free", 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_new(void *u)
{
HRESULT hr;
UINT i;
PROPVARIANT prop_var;
int ir;
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 prop_var_init = false;
bool br = false;
char *dev_id_str = NULL;
char *dev_name_str = NULL;
struct string_list *sl = string_list_new();
wasapi_log("Enumerating active devices ..");
WASAPI_CHECK(sl, "string_list_new failed", return NULL);
attr.i = 0;
hr = CoCreateInstance(&CLSID_MMDeviceEnumerator, NULL, CLSCTX_ALL,
&IID_IMMDeviceEnumerator, (void **)&enumerator);
WASAPI_HR_CHECK(hr, "CoCreateInstance", goto error);
hr = enumerator->lpVtbl->EnumAudioEndpoints(enumerator,
eRender, DEVICE_STATE_ACTIVE, &collection);
WASAPI_HR_CHECK(hr, "IMMDeviceEnumerator::EnumAudioEndpoints", goto error);
hr = collection->lpVtbl->GetCount(collection, &dev_count);
WASAPI_HR_CHECK(hr, "IMMDeviceCollection::GetCount", goto error);
for (i = 0; i < dev_count; ++i)
{
hr = collection->lpVtbl->Item(collection, i, &device);
WASAPI_HR_CHECK(hr, "IMMDeviceCollection::Item", goto error);
hr = device->lpVtbl->GetId(device, &dev_id_wstr);
WASAPI_HR_CHECK(hr, "IMMDevice::GetId", goto error);
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
NULL, 0, NULL, NULL);
WASAPI_SR_CHECK(ir, "WideCharToMultiByte", goto error);
dev_id_str = (char *)malloc(ir);
WASAPI_CHECK(dev_id_str, "Out of memory", goto error);
ir = WideCharToMultiByte(CP_ACP, 0, dev_id_wstr, -1,
dev_id_str, ir, NULL, NULL);
WASAPI_SR_CHECK(ir, "WideCharToMultiByte", goto error);
hr = device->lpVtbl->OpenPropertyStore(device, STGM_READ, &prop_store);
WASAPI_HR_CHECK(hr, "IMMDevice::OpenPropertyStore", goto error);
PropVariantInit(&prop_var);
prop_var_init = true;
hr = prop_store->lpVtbl->GetValue(prop_store,
&PKEY_Device_FriendlyName, &prop_var);
WASAPI_HR_CHECK(hr, "IPropertyStore::GetValue", goto error);
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
NULL, 0, NULL, NULL);
WASAPI_SR_CHECK(ir, "WideCharToMultiByte", goto error);
dev_name_str = (char *)malloc(ir);
WASAPI_CHECK(dev_name_str, "Out of memory", goto error);
ir = WideCharToMultiByte(CP_ACP, 0, prop_var.pwszVal, -1,
dev_name_str, ir, NULL, NULL);
WASAPI_SR_CHECK(ir, "WideCharToMultiByte", goto error);
RARCH_LOG("[WASAPI]: %s %s\n", dev_name_str, dev_id_str);
br = string_list_append(sl, dev_id_str, attr);
WASAPI_CHECK(br, "string_list_append failed", goto error);
PropVariantClear(&prop_var);
prop_var_init = false;
WASAPI_CO_FREE(dev_id_wstr);
WASAPI_FREE(dev_id_str);
WASAPI_FREE(dev_name_str);
WASAPI_RELEASE(prop_store);
WASAPI_RELEASE(device);
}
WASAPI_RELEASE(collection);
WASAPI_RELEASE(enumerator);
wasapi_log("Devices enumerated");
return sl;
error:
WASAPI_FREE(dev_id_str);
WASAPI_FREE(dev_name_str);
if (prop_var_init)
PropVariantClear(&prop_var);
WASAPI_RELEASE(prop_store);
WASAPI_CO_FREE(dev_id_wstr);
WASAPI_RELEASE(device);
WASAPI_RELEASE(collection);
WASAPI_RELEASE(enumerator);
if (sl)
string_list_free(sl);
wasapi_err("Device enumeration failed");
return NULL;
}
static void wasapi_device_list_free(void *u, void *slp)
{
struct string_list *sl = (struct string_list*)slp;
string_list_free(sl);
}
static size_t wasapi_write_avail(void *wh)
{
HRESULT hr;
wasapi_t *w = (wasapi_t*)wh;
UINT32 padding = 0;
if (w->buffer)
return fifo_write_avail(w->buffer);
hr = w->client->lpVtbl->GetCurrentPadding(w->client, &padding);
WASAPI_HR_CHECK(hr, "IAudioClient::GetCurrentPadding", 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",
wasapi_device_list_new,
wasapi_device_list_free,
wasapi_write_avail,
wasapi_buffer_size
};
-337
View File
@@ -1,337 +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 "audio/audio_driver.h"
typedef struct
{
AXMVoice* mvoice;
uint16_t* buffer_l;
uint16_t* buffer_r;
bool nonblocking;
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)
{
/*possibly called before unregister */
if(wiiu_cb_ax == NULL)
return;
ax_audio_t *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 = {0xF000, 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)
{
int i;
size_t countAvail = 0;
ax_audio_t* ax = (ax_audio_t*)data;
const uint16_t* src = buf;
int count = size >> 2;
if(!size || (size & 0x3))
return 0;
if(count > AX_AUDIO_MAX_FREE)
count = AX_AUDIO_MAX_FREE;
countAvail = ((ax->written > AX_AUDIO_MAX_FREE) ? 0 : (AX_AUDIO_MAX_FREE - ax->written));
if (ax->nonblocking)
{
/* Not enough available for 3ms of data */
if(countAvail < AX_AUDIO_SAMPLE_COUNT)
count = 0;
}
else if(countAvail < count)
{
/* Sync, wait for free memory */
while(AXIsMultiVoiceRunning(ax->mvoice) && (countAvail < count))
{
OSYieldThread(); /* Gives threads with same priority time to run */
countAvail = (ax->written > AX_AUDIO_MAX_FREE ? 0 : (AX_AUDIO_MAX_FREE - ax->written));
}
}
/* Over available space, do as much as possible */
if(count > countAvail)
count = countAvail;
/* make sure we have input size */
if(count > 0)
{
/* write in new data */
size_t startPos = ax->pos;
int flushP2needed = 0;
int flushP2 = 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)
{
flushP2needed = 1;
flushP2 = ((count << 1) - i);
DCStoreRangeNoSync(ax->buffer_l+startPos, (AX_AUDIO_COUNT-startPos) << 1);
DCStoreRangeNoSync(ax->buffer_r+startPos, (AX_AUDIO_COUNT-startPos) << 1);
}
}
/* standard cache store case */
if(!flushP2needed)
{
DCStoreRangeNoSync(ax->buffer_l+startPos, count << 1);
DCStoreRange(ax->buffer_r+startPos, count << 1);
}
/* store the rest after wrap */
else if(flushP2 > 0)
{
DCStoreRangeNoSync(ax->buffer_l, flushP2);
DCStoreRange(ax->buffer_r, flushP2);
}
/* 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->nonblocking = 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,
NULL,
/* ax_audio_write_avail, */
/* ax_audio_buffer_size */
};
+6 -24
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -14,12 +14,6 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(_XBOX) && (_MSC_VER == 1310)
#ifndef _WIN32_DCOM
#define _WIN32_DCOM
#endif
#endif
#include <stdio.h>
#include <stdint.h>
#include <stddef.h>
@@ -29,14 +23,10 @@
#include <compat/msvc.h>
#include <retro_miscellaneous.h>
#if defined(_MSC_VER) && (_WIN32_WINNT <= _WIN32_WINNT_WIN2K)
/* needed for CoInitializeEx */
#define _WIN32_DCOM
#endif
#include "xaudio.h"
#include "../audio_driver.h"
#include "../../configuration.h"
#include "../../verbosity.h"
typedef struct xaudio2 xaudio2_t;
@@ -147,10 +137,6 @@ static void xaudio2_free(xaudio2_t *handle)
delete handle;
}
#ifndef COINIT_MULTITHREADED
#define COINIT_MULTITHREADED 0x00
#endif
static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels,
size_t size, unsigned device)
{
@@ -203,7 +189,7 @@ static size_t xaudio2_write_avail(xaudio2_t *handle)
static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_)
{
unsigned bytes = bytes_;
unsigned bytes = bytes_;
const uint8_t *buffer = (const uint8_t*)buf;
while (bytes)
@@ -239,13 +225,11 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_)
return bytes_;
}
static void *xa_init(const char *device, unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
static void *xa_init(const char *device, unsigned rate, unsigned latency)
{
size_t bufsize;
unsigned device_index = 0;
xa_t *xa = (xa_t*)calloc(1, sizeof(*xa));
xa_t *xa = (xa_t*)calloc(1, sizeof(*xa));
if (!xa)
return NULL;
@@ -316,7 +300,7 @@ static void xa_set_nonblock_state(void *data, bool state)
xa->nonblock = state;
}
static bool xa_start(void *data, bool is_shutdown)
static bool xa_start(void *data)
{
xa_t *xa = (xa_t*)data;
xa->is_paused = false;
@@ -363,8 +347,6 @@ audio_driver_t audio_xa = {
xa_free,
xa_use_float,
"xaudio",
NULL,
NULL,
xa_write_avail,
xa_buffer_size,
};
+1 -1
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2011-2016 - Daniel De Matteis
* Copyright (C) 2010-2014 - OV2
*
* RetroArch is free software: you can redistribute it and/or modify it under the terms
+6 -9
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -22,6 +22,7 @@
#include <retro_inline.h>
#include "../audio_driver.h"
#include "../../configuration.h"
#define SOUND_FREQUENCY 48000
#define MAX_BUFFER 2048
@@ -34,11 +35,10 @@ typedef struct
} xenon_audio_t;
static void *xenon360_audio_init(const char *device,
unsigned rate, unsigned latency,
unsigned block_frames,
unsigned *new_rate)
unsigned rate, unsigned latency)
{
static bool inited = false;
settings_t *settings = config_get_ptr();
if (!inited)
{
@@ -46,8 +46,7 @@ static void *xenon360_audio_init(const char *device,
inited = true;
}
*new_rate = SOUND_FREQUENCY;
settings->audio.out_rate = SOUND_FREQUENCY;
return calloc(1, sizeof(xenon_audio_t));
}
@@ -112,7 +111,7 @@ static void xenon360_audio_set_nonblock_state(void *data, bool state)
xa->nonblock = state;
}
static bool xenon360_audio_start(void *data, bool is_shutdown)
static bool xenon360_audio_start(void *data)
{
xenon_audio_t *xa = data;
xa->is_paused = false;
@@ -147,8 +146,6 @@ audio_driver_t audio_xenon360 = {
xenon360_audio_free,
xenon360_use_float,
"xenon360",
NULL,
NULL,
xenon360_write_avail,
NULL
};
+14 -15
View File
@@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel ( aliaspider@gmail.com )
* Copyright (C) 2014-2016 - 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-
@@ -25,9 +25,8 @@
#include <retro_inline.h>
#include <retro_miscellaneous.h>
#include <memalign.h>
#include <math/float_minmax.h>
#include <audio/audio_resampler.h>
#include "../audio_resampler_driver.h"
/* Since SSE and NEON don't provide support for trigonometric functions
* we approximate those with polynoms
@@ -60,10 +59,10 @@ typedef struct rarch_CC_resampler
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 = (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;
audio_frame_float_t *outp = (audio_frame_float_t*)data->data_out;
(void)re_;
@@ -197,15 +196,15 @@ static void resampler_CC_downsample(void *re_, struct resampler_data *data)
__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_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_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);
__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);
vec_w1 = _mm_mul_ps(vec_w1, vec_b);
vec_w2 = _mm_mul_ps(vec_w2, vec_b);
(void)vec_ww1;
(void)vec_ww2;
@@ -272,7 +271,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data)
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 b = 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]);
@@ -348,7 +347,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data)
}
#elif defined (__ARM_NEON__) && !defined(DONT_WANT_ARM_OPTIMIZATIONS)
#elif defined (__ARM_NEON__)
#define CC_RESAMPLER_IDENT "NEON"
@@ -447,7 +446,7 @@ static void resampler_CC_upsample(void *re_, struct resampler_data *data)
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 b = MIN(data->ratio, 1.00); /* cutoff frequency. */
float ratio = 1.0 / data->ratio;
while (inp != inp_max)
@@ -540,7 +539,7 @@ static void resampler_CC_free(void *re_)
(void)re_;
}
retro_resampler_t CC_resampler = {
rarch_resampler_t CC_resampler = {
resampler_CC_init,
resampler_CC_process,
resampler_CC_free,
+1 -13
View File
@@ -1,5 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2017 - Ali Bouhlel ( aliaspider@gmail.com )
* Copyright (C) 2014-2015 - 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-
@@ -24,13 +24,7 @@
#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);
@@ -202,13 +196,7 @@ 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);
@@ -1,31 +1,23 @@
/* Copyright (C) 2010-2017 The RetroArch team
/* RetroArch - A frontend for libretro.
* Copyright (C) 2014-2016 - Ali Bouhlel ( aliaspider@gmail.com )
*
* ---------------------------------------------------------------------------------------
* The following license statement only applies to this file (nearest_resampler.c).
* ---------------------------------------------------------------------------------------
* 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.
*
* Permission is hereby granted, free of charge,
* to any person obtaining a copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
* and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* 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.
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* 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 <math.h>
#include <audio/audio_resampler.h>
#include "../audio_resampler_driver.h"
typedef struct rarch_nearest_resampler
{
float fraction;
@@ -78,7 +70,7 @@ static void *resampler_nearest_init(const struct resampler_config *config,
return re;
}
retro_resampler_t nearest_resampler = {
rarch_resampler_t nearest_resampler = {
resampler_nearest_init,
resampler_nearest_process,
resampler_nearest_free,
@@ -1,6 +1,5 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* Copyright (C) 2014-2016 - 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-
@@ -14,35 +13,36 @@
* If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef _MENU_FILEBROWSER_H
#define _MENU_FILEBROWSER_H
#include <stdint.h>
#include <stdlib.h>
#include <retro_common_api.h>
RETRO_BEGIN_DECLS
enum filebrowser_enums
#include <math.h>
#include "../audio_resampler_driver.h"
typedef struct rarch_null_resampler
{
FILEBROWSER_NONE = 0,
FILEBROWSER_SELECT_DIR,
FILEBROWSER_SCAN_DIR,
FILEBROWSER_SELECT_FILE,
FILEBROWSER_SELECT_IMAGE,
FILEBROWSER_SELECT_FONT,
FILEBROWSER_SELECT_COLLECTION
void *empty;
} rarch_null_resampler_t;
static void resampler_null_process(
void *re_, struct resampler_data *data)
{
}
static void resampler_null_free(void *re_)
{
}
static void *resampler_null_init(const struct resampler_config *config,
double bandwidth_mod, resampler_simd_mask_t mask)
{
return (void*)0;
}
rarch_resampler_t null_resampler = {
resampler_null_init,
resampler_null_process,
resampler_null_free,
RESAMPLER_API_VERSION,
"null",
"null"
};
enum filebrowser_enums filebrowser_get_type(void);
void filebrowser_clear_type(void);
void filebrowser_set_type(enum filebrowser_enums type);
void filebrowser_parse(void *data, unsigned type);
RETRO_END_DECLS
#endif
+483
View File
@@ -0,0 +1,483 @@
/* 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/>.
*/
/* Bog-standard windowed SINC implementation. */
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#ifdef __SSE__
#include <xmmintrin.h>
#endif
#include <retro_inline.h>
#include <filters.h>
#include <memalign.h>
#include "../audio_resampler_driver.h"
/* Rough SNR values for upsampling:
* LOWEST: 40 dB
* LOWER: 55 dB
* NORMAL: 70 dB
* HIGHER: 110 dB
* HIGHEST: 140 dB
*/
/* TODO, make all this more configurable. */
#if defined(SINC_LOWEST_QUALITY)
#define SINC_WINDOW_LANCZOS
#define CUTOFF 0.98
#define PHASE_BITS 12
#define SINC_COEFF_LERP 0
#define SUBPHASE_BITS 10
#define SIDELOBES 2
#define ENABLE_AVX 0
#elif defined(SINC_LOWER_QUALITY)
#define SINC_WINDOW_LANCZOS
#define CUTOFF 0.98
#define PHASE_BITS 12
#define SUBPHASE_BITS 10
#define SINC_COEFF_LERP 0
#define SIDELOBES 4
#define ENABLE_AVX 0
#elif defined(SINC_HIGHER_QUALITY)
#define SINC_WINDOW_KAISER
#define SINC_WINDOW_KAISER_BETA 10.5
#define CUTOFF 0.90
#define PHASE_BITS 10
#define SUBPHASE_BITS 14
#define SINC_COEFF_LERP 1
#define SIDELOBES 32
#define ENABLE_AVX 1
#elif defined(SINC_HIGHEST_QUALITY)
#define SINC_WINDOW_KAISER
#define SINC_WINDOW_KAISER_BETA 14.5
#define CUTOFF 0.962
#define PHASE_BITS 10
#define SUBPHASE_BITS 14
#define SINC_COEFF_LERP 1
#define SIDELOBES 128
#define ENABLE_AVX 1
#else
#define SINC_WINDOW_KAISER
#define SINC_WINDOW_KAISER_BETA 5.5
#define CUTOFF 0.825
#define PHASE_BITS 8
#define SUBPHASE_BITS 16
#define SINC_COEFF_LERP 1
#define SIDELOBES 8
#define ENABLE_AVX 0
#endif
/* For the little amount of taps we're using,
* SSE1 is faster than AVX for some reason.
* AVX code is kept here though as by increasing number
* of sinc taps, the AVX code is clearly faster than SSE1.
*/
#if defined(__AVX__) && ENABLE_AVX
#include <immintrin.h>
#endif
#define PHASES (1 << (PHASE_BITS + SUBPHASE_BITS))
#define TAPS (SIDELOBES * 2)
#define SUBPHASE_MASK ((1 << SUBPHASE_BITS) - 1)
#define SUBPHASE_MOD (1.0f / (1 << SUBPHASE_BITS))
typedef struct rarch_sinc_resampler
{
float *phase_table;
float *buffer_l;
float *buffer_r;
unsigned taps;
unsigned ptr;
uint32_t time;
/* A buffer for phase_table, buffer_l and buffer_r
* are created in a single calloc().
* Ensure that we get as good cache locality as we can hope for. */
float *main_buffer;
} rarch_sinc_resampler_t;
#if defined(SINC_WINDOW_LANCZOS)
#define window_function(idx) (lanzcos_window_function(idx))
#elif defined(SINC_WINDOW_KAISER)
#define window_function(idx) (kaiser_window_function(idx, SINC_WINDOW_KAISER_BETA))
#else
#error "No SINC window function defined."
#endif
static void init_sinc_table(rarch_sinc_resampler_t *resamp, double cutoff,
float *phase_table, int phases, int taps, bool calculate_delta)
{
int i, j;
double window_mod = window_function(0.0); /* Need to normalize w(0) to 1.0. */
int stride = calculate_delta ? 2 : 1;
double sidelobes = taps / 2.0;
for (i = 0; i < phases; i++)
{
for (j = 0; j < taps; j++)
{
double sinc_phase;
float val;
int n = j * phases + i;
double window_phase = (double)n / (phases * taps); /* [0, 1). */
window_phase = 2.0 * window_phase - 1.0; /* [-1, 1) */
sinc_phase = sidelobes * window_phase;
val = cutoff * sinc(M_PI * sinc_phase * cutoff) *
window_function(window_phase) / window_mod;
phase_table[i * stride * taps + j] = val;
}
}
if (calculate_delta)
{
int phase;
int p;
for (p = 0; p < phases - 1; p++)
{
for (j = 0; j < taps; j++)
{
float delta = phase_table[(p + 1) * stride * taps + j] -
phase_table[p * stride * taps + j];
phase_table[(p * stride + 1) * taps + j] = delta;
}
}
phase = phases - 1;
for (j = 0; j < taps; j++)
{
float val, delta;
double sinc_phase;
int n = j * phases + (phase + 1);
double window_phase = (double)n / (phases * taps); /* (0, 1]. */
window_phase = 2.0 * window_phase - 1.0; /* (-1, 1] */
sinc_phase = sidelobes * window_phase;
val = cutoff * sinc(M_PI * sinc_phase * cutoff) *
window_function(window_phase) / window_mod;
delta = (val - phase_table[phase * stride * taps + j]);
phase_table[(phase * stride + 1) * taps + j] = delta;
}
}
}
#if !(defined(__AVX__) && ENABLE_AVX) && !defined(__SSE__)
static INLINE void process_sinc_C(rarch_sinc_resampler_t *resamp,
float *out_buffer)
{
unsigned i;
float sum_l = 0.0f;
float sum_r = 0.0f;
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
float delta = (float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD;
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
for (i = 0; i < taps; i++)
{
#if SINC_COEFF_LERP
float sinc_val = phase_table[i] + delta_table[i] * delta;
#else
float sinc_val = phase_table[i];
#endif
sum_l += buffer_l[i] * sinc_val;
sum_r += buffer_r[i] * sinc_val;
}
out_buffer[0] = sum_l;
out_buffer[1] = sum_r;
}
#endif
#if defined(__AVX__) && ENABLE_AVX
#define process_sinc_func process_sinc
static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
{
unsigned i;
__m256 sum_l = _mm256_setzero_ps();
__m256 sum_r = _mm256_setzero_ps();
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
__m256 delta = _mm256_set1_ps((float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD);
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
for (i = 0; i < taps; i += 8)
{
__m256 buf_l = _mm256_loadu_ps(buffer_l + i);
__m256 buf_r = _mm256_loadu_ps(buffer_r + i);
#if SINC_COEFF_LERP
__m256 deltas = _mm256_load_ps(delta_table + i);
__m256 sinc = _mm256_add_ps(_mm256_load_ps(phase_table + i),
_mm256_mul_ps(deltas, delta));
#else
__m256 sinc = _mm256_load_ps(phase_table + i);
#endif
sum_l = _mm256_add_ps(sum_l, _mm256_mul_ps(buf_l, sinc));
sum_r = _mm256_add_ps(sum_r, _mm256_mul_ps(buf_r, sinc));
}
/* hadd on AVX is weird, and acts on low-lanes
* and high-lanes separately. */
__m256 res_l = _mm256_hadd_ps(sum_l, sum_l);
__m256 res_r = _mm256_hadd_ps(sum_r, sum_r);
res_l = _mm256_hadd_ps(res_l, res_l);
res_r = _mm256_hadd_ps(res_r, res_r);
res_l = _mm256_add_ps(_mm256_permute2f128_ps(res_l, res_l, 1), res_l);
res_r = _mm256_add_ps(_mm256_permute2f128_ps(res_r, res_r, 1), res_r);
/* This is optimized to mov %xmmN, [mem].
* There doesn't seem to be any _mm256_store_ss intrinsic. */
_mm_store_ss(out_buffer + 0, _mm256_extractf128_ps(res_l, 0));
_mm_store_ss(out_buffer + 1, _mm256_extractf128_ps(res_r, 0));
}
#elif defined(__SSE__)
#define process_sinc_func process_sinc
static void process_sinc(rarch_sinc_resampler_t *resamp, float *out_buffer)
{
unsigned i;
__m128 sum;
__m128 sum_l = _mm_setzero_ps();
__m128 sum_r = _mm_setzero_ps();
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned taps = resamp->taps;
unsigned phase = resamp->time >> SUBPHASE_BITS;
#if SINC_COEFF_LERP
const float *phase_table = resamp->phase_table + phase * taps * 2;
const float *delta_table = phase_table + taps;
__m128 delta = _mm_set1_ps((float)
(resamp->time & SUBPHASE_MASK) * SUBPHASE_MOD);
#else
const float *phase_table = resamp->phase_table + phase * taps;
#endif
for (i = 0; i < taps; i += 4)
{
__m128 buf_l = _mm_loadu_ps(buffer_l + i);
__m128 buf_r = _mm_loadu_ps(buffer_r + i);
#if SINC_COEFF_LERP
__m128 deltas = _mm_load_ps(delta_table + i);
__m128 _sinc = _mm_add_ps(_mm_load_ps(phase_table + i),
_mm_mul_ps(deltas, delta));
#else
__m128 _sinc = _mm_load_ps(phase_table + i);
#endif
sum_l = _mm_add_ps(sum_l, _mm_mul_ps(buf_l, _sinc));
sum_r = _mm_add_ps(sum_r, _mm_mul_ps(buf_r, _sinc));
}
/* Them annoying shuffles.
* sum_l = { l3, l2, l1, l0 }
* sum_r = { r3, r2, r1, r0 }
*/
sum = _mm_add_ps(_mm_shuffle_ps(sum_l, sum_r,
_MM_SHUFFLE(1, 0, 1, 0)),
_mm_shuffle_ps(sum_l, sum_r, _MM_SHUFFLE(3, 2, 3, 2)));
/* sum = { r1, r0, l1, l0 } + { r3, r2, l3, l2 }
* sum = { R1, R0, L1, L0 }
*/
sum = _mm_add_ps(_mm_shuffle_ps(sum, sum, _MM_SHUFFLE(3, 3, 1, 1)), sum);
/* sum = {R1, R1, L1, L1 } + { R1, R0, L1, L0 }
* sum = { X, R, X, L }
*/
/* Store L */
_mm_store_ss(out_buffer + 0, sum);
/* movehl { X, R, X, L } == { X, R, X, R } */
_mm_store_ss(out_buffer + 1, _mm_movehl_ps(sum, sum));
}
#elif defined(__ARM_NEON__) && !defined(VITA)
#if SINC_COEFF_LERP
#error "NEON asm does not support SINC lerp."
#endif
/* Need to make this function pointer as Android doesn't
* have built-in targets for NEON and plain ARMv7a.
*/
static void (*process_sinc_func)(rarch_sinc_resampler_t *resamp,
float *out_buffer);
/* Assumes that taps >= 8, and that taps is a multiple of 8. */
void process_sinc_neon_asm(float *out, const float *left,
const float *right, const float *coeff, unsigned taps);
static void process_sinc_neon(rarch_sinc_resampler_t *resamp,
float *out_buffer)
{
const float *buffer_l = resamp->buffer_l + resamp->ptr;
const float *buffer_r = resamp->buffer_r + resamp->ptr;
unsigned phase = resamp->time >> SUBPHASE_BITS;
unsigned taps = resamp->taps;
const float *phase_table = resamp->phase_table + phase * taps;
process_sinc_neon_asm(out_buffer, buffer_l, buffer_r, phase_table, taps);
}
#else /* Plain ol' C99 */
#define process_sinc_func process_sinc_C
#endif
static void resampler_sinc_process(void *re_, struct resampler_data *data)
{
rarch_sinc_resampler_t *re = (rarch_sinc_resampler_t*)re_;
uint32_t ratio = PHASES / data->ratio;
const float *input = data->data_in;
float *output = data->data_out;
size_t frames = data->input_frames;
size_t out_frames = 0;
while (frames)
{
while (frames && re->time >= PHASES)
{
/* Push in reverse to make filter more obvious. */
if (!re->ptr)
re->ptr = re->taps;
re->ptr--;
re->buffer_l[re->ptr + re->taps] = re->buffer_l[re->ptr] = *input++;
re->buffer_r[re->ptr + re->taps] = re->buffer_r[re->ptr] = *input++;
re->time -= PHASES;
frames--;
}
while (re->time < PHASES)
{
process_sinc_func(re, output);
output += 2;
out_frames++;
re->time += ratio;
}
}
data->output_frames = out_frames;
}
static void resampler_sinc_free(void *re)
{
rarch_sinc_resampler_t *resampler = (rarch_sinc_resampler_t*)re;
if (resampler)
memalign_free(resampler->main_buffer);
free(resampler);
}
static void *resampler_sinc_new(const struct resampler_config *config,
double bandwidth_mod, resampler_simd_mask_t mask)
{
size_t phase_elems, elems;
double cutoff;
rarch_sinc_resampler_t *re = (rarch_sinc_resampler_t*)
calloc(1, sizeof(*re));
if (!re)
return NULL;
(void)config;
re->taps = TAPS;
cutoff = CUTOFF;
/* Downsampling, must lower cutoff, and extend number of
* taps accordingly to keep same stopband attenuation. */
if (bandwidth_mod < 1.0)
{
cutoff *= bandwidth_mod;
re->taps = (unsigned)ceil(re->taps / bandwidth_mod);
}
/* Be SIMD-friendly. */
#if (defined(__AVX__) && ENABLE_AVX) || (defined(__ARM_NEON__)&& !defined(VITA))
re->taps = (re->taps + 7) & ~7;
#else
re->taps = (re->taps + 3) & ~3;
#endif
phase_elems = (1 << PHASE_BITS) * re->taps;
#if SINC_COEFF_LERP
phase_elems *= 2;
#endif
elems = phase_elems + 4 * re->taps;
re->main_buffer = (float*)memalign_alloc(128, sizeof(float) * elems);
if (!re->main_buffer)
goto error;
re->phase_table = re->main_buffer;
re->buffer_l = re->main_buffer + phase_elems;
re->buffer_r = re->buffer_l + 2 * re->taps;
init_sinc_table(re, cutoff, re->phase_table,
1 << PHASE_BITS, re->taps, SINC_COEFF_LERP);
#if defined(__ARM_NEON__) && !defined(VITA)
process_sinc_func = mask & RESAMPLER_SIMD_NEON
? process_sinc_neon : process_sinc_C;
#endif
return re;
error:
resampler_sinc_free(re);
return NULL;
}
rarch_resampler_t sinc_resampler = {
resampler_sinc_new,
resampler_sinc_process,
resampler_sinc_free,
RESAMPLER_API_VERSION,
"sinc",
"sinc"
};
@@ -0,0 +1,60 @@
/* 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/>.
*/
#if defined(__ARM_NEON__)
#ifndef __MACH__
.arm
#endif
.align 4
.globl process_sinc_neon_asm
.globl _process_sinc_neon_asm
# void process_sinc_neon(float *out, const float *left, const float *right, const float *coeff, unsigned taps)
# Assumes taps is >= 8, and a multiple of 8.
process_sinc_neon_asm:
_process_sinc_neon_asm:
push {r4, lr}
vmov.f32 q0, #0.0
vmov.f32 q8, #0.0
# Taps argument (r4) goes on stack in armeabi.
ldr r4, [sp, #8]
1:
# Left
vld1.f32 {q2-q3}, [r1]!
# Right
vld1.f32 {q10-q11}, [r2]!
# Coeff
vld1.f32 {q12-q13}, [r3, :128]!
# Left / Right
vmla.f32 q0, q2, q12
vmla.f32 q8, q10, q12
vmla.f32 q0, q3, q13
vmla.f32 q8, q11, q13
subs r4, r4, #8
bne 1b
# Add everything together
vadd.f32 d0, d0, d1
vadd.f32 d16, d16, d17
vpadd.f32 d0, d0, d16
vst1.f32 d0, [r0]
pop {r4, pc}
#endif
+25 -29
View File
@@ -1,6 +1,6 @@
/* RetroArch - A frontend for libretro.
* Copyright (C) 2010-2014 - Hans-Kristian Arntzen
* Copyright (C) 2011-2017 - Daniel De Matteis
* 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-
@@ -65,15 +65,14 @@
#include <ctype.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <stdarg.h>
#include <time.h>
#include <errno.h>
#include <compat/strl.h>
#include <retro_inline.h>
#include <retro_assert.h>
#include <retro_miscellaneous.h>
#include <retro_timers.h>
/*
****************************************************************************
@@ -213,7 +212,7 @@ static INLINE int rsnd_format_to_samplesize ( uint16_t fmt )
int rsd_samplesize( rsound_t *rd )
{
retro_assert(rd != NULL);
assert(rd != NULL);
return rd->samplesize;
}
@@ -1299,7 +1298,7 @@ static int rsnd_reset(rsound_t *rd)
int rsd_stop(rsound_t *rd)
{
retro_assert(rd != NULL);
assert(rd != NULL);
rsnd_stop_thread(rd);
const char buf[] = "RSD 5 STOP";
@@ -1315,7 +1314,7 @@ int rsd_stop(rsound_t *rd)
size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)
{
size_t max_write, written = 0;
retro_assert(rsound != NULL);
assert(rsound != NULL);
if ( !rsound->ready_for_data )
return 0;
@@ -1340,11 +1339,11 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size)
int rsd_start(rsound_t *rsound)
{
retro_assert(rsound != NULL);
retro_assert(rsound->rate > 0);
retro_assert(rsound->channels > 0);
retro_assert(rsound->host != NULL);
retro_assert(rsound->port != NULL);
assert(rsound != NULL);
assert(rsound->rate > 0);
assert(rsound->channels > 0);
assert(rsound->host != NULL);
assert(rsound->port != NULL);
if ( rsnd_create_connection(rsound) < 0 )
return -1;
@@ -1354,7 +1353,7 @@ int rsd_start(rsound_t *rsound)
int rsd_exec(rsound_t *rsound)
{
retro_assert(rsound != NULL);
assert(rsound != NULL);
RSD_DEBUG("[RSound] rsd_exec().\n");
// Makes sure we have a working connection
@@ -1407,8 +1406,8 @@ int rsd_exec(rsound_t *rsound)
/* ioctl()-ish param setting :D */
int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param)
{
retro_assert(rd != NULL);
retro_assert(param != NULL);
assert(rd != NULL);
assert(param != NULL);
int retval = 0;
switch(option)
@@ -1506,7 +1505,7 @@ void rsd_delay_wait(rsound_t *rd)
size_t rsd_pointer(rsound_t *rsound)
{
retro_assert(rsound != NULL);
assert(rsound != NULL);
int ptr;
ptr = rsnd_get_ptr(rsound);
@@ -1516,7 +1515,7 @@ size_t rsd_pointer(rsound_t *rsound)
size_t rsd_get_avail(rsound_t *rd)
{
retro_assert(rd != NULL);
assert(rd != NULL);
int ptr;
ptr = rsnd_get_ptr(rd);
return rd->buffer_size - ptr;
@@ -1524,7 +1523,7 @@ size_t rsd_get_avail(rsound_t *rd)
size_t rsd_delay(rsound_t *rd)
{
retro_assert(rd != NULL);
assert(rd != NULL);
int ptr = rsnd_get_delay(rd);
if ( ptr < 0 )
ptr = 0;
@@ -1534,29 +1533,28 @@ size_t rsd_delay(rsound_t *rd)
size_t rsd_delay_ms(rsound_t* rd)
{
retro_assert(rd);
retro_assert(rd->rate > 0 && rd->channels > 0);
assert(rd);
assert(rd->rate > 0 && rd->channels > 0);
return (rsd_delay(rd) * 1000) / ( rd->rate * rd->channels * rd->samplesize );
}
int rsd_pause(rsound_t* rsound, int enable)
{
retro_assert(rsound != NULL);
assert(rsound != NULL);
if ( enable )
return rsd_stop(rsound);
return rsd_start(rsound);
else
return rsd_start(rsound);
}
int rsd_init(rsound_t** rsound)
{
assert(rsound != NULL);
*rsound = calloc(1, sizeof(rsound_t));
if ( *rsound == NULL )
return -1;
retro_assert(rsound != NULL);
(*rsound)->conn.socket = -1;
(*rsound)->conn.ctl_socket = -1;
@@ -1618,7 +1616,7 @@ int rsd_simple_start(rsound_t** rsound, const char* host, const char* port, cons
void rsd_set_callback(rsound_t *rsound, rsd_audio_callback_t audio_cb, rsd_error_callback_t err_cb, size_t max_size, void *userdata)
{
retro_assert(rsound != NULL);
assert(rsound != NULL);
rsound->audio_callback = audio_cb;
rsound->error_callback = err_cb;
@@ -1626,9 +1624,7 @@ void rsd_set_callback(rsound_t *rsound, rsd_audio_callback_t audio_cb, rsd_error
rsound->cb_data = userdata;
if (rsound->audio_callback)
{
retro_assert(rsound->error_callback);
}
assert(rsound->error_callback);
}
void rsd_callback_lock(rsound_t *rsound)
@@ -1643,7 +1639,7 @@ void rsd_callback_unlock(rsound_t *rsound)
int rsd_free(rsound_t *rsound)
{
retro_assert(rsound != NULL);
assert(rsound != NULL);
if (rsound->fifo_buffer)
fifo_free(rsound->fifo_buffer);
if (rsound->host)
+111
View File
@@ -0,0 +1,111 @@
TESTS := test-sinc-lowest \
test-snr-sinc-lowest \
test-sinc-lower \
test-snr-sinc-lower \
test-sinc \
test-snr-sinc \
test-sinc-higher \
test-snr-sinc-higher \
test-sinc-highest \
test-snr-sinc-highest \
test-cc \
test-snr-cc
LIBRETRO_COMM_DIR = ../../libretro-common
CFLAGS += -O3 -ffast-math -g -Wall -pedantic -march=native -std=gnu99
CFLAGS += -DRESAMPLER_TEST -DRARCH_DUMMY_LOG -DRARCH_INTERNAL
CFLAGS += -I$(LIBRETRO_COMM_DIR)/include -I../../
LDFLAGS += -lm
SHAREDOBJ += $(LIBRETRO_COMM_DIR)/memmap/memalign.o \
$(LIBRETRO_COMM_DIR)/string/string_list.o \
$(LIBRETRO_COMM_DIR)/file/config_file_userdata.o \
$(LIBRETRO_COMM_DIR)/file/config_file.o \
$(LIBRETRO_COMM_DIR)/file/retro_file.o \
$(LIBRETRO_COMM_DIR)/file/file_path.o \
$(LIBRETRO_COMM_DIR)/compat/compat.o \
$(LIBRETRO_COMM_DIR)/hash/rhash.o \
all: $(TESTS)
resampler-sinc.o: ../audio_resampler_driver.c $(SHAREDOBJ)
$(CC) -c -o $@ $< $(CFLAGS)
resampler-cc.o: ../audio_resampler_driver.c $(SHAREDOBJ)
$(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"'
main-cc.o: main.c
$(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"'
snr-cc.o: snr.c
$(CC) -c -o $@ $< $(CFLAGS) -DRESAMPLER_IDENT='"CC"'
cc-resampler.o: ../drivers_resampler/cc_resampler.c
$(CC) -c -o $@ $< $(CFLAGS)
sinc-lowest.o: ../drivers_resampler/sinc.c
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWEST_QUALITY
sinc-lower.o: ../drivers_resampler/sinc.c
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_LOWER_QUALITY
sinc.o: ../drivers_resampler/sinc.c
$(CC) -c -o $@ $< $(CFLAGS)
nearest.o: ../drivers_resampler/nearest.c
$(CC) -c -o $@ $< $(CFLAGS)
sinc-higher.o: ../drivers_resampler/sinc.c
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHER_QUALITY
sinc-highest.o: ../drivers_resampler/sinc.c
$(CC) -c -o $@ $< $(CFLAGS) -DSINC_HIGHEST_QUALITY
test-sinc-lowest: sinc-lowest.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-sinc-lowest: sinc-lowest.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-sinc-lower: sinc-lower.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-sinc-lower: sinc-lower.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-sinc: sinc.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-sinc: sinc.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-sinc-higher: sinc-higher.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-sinc-higher: sinc-higher.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-sinc-highest: sinc-highest.o ../audio_utils.o main.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-sinc-highest: sinc-highest.o ../audio_utils.o snr.o resampler-sinc.o resampler-cc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-cc: cc-resampler.o ../audio_utils.o main-cc.o resampler-cc.o resampler-cc.o sinc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
test-snr-cc: cc-resampler.o ../audio_utils.o snr-cc.o resampler-cc.o sinc.o nearest.o $(SHAREDOBJ)
$(CC) -o $@ $^ $(LDFLAGS)
%.o: %.c
$(CC) -c -o $@ $< $(CFLAGS)
clean:
rm -f $(TESTS)
rm -f *.o
rm -f ../*.o
.PHONY: clean
+6
View File
@@ -0,0 +1,6 @@
function win = kaiser_window(N, beta)
% Create an N-point kaiser window with given beta.
indices = 2 * (0 : N - 1) / (N - 1) - 1;
mod = modified_bessel(beta);
win = modified_bessel(beta * sqrt(1 - indices.^2)) / mod;
Loaded 100 of 3199 files, more files were not shown because too many files have changed in this diff. Show more