Răsfoiți Sursa

Android native sound fix and update openal-soft to 1.21.1 (#1475)

* Update GLImageFormats.java

* Modified JmeBatchRenderBackend to clear the inner buffer of the image in the atlases instead of setting a predefined byte buffer
on disposal that made all atlases in the backend use the same buffer and generated rendering issues.

* First impl of testcasefor multiple atlases issue. Still missing to add more images to the screens so it really uses more atlases

* Manual merge pending stuff from jme3 base

* Manual merge

* Added -O0 and -O1 to fix some bad behaviour in newer NDKs making ogg loading fail and no sound on android
Fixed bad path check in openalsoft.gradle
Updated openal-soft to 1.17.2 and added related required defines in config.h

* Updated openal-soft to 1.19.1
Included new required header files
Updated target platform to android-19 (previous just don't link)

* Updated to latest openal-soft 1.21.1 (kcat repo)

* Removed bsinc_inc.h (not used in 1.21.1)

* Changed android build docker image to jme3

Co-authored-by: joliver82 <[email protected]>
Co-authored-by: Jesus Oliver <[email protected]>
joliver82 4 ani în urmă
părinte
comite
8c4d52360c

+ 1 - 1
.github/workflows/main.yml

@@ -69,7 +69,7 @@ jobs:
     name: Build natives for android
     runs-on: ubuntu-18.04
     container:
-      image: riccardoblb/buildenv-jme3:android
+      image: jmonkeyengine/buildenv-jme3:android
   
     steps:
       - name: Clone the repo

+ 5 - 4
jme3-android-native/openalsoft.gradle

@@ -1,11 +1,12 @@
-// OpenAL Soft r1.16
-String openALSoftUrl = 'https://github.com/jMonkeyEngine/openal-soft/archive/e5016f814a265ed592a88acea95cf912c4bfdf12.zip'
+// OpenAL Soft r1.21.1
+// TODO: update URL to jMonkeyEngine fork once it's updated with latest kcat's changes
+String openALSoftUrl = 'https://github.com/kcat/openal-soft/archive/1.21.1.zip'
 String openALSoftZipFile = 'OpenALSoft.zip'
 
 // OpenAL Soft directory the download is extracted into
 // Typically, the downloaded OpenAL Soft zip file will extract to a directory
 // called "openal-soft"
-String openALSoftFolder = 'openal-soft-e5016f814a265ed592a88acea95cf912c4bfdf12'
+String openALSoftFolder = 'openal-soft-1.21.1'
 
 //Working directories for the ndk build.
 String openalsoftBuildDir = "${buildDir}" + File.separator + 'openalsoft'
@@ -56,7 +57,7 @@ task copyOpenALSoft(type: Copy) {
     into outputDir
 }
 copyOpenALSoft.dependsOn {
-    def openALSoftUnzipDir = new File(project.projectDir.absolutePath + File.separator + openALSoftFolder)
+    def openALSoftUnzipDir = new File(openalsoftBuildDir + File.separator + openALSoftFolder)
 //    println "openALSoftUnzipDir path: " + openALSoftUnzipDir.absolutePath
 //    println "openALSoftUnzipDir exists: " + openALSoftUnzipDir.isDirectory()
     if (!openALSoftUnzipDir.isDirectory()) {

+ 1 - 1
jme3-android-native/src/native/jme_decode/Android.mk

@@ -10,7 +10,7 @@ LOCAL_C_INCLUDES:= \
 		$(LOCAL_PATH) \
 		$(LOCAL_PATH)/Tremor
 
-LOCAL_CFLAGS := -std=gnu99 -DLIMIT_TO_64kHz
+LOCAL_CFLAGS := -std=gnu99 -DLIMIT_TO_64kHz -O0
 LOCAL_LDLIBS := -lz -llog -Wl,-s
 	
 ifeq ($(TARGET_ARCH),arm)

+ 89 - 56
jme3-android-native/src/native/jme_openalsoft/Android.mk

@@ -1,4 +1,4 @@
-TARGET_PLATFORM := android-9
+TARGET_PLATFORM := android-19
 
 LOCAL_PATH := $(call my-dir)
 
@@ -7,64 +7,97 @@ include $(CLEAR_VARS)
 LOCAL_MODULE     := openalsoftjme
 
 LOCAL_C_INCLUDES += $(LOCAL_PATH) $(LOCAL_PATH)/include \
-		    $(LOCAL_PATH)/OpenAL32/Include $(LOCAL_PATH)/Alc
+		    $(LOCAL_PATH)/alc  $(LOCAL_PATH)/common
 
-LOCAL_CFLAGS     := -std=c99 -ffast-math -DAL_BUILD_LIBRARY -DAL_ALEXT_PROTOTYPES
+LOCAL_CPP_FEATURES += exceptions
+
+LOCAL_CFLAGS     := -ffast-math -DAL_BUILD_LIBRARY -DAL_ALEXT_PROTOTYPES -fcommon -O0 -DRESTRICT=""
 LOCAL_LDLIBS     := -lOpenSLES -llog -Wl,-s
 
-LOCAL_SRC_FILES  :=   Alc/backends/opensl.c \
-                      Alc/backends/loopback.c \
-                      Alc/backends/wave.c \
-                      Alc/backends/base.c \
-                      Alc/backends/null.c \
-                      Alc/ALc.c \
-                      Alc/helpers.c \
-                      Alc/bs2b.c \
-                      Alc/alcRing.c \
-                      Alc/effects/chorus.c \
-                      Alc/effects/flanger.c \
-                      Alc/effects/dedicated.c \
-                      Alc/effects/reverb.c \
-                      Alc/effects/distortion.c \
-                      Alc/effects/autowah.c \
-                      Alc/effects/equalizer.c \
-                      Alc/effects/modulator.c \
-                      Alc/effects/echo.c \
-                      Alc/effects/compressor.c \
-                      Alc/effects/null.c \
-                      Alc/alcConfig.c \
-                      Alc/ALu.c \
-                      Alc/mixer_c.c \
-                      Alc/panning.c \
-                      Alc/hrtf.c \
-                      Alc/mixer.c \
-                      Alc/midi/soft.c \
-                      Alc/midi/sf2load.c \
-                      Alc/midi/dummy.c \
-                      Alc/midi/fluidsynth.c \
-                      Alc/midi/base.c \
-                      common/uintmap.c \
-                      common/atomic.c \
-                      common/threads.c \
-                      common/rwlock.c \
-                      OpenAL32/alBuffer.c \
-                      OpenAL32/alPreset.c \
-                      OpenAL32/alListener.c \
-                      OpenAL32/alEffect.c \
-                      OpenAL32/alExtension.c \
-                      OpenAL32/alThunk.c \
-                      OpenAL32/alMidi.c \
-                      OpenAL32/alSoundfont.c \
-                      OpenAL32/alFontsound.c \
-                      OpenAL32/alAuxEffectSlot.c \
-                      OpenAL32/alError.c \
-                      OpenAL32/alFilter.c \
-                      OpenAL32/alSource.c \
-                      OpenAL32/alState.c \
-                      OpenAL32/sample_cvt.c \
-		      com_jme3_audio_android_AndroidAL.c \
-		      com_jme3_audio_android_AndroidALC.c \
-		      com_jme3_audio_android_AndroidEFX.c 
+LOCAL_SRC_FILES  :=   al/auxeffectslot.cpp \
+                      al/buffer.cpp \
+                      al/effect.cpp \
+                      al/effects/autowah.cpp \
+                      al/effects/chorus.cpp \
+                      al/effects/compressor.cpp \
+                      al/effects/convolution.cpp \
+                      al/effects/dedicated.cpp \
+                      al/effects/distortion.cpp \
+                      al/effects/echo.cpp \
+                      al/effects/equalizer.cpp \
+                      al/effects/fshifter.cpp \
+                      al/effects/modulator.cpp \
+                      al/effects/null.cpp \
+                      al/effects/pshifter.cpp \
+                      al/effects/reverb.cpp \
+                      al/effects/vmorpher.cpp \
+                      al/error.cpp \
+                      al/event.cpp \
+                      al/extension.cpp \
+                      al/filter.cpp \
+                      al/listener.cpp \
+                      al/source.cpp \
+                      al/state.cpp \
+                      alc/alc.cpp \
+                      alc/alconfig.cpp \
+                      alc/alu.cpp \
+                      alc/backends/base.cpp \
+                      alc/backends/loopback.cpp \
+                      alc/backends/null.cpp \
+                      alc/backends/opensl.cpp \
+                      alc/backends/wave.cpp \
+                      alc/bformatdec.cpp \
+                      alc/buffer_storage.cpp \
+                      alc/converter.cpp \
+                      alc/effects/autowah.cpp \
+                      alc/effects/chorus.cpp \
+                      alc/effects/compressor.cpp \
+                      alc/effects/convolution.cpp \
+                      alc/effects/dedicated.cpp \
+                      alc/effects/distortion.cpp \
+                      alc/effects/echo.cpp \
+                      alc/effects/equalizer.cpp \
+                      alc/effects/fshifter.cpp \
+                      alc/effects/modulator.cpp \
+                      alc/effects/null.cpp \
+                      alc/effects/pshifter.cpp \
+                      alc/effects/reverb.cpp \
+                      alc/effects/vmorpher.cpp \
+                      alc/effectslot.cpp \
+                      alc/helpers.cpp \
+                      alc/hrtf.cpp \
+                      alc/panning.cpp \
+                      alc/uiddefs.cpp \
+                      alc/voice.cpp \
+                      common/alcomplex.cpp \
+                      common/alfstream.cpp \
+                      common/almalloc.cpp \
+                      common/alstring.cpp \
+                      common/dynload.cpp \
+                      common/polyphase_resampler.cpp \
+                      common/ringbuffer.cpp \
+                      common/strutils.cpp \
+                      common/threads.cpp \
+                      core/ambdec.cpp \
+                      core/bs2b.cpp \
+                      core/bsinc_tables.cpp \
+                      core/cpu_caps.cpp \
+                      core/devformat.cpp \
+                      core/except.cpp \
+                      core/filters/biquad.cpp \
+                      core/filters/nfc.cpp \
+                      core/filters/splitter.cpp \
+                      core/fmt_traits.cpp \
+                      core/fpu_ctrl.cpp \
+                      core/logging.cpp \
+                      core/mastering.cpp \
+                      core/mixer/mixer_c.cpp \
+                      core/uhjfilter.cpp \
+                      com_jme3_audio_android_AndroidAL.c \
+                      com_jme3_audio_android_AndroidALC.c \
+                      com_jme3_audio_android_AndroidEFX.c
 
 include $(BUILD_SHARED_LIBRARY)
 
+#                      Alc/mixer/hrtf_inc.c \
+

+ 4 - 2
jme3-android-native/src/native/jme_openalsoft/Application.mk

@@ -1,3 +1,5 @@
-APP_PLATFORM := android-9
+APP_PLATFORM := android-19
 APP_OPTIM := release
-APP_ABI := all
+APP_ABI := all
+APP_STL := c++_static
+

+ 57 - 35
jme3-android-native/src/native/jme_openalsoft/config.h

@@ -2,18 +2,18 @@
 #define AL_API  __attribute__((visibility("protected")))
 #define ALC_API __attribute__((visibility("protected")))
 
-/* Define to the library version */
-#define ALSOFT_VERSION "1.16.0"
-
-#ifdef IN_IDE_PARSER
-/* KDevelop's parser doesn't recognize the C99-standard restrict keyword, but
- * recent versions (at least 4.5.1) do recognize GCC's __restrict. */
-#define restrict __restrict
-#endif 
-
 /* Define any available alignment declaration */
 #define ALIGN(x) __attribute__((aligned(x)))
 
+/* Define a built-in call indicating an aligned data pointer */
+#define ASSUME_ALIGNED(x, y) __builtin_assume_aligned(x, y)
+
+/* Define if HRTF data is embedded in the library */
+/* #undef ALSOFT_EMBED_HRTF_DATA */ 
+
+/* Define if we have the sysconf function */
+#define HAVE_SYSCONF
+
 /* Define if we have the C11 aligned_alloc function */
 /* #undef HAVE_ALIGNED_ALLOC */
 
@@ -23,17 +23,21 @@
 /* Define if we have the _aligned_malloc function */
 /* #undef HAVE__ALIGNED_MALLOC */
 
+/* Define if we have the proc_pidpath function */
+/* #undef HAVE_PROC_PIDPATH */
+
+/* Define if we have the getopt function */
+#define HAVE_GETOPT
+
 /* Define if we have SSE CPU extensions */
 /* #undef HAVE_SSE */
 /* #undef HAVE_SSE2 */
+/* #undef HAVE_SSE3 */
 /* #undef HAVE_SSE4_1 */
 
 /* Define if we have ARM Neon CPU extensions */
 /* #undef HAVE_NEON */
 
-/* Define if we have FluidSynth support */
-/* #undef HAVE_FLUIDSYNTH */
-
 /* Define if we have the ALSA backend */
 /* #undef HAVE_ALSA */
 
@@ -49,8 +53,8 @@
 /* Define if we have the QSA backend */
 /* #undef HAVE_QSA */
 
-/* Define if we have the MMDevApi backend */
-/* #undef HAVE_MMDEVAPI */
+/* Define if we have the WASAPI backend */
+/* #undef HAVE_WASAPI */
 
 /* Define if we have the DSound backend */
 /* #undef HAVE_DSOUND */
@@ -64,6 +68,9 @@
 /* Define if we have the PulseAudio backend */
 /* #undef HAVE_PULSEAUDIO */
 
+/* Define if we have the JACK backend */
+/* #undef HAVE_JACK */
+
 /* Define if we have the CoreAudio backend */
 /* #undef HAVE_COREAUDIO */
 
@@ -73,15 +80,33 @@
 /* Define if we have the Wave Writer backend */
 #define HAVE_WAVE
 
+/* Define if we have the SDL2 backend */
+/* #undef HAVE_SDL2 */
+
 /* Define if we have the stat function */
 #define HAVE_STAT
 
 /* Define if we have the lrintf function */
 #define HAVE_LRINTF
 
+/* Define if we have the modff function */
+#define HAVE_MODFF
+
+/* Define if we have the log2f function */
+#define HAVE_LOG2F 
+
+/* Define if we have the cbrtf function */
+#define HAVE_CBRTF
+
+/* Define if we have the copysignf function */
+#define HAVE_COPYSIGNF
+
 /* Define if we have the strtof function */
 /* #undef HAVE_STRTOF */
 
+/* Define if we have the strnlen function */
+#define HAVE_STRNLEN
+
 /* Define if we have the __int64 type */
 /* #undef HAVE___INT64 */
 
@@ -91,9 +116,6 @@
 /* Define to the size of a long long int type */
 #define SIZEOF_LONG_LONG 8
 
-/* Define if we have C99 variable-length array support */
-#define HAVE_C99_VLA
-
 /* Define if we have C99 _Bool support */
 #define HAVE_C99_BOOL
 
@@ -101,10 +123,10 @@
 #define HAVE_C11_STATIC_ASSERT
 
 /* Define if we have C11 _Alignas support */
-/* #undef HAVE_C11_ALIGNAS */
+#define HAVE_C11_ALIGNAS
 
 /* Define if we have C11 _Atomic support */
-/* #undef HAVE_C11_ATOMIC */
+#define HAVE_C11_ATOMIC
 
 /* Define if we have GCC's destructor attribute */
 #define HAVE_GCC_DESTRUCTOR
@@ -119,7 +141,7 @@
 #define HAVE_STDBOOL_H
 
 /* Define if we have stdalign.h */
-/* #undef HAVE_STDALIGN_H */
+#define HAVE_STDALIGN_H
 
 /* Define if we have windows.h */
 /* #undef HAVE_WINDOWS_H */
@@ -130,17 +152,11 @@
 /* Define if we have pthread_np.h */
 /* #undef HAVE_PTHREAD_NP_H */
 
-/* Define if we have alloca.h */
-/* #undef HAVE_ALLOCA_H */
-
 /* Define if we have malloc.h */
 #define HAVE_MALLOC_H
 
-/* Define if we have ftw.h */
-/* #undef HAVE_FTW_H */
-
-/* Define if we have io.h */
-/* #undef HAVE_IO_H */
+/* Define if we have dirent.h */
+#define HAVE_DIRENT_H
 
 /* Define if we have strings.h */
 #define HAVE_STRINGS_H
@@ -175,24 +191,30 @@
 /* Define if we have the __cpuid() intrinsic */
 /* #undef HAVE_CPUID_INTRINSIC */
 
+/* Define if we have the _BitScanForward64() intrinsic */
+/* #undef HAVE_BITSCANFORWARD64_INTRINSIC */
+
+/* Define if we have the _BitScanForward() intrinsic */
+/* #undef HAVE_BITSCANFORWARD_INTRINSIC */
+
 /* Define if we have _controlfp() */
 /* #undef HAVE__CONTROLFP */
 
 /* Define if we have __control87_2() */
 /* #undef HAVE___CONTROL87_2 */
 
-/* Define if we have ftw() */
-/* #undef HAVE_FTW */
-
-/* Define if we have _wfindfirst() */
-/* #undef HAVE__WFINDFIRST */
-
 /* Define if we have pthread_setschedparam() */
 #define HAVE_PTHREAD_SETSCHEDPARAM
 
 /* Define if we have pthread_setname_np() */
 #define HAVE_PTHREAD_SETNAME_NP
 
+/* Define if pthread_setname_np() only accepts one parameter */
+/* #undef PTHREAD_SETNAME_NP_ONE_PARAM */
+
+/* Define if pthread_setname_np() accepts three parameters */
+/* #undef PTHREAD_SETNAME_NP_THREE_PARAMS */
+
 /* Define if we have pthread_set_name_np() */
 /* #undef HAVE_PTHREAD_SET_NAME_NP */
 
@@ -200,4 +222,4 @@
 /* #undef HAVE_PTHREAD_MUTEXATTR_SETKIND_NP */
 
 /* Define if we have pthread_mutex_timedlock() */
-/* #undef HAVE_PTHREAD_MUTEX_TIMEDLOCK */
+/* #undef HAVE_PTHREAD_MUTEX_TIMEDLOCK */

+ 10 - 0
jme3-android-native/src/native/jme_openalsoft/version.h

@@ -0,0 +1,10 @@
+/* Define to the library version */
+#define ALSOFT_VERSION "1.21.1"
+#define ALSOFT_VERSION_NUM 1,21,1,0
+
+/* Define the branch being built */
+#define ALSOFT_GIT_BRANCH "HEAD"
+
+/* Define the hash of the head commit */
+#define ALSOFT_GIT_COMMIT_HASH "ae4eacf1"
+