Make openal default audio driver

This commit is contained in:
Ethan O'Brien 2023-07-14 08:59:45 -05:00 committed by LibretroAdmin
parent 20f151d42e
commit e5c0ab17e4
5 changed files with 34 additions and 6 deletions

View File

@ -758,8 +758,10 @@ ifeq ($(HAVE_EMSCRIPTEN), 1)
OBJ += frontend/drivers/platform_emscripten.o \ OBJ += frontend/drivers/platform_emscripten.o \
input/drivers/rwebinput_input.o \ input/drivers/rwebinput_input.o \
input/drivers_joypad/rwebpad_joypad.o \ input/drivers_joypad/rwebpad_joypad.o \
audio/drivers/rwebaudio.o \
camera/drivers/rwebcam.o camera/drivers/rwebcam.o
ifeq ($(HAVE_RWEBAUDIO), 1)
OBJ += audio/drivers/rwebaudio.o
endif
endif endif
ifeq ($(HAVE_BLUETOOTH), 1) ifeq ($(HAVE_BLUETOOTH), 1)

View File

@ -46,6 +46,16 @@ HAVE_IBXM = 1
HAVE_CORE_INFO_CACHE = 1 HAVE_CORE_INFO_CACHE = 1
HAVE_7ZIP = 1 HAVE_7ZIP = 1
HAVE_BSV_MOVIE = 1 HAVE_BSV_MOVIE = 1
HAVE_AL = 1
# WARNING -- READ BEFORE ENABLING
# The rwebaudio driver is known to have several audio bugs, such as
# minor crackling, or the entire page freezing/crashing.
# It works perfectly on chrome, but even firefox has really bad audio quality.
# I should also note, the driver on iOS is completely broken (crashes the page).
# You have been warned.
HAVE_RWEBAUDIO = 0
ASYNC ?= 0 ASYNC ?= 0
ifeq ($(LIBRETRO), mupen64plus) ifeq ($(LIBRETRO), mupen64plus)
@ -70,9 +80,17 @@ OBJDIR := obj-emscripten
LIBS := -s USE_ZLIB=1 LIBS := -s USE_ZLIB=1
LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \ LDFLAGS := -L. --no-heap-copy -s $(LIBS) -s TOTAL_MEMORY=$(MEMORY) -s NO_EXIT_RUNTIME=0 -s FULL_ES2=1 -s "EXTRA_EXPORTED_RUNTIME_METHODS=['callMain']" \
-s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \ -s ALLOW_MEMORY_GROWTH=1 -s EXPORTED_FUNCTIONS="['_main', '_malloc', '_cmd_savefiles', '_cmd_save_state', '_cmd_load_state', '_cmd_take_screenshot']" \
--js-library emscripten/library_rwebaudio.js \ --js-library emscripten/library_errno_codes.js \
--js-library emscripten/library_rwebcam.js \ --js-library emscripten/library_rwebcam.js
--js-library emscripten/library_errno_codes.js
ifeq ($(HAVE_RWEBAUDIO), 1)
LDFLAGS += --js-library emscripten/library_rwebaudio.js
DEFINES += -DHAVE_RWEBAUDIO
endif
ifeq ($(HAVE_AL), 1)
LDFLAGS += -lopenal
DEFINES += -DHAVE_AL
endif
ifneq ($(PTHREAD), 0) ifneq ($(PTHREAD), 0)
LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD) LDFLAGS += -s WASM_MEM_MAX=1073741824 -pthread -s PTHREAD_POOL_SIZE=$(PTHREAD)

View File

@ -143,7 +143,7 @@ audio_driver_t *audio_drivers[] = {
#ifdef WIIU #ifdef WIIU
&audio_ax, &audio_ax,
#endif #endif
#ifdef EMSCRIPTEN #if defined(EMSCRIPTEN) && defined(HAVE_RWEBAUDIO)
&audio_rwebaudio, &audio_rwebaudio,
#endif #endif
#if defined(PSP) || defined(VITA) || defined(ORBIS) #if defined(PSP) || defined(VITA) || defined(ORBIS)

View File

@ -237,7 +237,11 @@ static bool al_start(void *data, bool is_shutdown)
{ {
al_t *al = (al_t*)data; al_t *al = (al_t*)data;
if (al) if (al)
al->is_paused = false; #ifdef EMSCRIPTEN //NEVER EVER BLOCK THE MAIN THREAD!! Emscripten will handle this for us :)
al->nonblock = true;
#else
al->nonblock = state;
#endif
return true; return true;
} }

View File

@ -4930,7 +4930,9 @@ int rarch_main(int argc, char *argv[], void *data)
#if defined(EMSCRIPTEN) #if defined(EMSCRIPTEN)
#include "gfx/common/gl_common.h" #include "gfx/common/gl_common.h"
#ifdef HAVE_RWEBAUDIO
void RWebAudioRecalibrateTime(void); void RWebAudioRecalibrateTime(void);
#endif
void emscripten_mainloop(void) void emscripten_mainloop(void)
{ {
@ -4946,7 +4948,9 @@ void emscripten_mainloop(void)
bool runloop_is_slowmotion = runloop_flags & RUNLOOP_FLAG_SLOWMOTION; bool runloop_is_slowmotion = runloop_flags & RUNLOOP_FLAG_SLOWMOTION;
bool runloop_is_paused = runloop_flags & RUNLOOP_FLAG_PAUSED; bool runloop_is_paused = runloop_flags & RUNLOOP_FLAG_PAUSED;
#ifdef HAVE_RWEBAUDIO
RWebAudioRecalibrateTime(); RWebAudioRecalibrateTime();
#endif
emscripten_frame_count++; emscripten_frame_count++;