FluidSynth / fluidsynth

Software synthesizer based on the SoundFont 2 specifications
https://www.fluidsynth.org
GNU Lesser General Public License v2.1
1.89k stars 259 forks source link

Oboe audio driver is not producing any sound in Android #1393

Closed prasenjitghoshcse closed 1 month ago

prasenjitghoshcse commented 1 month ago

FluidSynth version

2.3.6 prebuild library package for Android

Describe the bug

Oboe audio driver is not producing any sound in Android. Even if liboboe.so is excluded in the build script, there is no linking error. Seems OBOE dependency is missing in this version of the package.

Expected behavior

Selecting oboe as audio driver through settings parameters, should use oboe and produce audio in Android.

Steps to reproduce

In CMakeList.txt if I place following block for creating my own library, there is no link failure.

target_link_libraries( native-lib

# Non-fluidsynth binaries
libc++_shared
libomp

# fluidsynth binaries
libFLAC
libfluidsynth
libfluidsynth-assetloader
libgio-2.0
libglib-2.0
libgmodule-2.0
libgobject-2.0
libgthread-2.0
libinstpatch-1.0

liboboe --------- Note oboe is not linked

libogg
libopus
libpcre
libsndfile
libvorbis
libvorbisenc
libvorbisfile

)

Additional context

Following is the full CMakeLists.txt

# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html

# Sets the minimum version of CMake required to build the native library.
cmake_minimum_required(VERSION 3.4.1)

# Create a variable fluidsynth_DIR to specify where the fluidsynth library is located.
set(fluidsynth_DIR ${CMAKE_CURRENT_SOURCE_DIR}/fluidsynth)

# Create a variable lib_other_DIR to specify where the other non-fluidsynth libraries is located.
set(lib_other_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib_other)

# Fluidsynth library code will be calling some non-fluidsynth functions which are not part of
# default NDK, so we add the binaries as dependencies of our code.

add_library(libc++_shared SHARED IMPORTED)
set_target_properties(libc++_shared PROPERTIES IMPORTED_LOCATION ${lib_other_DIR}/${ANDROID_ABI}/libc++_shared.so)

add_library(libomp SHARED IMPORTED)
set_target_properties(libomp PROPERTIES IMPORTED_LOCATION ${lib_other_DIR}/${ANDROID_ABI}/libomp.so)

# Our code (native-lib.cpp) will be calling fluidsynth functions, so adding the fluidsynth binaries as dependencies.

add_library(libFLAC SHARED IMPORTED)
set_target_properties(libFLAC PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libFLAC.so)

add_library(libfluidsynth SHARED IMPORTED)
set_target_properties(libfluidsynth PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libfluidsynth.so)

add_library(libfluidsynth-assetloader SHARED IMPORTED)
set_target_properties(libfluidsynth-assetloader PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libfluidsynth-assetloader.so)

add_library(libgio-2.0 SHARED IMPORTED)
set_target_properties(libgio-2.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libgio-2.0.so)

add_library(libglib-2.0 SHARED IMPORTED)
set_target_properties(libglib-2.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libglib-2.0.so)

add_library(libgmodule-2.0 SHARED IMPORTED)
set_target_properties(libgmodule-2.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libgmodule-2.0.so)

add_library(libgobject-2.0 SHARED IMPORTED)
set_target_properties(libgobject-2.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libgobject-2.0.so)

add_library(libgthread-2.0 SHARED IMPORTED)
set_target_properties(libgthread-2.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libgthread-2.0.so)

add_library(libinstpatch-1.0 SHARED IMPORTED)
set_target_properties(libinstpatch-1.0 PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libinstpatch-1.0.so)

#add_library(liboboe SHARED IMPORTED)
#set_target_properties(liboboe PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/liboboe.so)

add_library(libogg SHARED IMPORTED)
set_target_properties(libogg PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libogg.so)

add_library(libopus SHARED IMPORTED)
set_target_properties(libopus PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libopus.so)

add_library(libpcre SHARED IMPORTED)
set_target_properties(libpcre PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libpcre.so)

add_library(libsndfile SHARED IMPORTED)
set_target_properties(libsndfile PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libsndfile.so)

add_library(libvorbis SHARED IMPORTED)
set_target_properties(libvorbis PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libvorbis.so)

add_library(libvorbisenc SHARED IMPORTED)
set_target_properties(libvorbisenc PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libvorbisenc.so)

add_library(libvorbisfile SHARED IMPORTED)
set_target_properties(libvorbisfile PROPERTIES IMPORTED_LOCATION ${fluidsynth_DIR}/lib/${ANDROID_ABI}/libvorbisfile.so)

# Library that will be called directly from JAVA
add_library(native-lib SHARED native-lib.cpp)

# Specifies the directory where the C or C++ source code will look the #include <yourlibrary.h> header files
target_include_directories(native-lib PRIVATE ${fluidsynth_DIR}/include)

# Link everything all together. Notice that native-lib should be the first element in the list.
target_link_libraries(
    native-lib

    # Non-fluidsynth binaries
    libc++_shared
    libomp

    # fluidsynth binaries
    libFLAC
    libfluidsynth
    libfluidsynth-assetloader
    libgio-2.0
    libglib-2.0
    libgmodule-2.0
    libgobject-2.0
    libgthread-2.0
    libinstpatch-1.0
#    liboboe
    libogg
    libopus
    libpcre
    libsndfile
    libvorbis
    libvorbisenc
    libvorbisfile
)
derselbst commented 1 month ago

The Android binaries were indeed compiled without oboe support. I need to investigate.

Selecting oboe as audio driver through settings parameters, should use oboe and produce audio in Android.

PS: Make sure to evaluate the return value. In this case FLUID_FAILED will be returned, allowing you to handle that error.

derselbst commented 1 month ago

This bug seems to be a regression from da7e0d197ef3ff5a3dfdb09b6242f7db931a7f13. I fixed it, pls try those binaries and let me know if it works again: https://dev.azure.com/tommbrt/tommbrt/_build/results?buildId=10637&view=artifacts&pathAsName=false&type=publishedArtifacts

prasenjitghoshcse commented 1 month ago

Hi, yes, the binaries you provided works. Thanks for your quick help.

Is there going to be any official release? or I should use the binary you provided?

derselbst commented 1 month ago

Ok, great. Fluidsynth 2.3.7 will have binaries as usual. I'll probably take 1-2 weeks until the release.

Thanks for the report!