Files
libretroadmin f62d495d2d CHD: decode ahead per stream, so CD audio and data do not collide
A CHD was read through one decoded hunk and a thread that decoded one
hunk ahead. A game that plays CD audio while it streams data reads the
two from different places a sector at a time, so each threw out the
other's hunk and aimed the thread away from it, and the hunks were
decoded on the emulation thread: a stutter a GDI never shows.

Each stream (data tracks, audio tracks) now reads through its own
libretro-common vfs_prefetch, whose thread decodes the hunks ahead on an
image handle of its own, one window per hunk; sectors are lent from the
windows in place, and a read command's Prefetch() sets the data
stream's thread going before the first sector is asked for. The core
defines HAVE_THREADS where it builds threads, so the prefetcher is not
compiled to stubs. tools/chd/chd_streams_test, run from tools/chd/run.sh
and now in CI, reads audio and data at once and fails when the reading
thread does the decoding.
2026-10-26 14:49:16 +01:00

124 lines
3.0 KiB
Makefile

LOCAL_PATH := $(call my-dir)
platform := android
CORE_DIR := $(LOCAL_PATH)/..
ROOT_DIR := $(LOCAL_PATH)/..
LIBRETRO_DIR := $(ROOT_DIR)/libretro
SOURCES_C :=
SOURCES_CXX :=
SOURCES_ASM :=
INCFLAGS :=
CFLAGS :=
CXXFLAGS :=
DYNAFLAGS :=
NO_THREADS := 0
HAVE_NEON := 0
WITH_DYNAREC :=
NO_REC := 0
HAVE_CHD := 1
HAVE_GL := 1
HAVE_OPENGL := 1
HAVE_VULKAN := 1
GLES := 1
ENABLE_MODEM := 1
HOST_CPU_X86=0x20000001
HOST_CPU_ARM=0x20000002
HOST_CPU_MIPS=0x20000003
HOST_CPU_X64=0x20000004
HOST_CPU_GENERIC=0x20000005
HOST_CPU_ARM64=0x20000006
ifeq ($(TARGET_ARCH_ABI),arm64-v8a)
WITH_DYNAREC := arm64
else ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
WITH_DYNAREC := arm
HAVE_NEON := 1
else ifeq ($(TARGET_ARCH_ABI),x86)
# (the recompiler writes all its own code at run time: the library has
# no text relocations, which Android 6 on refuses)
WITH_DYNAREC := x86
else ifeq ($(TARGET_ARCH_ABI),x86_64)
WITH_DYNAREC := x86_64
endif
CORE_DEFINES :=
include $(ROOT_DIR)/Makefile.common
# (no fast-math, and no fused multiply-adds the code does not ask for: the
# SH4's floating point has to come out the same on every host, see Makefile)
COREFLAGS := -ffp-contract=off -D__LIBRETRO__ -DHAVE_GLSYM_PRIVATE -DINLINE="inline" -DANDROID -D_ANDROID -DHAVE_OPENGLES -DHAVE_OPENGLES2 $(GLFLAGS) $(INCFLAGS) $(DYNAFLAGS) $(CORE_DEFINES)
COREFLAGS += -DNDEBUG -DNO_VERIFY
ifeq ($(NO_THREADS),1)
COREFLAGS += -DTARGET_NO_THREADS
else
COREFLAGS += -DHAVE_THREADS
endif
ifeq ($(HAVE_GENERIC_JIT),1)
COREFLAGS += -DTARGET_NO_JIT -DFEAT_SHREC=0x40000003
endif
ifeq ($(NO_REC),1)
COREFLAGS += -DTARGET_NO_REC
endif
ifeq ($(TARGET_ARCH_ABI),x86_64)
COREFLAGS += -fno-operator-names
COREFLAGS += -DHOST_CPU=$(HOST_CPU_X64)
endif
ifeq ($(TARGET_ARCH_ABI), x86)
COREFLAGS += -fno-operator-names
COREFLAGS += -DHOST_CPU=$(HOST_CPU_X86)
endif
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
COREFLAGS += -DHOST_CPU=$(HOST_CPU_ARM)
endif
ifeq ($(TARGET_ARCH_ABI), arm64-v8a)
COREFLAGS += -DHOST_CPU=$(HOST_CPU_ARM64)
endif
ifeq ($(TARGET_ARCH_ABI), mips)
COREFLAGS += -DHOST_CPU=$(HOST_CPU_MIPS)
endif
GIT_VERSION := " $(shell git rev-parse --short HEAD || echo unknown)"
ifneq ($(GIT_VERSION)," unknown")
COREFLAGS += -DGIT_VERSION=\"$(GIT_VERSION)\"
endif
COREFLAGS += -DHAVE_MMAP
ifeq ($(HAVE_CHD),1)
COREFLAGS += -DHAVE_CHD -DHAVE_RCHD -DHAVE_RCHD_DEFLATE -DHAVE_RCHD_LZMA -DHAVE_RCHD_FLAC -DHAVE_RCHD_ZSTD -DHAVE_RFLAC -DHAVE_RZSTD
endif
ifeq ($(HAVE_VULKAN),1)
COREFLAGS += -DHAVE_VULKAN
endif
include $(CLEAR_VARS)
LOCAL_MODULE := retro
LOCAL_SRC_FILES := $(SOURCES_CXX) $(SOURCES_C) $(SOURCES_ASM)
LOCAL_CFLAGS := $(COREFLAGS) $(CFLAGS)
LOCAL_CXXFLAGS := -std=c++11 $(COREFLAGS) $(CXXFLAGS)
LOCAL_LDFLAGS := -Wl,-version-script=$(CORE_DIR)/link.T
LOCAL_LDLIBS := -lGLESv2 -llog $(CORELDLIBS)
LOCAL_CPP_FEATURES := exceptions
LOCAL_ARM_NEON := true
LOCAL_ARM_MODE := arm
ifeq ($(NO_THREADS),1)
else
#LOCAL_LDLIBS += -lpthread
endif
include $(BUILD_SHARED_LIBRARY)