GithubHelp home page GithubHelp logo

barsoosayque / libgdx-oboe Goto Github PK

View Code? Open in Web Editor NEW
54.0 7.0 10.0 46.4 MB

🎶 libGDX audio replacement for Android (API 16+) built on top of Oboe.

License: MIT License

CMake 2.32% C++ 78.56% Kotlin 8.97% Shell 7.62% Nix 2.52%

libgdx-oboe's Introduction

Icon

libGDX Oboe

libGDX oboe

Reimplementation of the Audio interface for libGDX framework using Oboe and FFmpeg, which allows music to flow without any delay or another unpleasant distortion.

And if you ever asked yourself "Why is my libGDX app music is so broken ?", then you've come to the right place.

🔰 How to Use🎺 Explore Examples🚜 How to Build

Content of docs directory.

Quick, show me some code !

Here is how do one essentially "use" this library (code in Kotlin):

class AndroidLauncher : AndroidApplication() {
    // Magic happens here:
    override fun createAudio(context: Context, config: AndroidApplicationConfiguration): AndroidAudio =
            OboeAudio(context.assets)

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // Create an app like always
        val config = AndroidApplicationConfiguration()
        initialize(SomeApp(), config)
    }
}

How does this works ?

Using Oboe library from Google, you can create high-performance audio streams which may plug in and tweak some features in runtime to boost speed even further. This streams are native, so there is no GC that will slow things down. For audio decoding, this library also provide native tools: libavformat and friends (FFmpeg) with MP3, OGG and WAV support only. Such audio decoder is blazing fast, so combining that with oboe streams, we get ourselves responsive and fast Audio implementation.

State of features

Here is a table of known goodies and problems for certain features per file format (decoder):

Feature State Description
Sounds Per-sound soundpools. All features should be working. Although max sounds isn't read from android config, the number is infinite at the moment.
Music playing Precise position, starts and pauses exactly when requested.
Music Seek 👌 WAV is precise, no content lost. OGG and MP3 is different: bad initial seek, but dropping frames until PTS is equal to desired seek TS. May lose some content if PTS isn't precise enough.
Audio Device 👌 Repetitive writes to audio device might produce audio artifacts (cracks).
Audio Recorder 👌 Repetitive reads bleed a little bit of cache from the last read to the buffer. Omit a few first frames when using recorded PCM.

libgdx-oboe's People

Contributors

alex-dorokhov avatar barsoosayque avatar dasisdormax avatar kurante2801 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

libgdx-oboe's Issues

OboeAudio doesn't play music/sounds during entire first foreground session.

I'm using libgdx's AndroidFragmentApplication and my game needs to play a looped background music piece as soon as the game loads. The issue is no music or sounds get played for the entire time the app is in foreground until you put app in background, and then back into foreground. Once it's in foreground for the second time, then music and sounds start playing without me having to invoke play() on any of them. I'm using the latest libgdxoboe 0.2.4.

Not sure if this is an issue related to using AndroidFragmentApplication instead of your README's AndroidApplication but the fix is to invoke resume() after creating the OboeAudio instance. I'm assuming the issue resolves itself when you bring app back into foreground a second time because resume gets invoked automatically. Just not that first time.

Note this wasn't something I had to do with Libgdx's default AndroidAudio.

  override fun createAudio(context: Context, config: AndroidApplicationConfiguration): AndroidAudio {
        return OboeAudio(context.assets).also {
            it.resume()
        }
    }

Crashes on Google pre-paunch report

First of all i would like to thank you for this repo & implementation!
I hope to be able to avoid any glitches i have in our currently developing audio app, which only occur on android devices.
So i did include libgdx-oboe im my libGDX project, everything run perfectly with the debug aar.
After trying releasing it i had to add some dependancies ( do not use kotlin, just pure Java, in my case org.jetbrains.kotlin:kotlin-stdlib-jdk7 was missing, this may be something you could add in the docs)

Anyway, i was actually able to deploy the release version on my devices, test it successfully and decided to upload on google store. Google runs after the upload some tests on the application and in my case there were for 2 test devices the following issue:

Exception java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "iconv_open" referenced by "/data/app/com.xxxx.yyyy-PpC-eyYveCd_4D3q4iVarg==/split_config.arm64_v8a.apk!/lib/arm64-v8a/libavcodec.so"... at java.lang.Runtime.loadLibrary0 (Runtime.java:1016) at java.lang.System.loadLibrary (System.java:1657) at barsoosayque.libgdxoboe.OboeAudio.<init> (OboeAudio.java) at com.immons.trace.AndroidLauncher.createAudio (AndroidLauncher.java) at com.badlogic.gdx.backends.android.AndroidApplication.init (AndroidApplication.java) at com.badlogic.gdx.backends.android.AndroidApplication.initialize (AndroidApplication.java) at com.immons.trace.AndroidLauncher.onCreate (AndroidLauncher.java) at android.app.Activity.performCreate (Activity.java:7174) at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1220) at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2908) at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:3030) at android.app.ActivityThread.-wrap11 (ActivityThread.java) at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1696) at android.os.Handler.dispatchMessage (Handler.java:105) at android.os.Looper.loop (Looper.java:164) at android.app.ActivityThread.main (ActivityThread.java:6938) at java.lang.reflect.Method.invoke (Method.java) at com.android.internal.os.Zygote$MethodAndArgsCaller.run (Zygote.java:327) at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1374)

The affected devices were "samsung SM-G960U1" (Android 8.0 (SDK 26) - arm64-v8a) and Nokia Nokia 1 (SDK 27 but armeabi, which we will exclude because do not support this ABI).
I would be very grateful for any suggestion and possible solution to this problem.
Regards, Yarnee

Failed to load natives on older Android versions

We're using libgdx-oboe built from the cb25562 and some of our users on older Android devices experience a fatal crash during app initialization time.

It appears that the libavformat.so native lib is failed to load. And the exception is:

java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH in "libavformat.so" (built with --hash-style=gnu?)

Some googling led me to this StackOverflow thread about a similar issue -
https://stackoverflow.com/questions/28638809

Sounds like building the libavformat.so (and possibly some other dependencies) with -Wl,--hash-style=both would fix the issue.

We have crash reports only from Android 5.1 devices. But one of the answers from StackOverflow says that only the devices prior Android 8 are affected.

Now, at this point, I have little experience with Android NDK and I cannot tell:

  1. If the suggested solution is correct and what are the implications of compiling with -Wl,--hash-style=both?
  2. Do we actually have an option to easily build those libraries on our side? Cuz from a quick look at the repo files, it seems like the native dependencies are linked through re-distributable dynamic libs, rather than been built from the sources.

Here's the full exception stack trace:

Fatal Exception: java.lang.UnsatisfiedLinkError: dlopen failed: empty/missing DT_HASH in "libavformat.so" (built with --hash-style=gnu?)
       at java.lang.Runtime.loadLibrary(Runtime.java:372)
       at java.lang.System.loadLibrary(System.java:988)
       at barsoosayque.libgdxoboe.OboeAudio.<init>(OboeAudio.kt:23)
       at com.crashinvaders.magnetter.android.AndroidLauncher.createAudio(AndroidLauncher.java:80)
       at com.badlogic.gdx.backends.android.AndroidApplication.init(AndroidApplication.java:120)
       at com.badlogic.gdx.backends.android.AndroidApplication.initialize(AndroidApplication.java:81)
       at com.crashinvaders.magnetter.android.AndroidLauncher.onCreate(AndroidLauncher.java:62)
       at android.app.Activity.performCreate(Activity.java:6251)
       at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1112)
       at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2622)
       at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2766)
       at android.app.ActivityThread.access$1000(ActivityThread.java:197)
       at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1611)
       at android.os.Handler.dispatchMessage(Handler.java:111)
       at android.os.Looper.loop(Looper.java:224)
       at android.app.ActivityThread.main(ActivityThread.java:5958)
       at java.lang.reflect.Method.invoke(Method.java)
       at java.lang.reflect.Method.invoke(Method.java:372)
       at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1113)
       at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:879)

Crash when starting app on some devices

Hello and first of all, Thanks for creating this library!

Using libgdx-oboe from current master, my game crashes when launching on some, but not all of my devices. The error happens on a OnePlus 6 running Android 11. This is the message:

java.lang.RuntimeException: Unable to resume activity {...}: com.badlogic.gdx.utils.GdxRuntimeException: Error starting stream: ErrorInvalidState
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4636)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4668)
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52)
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176)
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:233)
        at android.app.ActivityThread.main(ActivityThread.java:8068)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978)
     Caused by: com.badlogic.gdx.utils.GdxRuntimeException: Error starting stream: ErrorInvalidState
        at barsoosayque.libgdxoboe.OboeAudio.resume(Native Method)
        at com.badlogic.gdx.backends.android.AndroidApplication.onResume(AndroidApplication.java:265)
        at android.app.Instrumentation.callActivityOnResume(Instrumentation.java:1571)
        at android.app.Activity.performResume(Activity.java:8141)
        at android.app.ActivityThread.performResumeActivity(ActivityThread.java:4626)
        at android.app.ActivityThread.handleResumeActivity(ActivityThread.java:4668) 
        at android.app.servertransaction.ResumeActivityItem.execute(ResumeActivityItem.java:52) 
        at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:176) 
        at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:97) 
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2251) 
        at android.os.Handler.dispatchMessage(Handler.java:106) 
        at android.os.Looper.loop(Looper.java:233) 
        at android.app.ActivityThread.main(ActivityThread.java:8068) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:631) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:978) 

When rolling back to commit c09f42c, the app works normal on my devices. So this looks like an error introduced when fixing issue #12.

When researching a bit more I found out:

  • That device calls resume when launching the app while other devices don't
  • Calling audio.resume() twice crashes the app

Changing the resume function to do nothing instead of crashing when already resumed would seem like a good solution to me.

Crackling popping

First, I would like to thank you for creating this library! The setup was smooth and documentation is great.

However, I'm experiencing constant crackling popping / noise in my game after switching to oboe. This becomes very noticeable when a sound effect starts or ends with a fade in/out effect while having another sound running on a loop in the background. The issue is not very noticeable when playing one sound from absolute silence.

I'm using a mix of mp3 and wav sounds on a OnePlus 5T Android version 9.0.11

Unfortunately I can't point out the source of the issue... I'm not even sure if this is an issue related to this library or oboe. My only suggestion is to upgrade oboe to the latest version? I've seen similar issues on their repo and maybe its fixed 🤷‍♂️
google/oboe#286
google/oboe#564

Bundle natives in AAR

As it was before 0.2.2 version, it should be possible for users to define only one dependency on libgdx-oboe (without using the natives configuration). This should work out of the box, and it also worked before.

Calling dispose() on OboeMusic leads to crash

Thank you for creating this library! This library is great!

I've run into a problem with music disposal:

  • If setOnCompletionListener() is used, music.dispose() causes app to crash.
  • The same problem happens if assetManager.unload() is used instead of music.dispose().
  • If setOnCompletionListener() is not used, everything works fine.

Environment:
LibGdx Oboe 0.23, LibGdx 1.9.10

Error log:

2020-08-03 15:52:15.794 7171-7382/com.test.android A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x38 in tid 7382 (GLThread 2422), pid 7171 (lish.android)
2020-08-03 15:52:15.967 7850-7850/? A/DEBUG: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
2020-08-03 15:52:15.967 7850-7850/? A/DEBUG: Revision: '0'
2020-08-03 15:52:15.967 7850-7850/? A/DEBUG: ABI: 'arm'
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: SYSVMTYPE: Maple
    APPVMTYPE: Art
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: Timestamp: 2020-08-03 15:52:15+0800
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: pid: 7171, tid: 7382, name: GLThread 2422  >>> com.test.android <<<
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: uid: 10108
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x38
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG: Cause: null pointer dereference
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG:     r0  fffffffc  r1  ffffffff  r2  00002942  r3  00000000
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG:     r4  e9a37c4c  r5  bc678000  r6  00002942  r7  00000000
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG:     r8  bc66a408  r9  bc5eb600  r10 e9a3017c  r11 bc5eb600
2020-08-03 15:52:15.968 7850-7850/? A/DEBUG:     ip  e9a2f548  sp  b8a40f28  lr  e99c63a7  pc  e99c5f9c
2020-08-03 15:52:16.233 30595-30638/? E/BluetoothServiceJni: read_rssi_cmd_callback
2020-08-03 15:52:16.364 7850-7850/? A/DEBUG: backtrace:
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #00 pc 00040f9c  /apex/com.android.runtime/lib/bionic/libc.so (ifree+48) (BuildId: a4512dbc201a034f375ebdf7a21495c8)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #01 pc 000413a3  /apex/com.android.runtime/lib/bionic/libc.so (je_free+74) (BuildId: a4512dbc201a034f375ebdf7a21495c8)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #02 pc 000e6519  /apex/com.android.runtime/lib/libart.so (art_quick_generic_jni_trampoline+40) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #03 pc 000e1bc5  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub_internal+68) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #04 pc 0044cd4b  /apex/com.android.runtime/lib/libart.so (art_quick_invoke_stub+250) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #05 pc 000e9ff5  /apex/com.android.runtime/lib/libart.so (art::ArtMethod::Invoke(art::Thread*, unsigned int*, unsigned int, art::JValue*, char const*)+160) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #06 pc 0021b15f  /apex/com.android.runtime/lib/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread*, art::ArtMethod*, art::ShadowFrame*, unsigned short, art::JValue*)+274) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #07 pc 002172c7  /apex/com.android.runtime/lib/libart.so (bool art::interpreter::DoCall<false, false>(art::ArtMethod*, art::Thread*, art::ShadowFrame&, art::Instruction const*, unsigned short, art::JValue*)+802) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.365 7850-7850/? A/DEBUG:       #08 pc 004433b3  /apex/com.android.runtime/lib/libart.so (MterpInvokeInterface+762) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.366 7850-7850/? A/DEBUG:       #09 pc 000dca14  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_interface+20) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.366 7850-7850/? A/DEBUG:       #10 pc 002a7dc2  [anon:dalvik-classes2.dex extracted in memory from /data/app/com.test.android-Wd-HiRXhgnB7WZ8DrgtqlA==/base.apk!classes2.dex] (com.badlogic.gdx.assets.AssetManager.unload+386)
2020-08-03 15:52:16.366 7850-7850/? A/DEBUG:       #11 pc 00442159  /apex/com.android.runtime/lib/libart.so (MterpInvokeVirtual+1184) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)
2020-08-03 15:52:16.366 7850-7850/? A/DEBUG:       #12 pc 000dc814  /apex/com.android.runtime/lib/libart.so (mterp_op_invoke_virtual+20) (BuildId: 2f1da2282ed9ab3ce5c8d66b2440693c)

Crashes at activity onResume.

pc 000000000022c960 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.Instrumentation.callActivityOnResume+80)
#00 pc 00000000004e21a0 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.Activity.performResume+560)
#00 pc 000000000032a800 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.ActivityThread.performResumeActivity+880)
#00 pc 0000000000327420 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.ActivityThread.handleResumeActivity+256)
#00 pc 0000000000504d48 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.servertransaction.ResumeActivityItem.execute+120)
#00 pc 00000000002558a0 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.servertransaction.TransactionExecutor.executeLifecycleState+384)
#00 pc 0000000000256150 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.servertransaction.TransactionExecutor.execute+1008)
#00 pc 0000000000306f7c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.ActivityThread$H.handleMessage+2044)
#00 pc 000000000054e42c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.os.Handler.dispatchMessage+188)
#00 pc 0000000000551300 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.os.Looper.loopOnce+1072)
#00 pc 0000000000550e34 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.os.Looper.loop+516)
#00 pc 000000000031d094 /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (android.app.ActivityThread.main+948)
#00 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568)
#00 pc 000000000035b5d0 /apex/com.android.art/lib64/libart.so (_jobject* art::InvokeMethod<(art::PointerSize)8>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jobject*, _jobject*, unsigned long)+608)
#00 pc 000000000035b348 /apex/com.android.art/lib64/libart.so (art::Method_invoke(_JNIEnv*, _jobject*, _jobject*, _jobjectArray*)+52)
#00 pc 00000000000b2f74 /apex/com.android.art/javalib/arm64/boot.oat (art_jni_trampoline+132)
#00 pc 000000000089156c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run+140)
#00 pc 0000000000899a0c /data/misc/apexdata/com.android.art/dalvik-cache/arm64/boot-framework.oat (com.android.internal.os.ZygoteInit.main+2620)
#00 pc 00000000002ca9e8 /apex/com.android.art/lib64/libart.so (art_quick_invoke_static_stub+568)
#00 pc 000000000044ca04 /apex/com.android.art/lib64/libart.so (art::JValue art::InvokeWithVarArgs<_jmethodID*>(art::ScopedObjectAccessAlreadyRunnable const&, _jobject*, _jmethodID*, std::__va_list)+464)
#00 pc 000000000062cf30 /apex/com.android.art/lib64/libart.so (art::JNI::CallStaticVoidMethodV(_JNIEnv*, _jclass*, _jmethodID*, std::__va_list)+268)
#00 pc 00000000000b1bf8 /system/lib64/libandroid_runtime.so (_JNIEnv::CallStaticVoidMethod(_jclass*, _jmethodID*, ...)+124)
#00 pc 00000000000bd784 /system/lib64/libandroid_runtime.so (android::AndroidRuntime::start(char const*, android::Vectorandroid::String8 const&, bool)+996)
#00 pc 0000000000002594 /system/bin/app_process64 (main+1340)
#00 pc 0000000000049ee0 /apex/com.android.runtime/lib64/bionic/libc.so (__libc_init+100)

Reduce binary size

As per the current version (0.2.2), the binary size (all ABIs combined) is about 12MB, which is huge. It is 100% possible to reduce that. Three things worth mentioning:

  • There is a binary size optimization flag in the configure script of FFmpeg. It disables performance optimizations, so it can be potentially harmful.
  • Build libgdx-oboe.so with LTO optimizations. I believe, this requires FFmpeg libs to be statically built, but that's not a problem.
  • Incorporate strip as a last built step; however, if I'm not mistaken, the NDK toolchain already does that.

Cannot locate symbol "av_malloc_array" referenced by "libswresample.so"

I have been using version 0.24 for a while now and, for most devices, everything is working great!

However, on some devices, I am getting the following error upon app launch. i.e. app crashes on launch.

Environment:
LibGdx Oboe 0.24, LibGdx 1.9.11

Error Log:

57--------- beginning of crash
5809-14 15:48:17.929 13698 13698 E AndroidRuntime: FATAL EXCEPTION: main
5909-14 15:48:17.929 13698 13698 E AndroidRuntime: Process: com.test.android, PID: 13698
6009-14 15:48:17.929 13698 13698 E AndroidRuntime: java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "av_malloc_array" referenced by "libswresample.so"...
6109-14 15:48:17.929 13698 13698 E AndroidRuntime: at java.lang.Runtime.loadLibrary(Runtime.java:371)
6209-14 15:48:17.929 13698 13698 E AndroidRuntime: at java.lang.System.loadLibrary(System.java:988)
6309-14 15:48:17.929 13698 13698 E AndroidRuntime: at barsoosayque.libgdxoboe.OboeAudio.<init>(OboeAudio.kt:6)
com.test.android.CustomAndroidActivity.onCreate(CustomAndroidActivity.java:1)
6509-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.Activity.performCreate(Activity.java:5990)
6609-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1106)
6709-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2312)
6809-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2421)
6909-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.ActivityThread.access$800(ActivityThread.java:151)
7009-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1333)
7109-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102)
7209-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.os.Looper.loop(Looper.java:135)
7309-14 15:48:17.929 13698 13698 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5288)
7409-14 15:48:17.929 13698 13698 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)
7509-14 15:48:17.929 13698 13698 E AndroidRuntime: at java.lang.reflect.Method.invoke(Method.java:372)
7609-14 15:48:17.929 13698 13698 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1107)
7709-14 15:48:17.929 13698 13698 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:898)
11109-14 15:48:18.247 13751 13751 W linker : libgdx.so: unused DT entry: type 0x6ffffffe arg 0x30d8
11209-14 15:48:18.248 13751 13751 W linker : libgdx.so: unused DT entry: type 0x6fffffff arg 0x2
11309-14 15:48:18.253 13751 13770 W GAv4 : AnalyticsService not registered in the app manifest. Hits might not be delivered reliably. See http://goo.gl/8Rd3yj for instructions.
11409-14 15:48:18.295 13751 13751 W linker : liblibgdx-oboe.so: unused DT entry: type 0x6ffffef5 arg 0x223b0
11509-14 15:48:18.296 13751 13751 W linker : liblibgdx-oboe.so: unused DT entry: type 0x6ffffffe arg 0x2af54
11609-14 15:48:18.297 13751 13751 W linker : liblibgdx-oboe.so: unused DT entry: type 0x6fffffff arg 0x7
11709-14 15:48:18.297 13751 13751 W linker : libswresample.so: unused DT entry: type 0x6ffffef5 arg 0xafc
11809-14 15:48:18.297 13751 13751 W linker : libswresample.so: unused DT entry: type 0x6ffffffe arg 0xed4
11909-14 15:48:18.297 13751 13751 W linker : libswresample.so: unused DT entry: type 0x6fffffff arg 0x3
12009-14 15:48:18.302 13751 13751 E art : dlopen("/data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "av_malloc_array" referenced by "libswresample.so"...
12109-14 15:48:18.302 13751 13751 D AndroidRuntime: Shutting down VM

General volume is lower than on the default libGDX implementation.

I noticed that if I disable Oboe in my project (comment createAudio() method in the AndroidApplication class) the overall audio volume gets much louder (feels like twice as loud).

I couldn't find any master volume parameter in Oboe classes. Is it possible that the master volume is locked to 0.5 by default somewhere down deep in the native code?

Play of sound always return 0.

Hi support team,
After updating the oboe in libgdx 1.9.11, I tried to play the sound and it can work fine but the return of play is always 0.
Ex:
long ret1 = mySound.play(volume); // ret 1 is 0
long ret2 = mySound.play(volume); // ret 2 is 0
// both ret 1 and 2 are 0, they should be different.

Modular OboeAudio

Considering libgdx/libgdx#5985, it will be possible to provide OboeAudio as a module to replace default android audio and preserve all application logic.

This will remove any need in OboeAndroidApplication (which is, essentially, a copy-paste), thus more cleaner and easier usage.

Compiled AAR lib

I just want to place somewhere the compiled AAR library and can not find place better than this. It's build at 08.07.2023 (version 0.2.4?). Author, it's useful to add such files to releases.

If you want to include libgdx-oboe to your project you need to move aar file to libs directory inside your app module and then make sure that build.gradle contains:
implementation fileTree(dir: "libs", include: ["*.aar"])

libgdx-oboe.zip

JNI DETECTED ERROR IN APPLICATION: use of deleted global reference

I have been struggling with this issue for a while.

I have two questions:

  1. What could potentially cause "use of deleted global reference" in libgdx-oboe?

  2. Is there any way to show function name and line number for libgdx-oboe in backtrace?
    For all the other so files, there are function name and lines numbers. But for libgdx-oboe (from #12 to #16), there are no such info. Is there a config that I can set to show such info?

Thanks a lot.

10-23 16:22:20.547 32591 32619 F libc    : Fatal signal 6 (SIGABRT), code -6 in tid 32619 (Thread-1623)
10-23 16:22:20.611   324   324 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
10-23 16:22:20.611   324   324 F DEBUG   : Build fingerprint: 'asus/CN_P024/P024_3:6.0.1/MMB29M/CN_P024-V5.7.3-20161011:user/release-keys'
10-23 16:22:20.611   324   324 F DEBUG   : Revision: '0'
10-23 16:22:20.611   324   324 F DEBUG   : ABI: 'arm'
10-23 16:22:20.612   324   324 F DEBUG   : pid: 32591, tid: 32619, name: Thread-1623  >>> com.xuexue.ai.english.android <<<
10-23 16:22:20.612   324   324 F DEBUG   : signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
10-23 16:22:20.659   324   324 F DEBUG   : Abort message: 'art/runtime/java_vm_ext.cc:410] JNI DETECTED ERROR IN APPLICATION: use of deleted global reference 0x2005aa'
10-23 16:22:20.660   324   324 F DEBUG   :     r0 00000000  r1 00007f6b  r2 00000006  r3 98d63978
10-23 16:22:20.660   324   324 F DEBUG   :     r4 98d63980  r5 98d63930  r6 0000000b  r7 0000010c
10-23 16:22:20.660   324   324 F DEBUG   :     r8 b8870700  r9 b4c37378  sl 00000000  fp 00000000
10-23 16:22:20.660   324   324 F DEBUG   :     ip 00000006  sp 98d63198  lr b6d6bf25  pc b6d6e320  cpsr 40070010
10-23 16:22:20.685   324   324 F DEBUG   : 
10-23 16:22:20.685   324   324 F DEBUG   : backtrace:
10-23 16:22:20.685   324   324 F DEBUG   :     #00 pc 00044320  /system/lib/libc.so (tgkill+12)
10-23 16:22:20.685   324   324 F DEBUG   :     #01 pc 00041f21  /system/lib/libc.so (pthread_kill+32)
10-23 16:22:20.685   324   324 F DEBUG   :     #02 pc 0001ba4f  /system/lib/libc.so (raise+10)
10-23 16:22:20.685   324   324 F DEBUG   :     #03 pc 00018bf1  /system/lib/libc.so (__libc_android_abort+34)
10-23 16:22:20.685   324   324 F DEBUG   :     #04 pc 000167b0  /system/lib/libc.so (abort+4)
10-23 16:22:20.685   324   324 F DEBUG   :     #05 pc 0032140d  /system/lib/libart.so (_ZN3art7Runtime5AbortEv+212)
10-23 16:22:20.685   324   324 F DEBUG   :     #06 pc 000f3cdd  /system/lib/libart.so (_ZN3art10LogMessageD2Ev+2212)
10-23 16:22:20.686   324   324 F DEBUG   :     #07 pc 0024f86d  /system/lib/libart.so (_ZN3art9JavaVMExt8JniAbortEPKcS2_+1524)
10-23 16:22:20.686   324   324 F DEBUG   :     #08 pc 0024fc79  /system/lib/libart.so (_ZN3art9JavaVMExt9JniAbortFEPKcS2_z+68)
10-23 16:22:20.686   324   324 F DEBUG   :     #09 pc 0033e3a7  /system/lib/libart.so (_ZNK3art6Thread13DecodeJObjectEP8_jobject+686)
10-23 16:22:20.686   324   324 F DEBUG   :     #10 pc 000fff25  /system/lib/libart.so (_ZN3art11ScopedCheck5CheckERNS_18ScopedObjectAccessEbPKcPNS_12JniValueTypeE.constprop.95+900)
10-23 16:22:20.686   324   324 F DEBUG   :     #11 pc 00107837  /system/lib/libart.so (_ZN3art8CheckJNI14GetObjectClassEP7_JNIEnvP8_jobject+370)
10-23 16:22:20.686   324   324 F DEBUG   :     #12 pc 00046b33  /data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so
10-23 16:22:20.686   324   324 F DEBUG   :     #13 pc 00045ab7  /data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so
10-23 16:22:20.686   324   324 F DEBUG   :     #14 pc 0004421b  /data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so
10-23 16:22:20.686   324   324 F DEBUG   :     #15 pc 0004409f  /data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so
10-23 16:22:20.686   324   324 F DEBUG   :     #16 pc 0005111d  /data/app/com.test.android-1/lib/arm/liblibgdx-oboe.so
10-23 16:22:20.686   324   324 F DEBUG   :     #17 pc 000085d5  /system/lib/libwilhelm.so
10-23 16:22:20.686   324   324 F DEBUG   :     #18 pc 000609c1  /system/lib/libmedia.so (_ZN7android10AudioTrack18processAudioBufferEv+1232)
10-23 16:22:20.686   324   324 F DEBUG   :     #19 pc 00061631  /system/lib/libmedia.so (_ZN7android10AudioTrack16AudioTrackThread10threadLoopEv+172)
10-23 16:22:20.686   324   324 F DEBUG   :     #20 pc 0001011d  /system/lib/libutils.so (_ZN7android6Thread11_threadLoopEPv+112)
10-23 16:22:20.686   324   324 F DEBUG   :     #21 pc 00041823  /system/lib/libc.so (_ZL15__pthread_startPv+30)
10-23 16:22:20.686   324   324 F DEBUG   :     #22 pc 00019285  /system/lib/libc.so (__start_thread+6)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: Exception dealing with report
10-23 16:22:22.683  1196  2349 E NativeCrashListener: android.system.ErrnoException: read failed: EAGAIN (Try again)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at libcore.io.Posix.readBytes(Native Method)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at libcore.io.Posix.read(Posix.java:169)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at libcore.io.BlockGuardOs.read(BlockGuardOs.java:230)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at android.system.Os.read(Os.java:367)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at com.android.server.am.NativeCrashListener.consumeNativeCrashData(NativeCrashListener.java:240)
10-23 16:22:22.683  1196  2349 E NativeCrashListener: 	at com.android.server.am.NativeCrashListener.run(NativeCrashListener.java:138)

How to add libgdx-oboe to my libgdx project?

Hi,

How can I add this promising tool to my project? I added

@Override public AndroidAudio createAudio(Context context, AndroidApplicationConfiguration config) { return new OboeAudio(context.getAssets()); }

to my AndroidLauncher class, but it says "Cannot resolve symbol 'OboeAudio'" and IntelliJ does not offer any import selection. I tried using https://jitpack.io/#barsoosayque/libgdx-oboe, but no luck. Any hint please?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.