From fccef557fc440a9c575bce11ecee363d933bf2dd Mon Sep 17 00:00:00 2001 From: jSTE0 <98854293+jSTE0@users.noreply.github.com> Date: Sat, 2 Apr 2022 08:07:25 +0100 Subject: [PATCH] miyoo: Enable ALSA audio driver and default to it (#13814) Enable it as it does not freeze. This provides an audio backend that can report its buffer status, allowing auto frame skip to work on cores that support it. Do not build or include alsathread as it results in choppy audio. Similarly, leave tinyalsa disabled as it plays back at a higher pitch and is also choppy. Change the default sample rate to 32000Hz as the previous default of 32730Hz is derived from the 3DS. --- Makefile.common | 6 ++++-- Makefile.miyoo | 7 +++---- audio/audio_driver.c | 2 +- config.def.h | 4 ++-- configuration.c | 2 +- 5 files changed, 11 insertions(+), 10 deletions(-) diff --git a/Makefile.common b/Makefile.common index d7d3b0906d..4392060c11 100644 --- a/Makefile.common +++ b/Makefile.common @@ -878,8 +878,10 @@ ifeq ($(HAVE_ALSA), 1) endif endif - ifeq ($(HAVE_THREADS), 1) - OBJ += audio/drivers/alsathread.o + ifneq ($(MIYOO), 1) + ifeq ($(HAVE_THREADS), 1) + OBJ += audio/drivers/alsathread.o + endif endif LIBS += $(ALSA_LIBS) diff --git a/Makefile.miyoo b/Makefile.miyoo index e7925d7d09..f1f513ce82 100644 --- a/Makefile.miyoo +++ b/Makefile.miyoo @@ -45,8 +45,7 @@ HAVE_SCREENSHOTS = 0 HAVE_REWIND = 0 HAVE_7ZIP = 1 HAVE_AL = 0 -# ALSA freezes when switching back from menu -HAVE_ALSA = 0 +HAVE_ALSA = 1 HAVE_DSP_FILTER = 1 HAVE_VIDEO_FILTER = 1 HAVE_STATIC_VIDEO_FILTERS = 1 @@ -123,7 +122,7 @@ DEF_FLAGS += -ffunction-sections -fdata-sections DEF_FLAGS += -I. -Ideps -Ideps/stb -DMIYOO=1 -DDINGUX -MMD DEF_FLAGS += -Wall -Wno-unused-variable -flto DEF_FLAGS += -std=gnu99 -D_GNU_SOURCE -LIBS := -ldl -lz -lrt -pthread +LIBS := -ldl -lz -lrt -pthread -lasound CFLAGS := CXXFLAGS := -fno-exceptions -fno-rtti -std=c++11 -D__STDC_CONSTANT_MACROS ASFLAGS := @@ -133,7 +132,7 @@ LIBRARY_DIRS = -L$(GCW0_LIB_DIR) DEFINES := -DRARCH_INTERNAL -D_FILE_OFFSET_BITS=64 -UHAVE_STATIC_DUMMY DEFINES += -DHAVE_C99=1 -DHAVE_CXX=1 DEFINES += -DHAVE_GETOPT_LONG=1 -DHAVE_STRCASESTR=1 -DHAVE_DYNAMIC=1 -DEFINES += -DHAVE_FILTERS_BUILTIN +DEFINES += -DHAVE_FILTERS_BUILTIN -DHAVE_ALSA SDL_DINGUX_CFLAGS := $(shell $(GCW0_SDL_CONFIG) --cflags) SDL_DINGUX_LIBS := $(shell $(GCW0_SDL_CONFIG) --libs) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 0e0c77cb3d..2f0fa691de 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -83,7 +83,7 @@ audio_driver_t audio_null = { audio_driver_t *audio_drivers[] = { #ifdef HAVE_ALSA &audio_alsa, -#if !defined(__QNX__) && defined(HAVE_THREADS) +#if !defined(__QNX__) && !defined(MIYOO) && defined(HAVE_THREADS) &audio_alsathread, #endif #endif diff --git a/config.def.h b/config.def.h index 159082a54e..1ac8ccb235 100644 --- a/config.def.h +++ b/config.def.h @@ -1051,9 +1051,9 @@ static const bool audio_enable_menu_bgm = false; #endif /* Output samplerate. */ -#ifdef GEKKO +#if defined(GEKKO) || defined(MIYOO) #define DEFAULT_OUTPUT_RATE 32000 -#elif defined(_3DS) || defined(RETROFW) || defined(MIYOO) +#elif defined(_3DS) || defined(RETROFW) #define DEFAULT_OUTPUT_RATE 32730 #else #define DEFAULT_OUTPUT_RATE 48000 diff --git a/configuration.c b/configuration.c index e807e27b72..50acf1be27 100644 --- a/configuration.c +++ b/configuration.c @@ -453,7 +453,7 @@ static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_PS3; static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_CTR; #elif defined(SWITCH) static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_SWITCH; -#elif defined(DINGUX_BETA) && defined(HAVE_ALSA) +#elif (defined(DINGUX_BETA) || defined(MIYOO)) && defined(HAVE_ALSA) static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_ALSA; #elif defined(DINGUX) && defined(HAVE_AL) static const enum audio_driver_enum AUDIO_DEFAULT_DRIVER = AUDIO_AL;