[Android] Audio Decoding Issues Discussion

@dumganhar So I am not the only one getting hash map concurrent modification error, please consider above post.

@atin_agarwal2 do you have a way to reproduce this error ? Do you confirm that you are using the new audio engine too ?

Cocos2dxSound is a class used by SimpleAudioEngine, not AudioEngine. AudioEngine uses cpp code only.

I’m sure it’s a different issue which caused by SimpleAudioEngine.
I send a PR for it

@dumganhar Thanks for your effort!!

I´m currently using v3.13.1 How can I merge your changes into this version?
I normally just use the complete download package to update cocos2d.
So I have no idea how to merge your changes using git…

I dont want to use the zip files in post #3 because it seems you made some changes since then.

Can you halp me please?
Thanks in advance!

@RobinK

Basically, you need to

  • clone the source code of v3 branch on github
  • run python download-deps.py
  • copy cocos/audio/android and replace to your project
  • copy external/android-specific to your project
  • re-compile your project

You probably will meet some compilation errors but i think it’s not difficult to fix.
BTW, we will release v3.15 this month.

@dumganhar

is the problem with limited max instance of AudioEngine fixed? So it should stop older sounds in order to make “room” for the new ones.

@piotrros, I haven’t enough time for doing this refactor.
There is probably an issue about changing the strategy, that’s, there’s no way to distinguish whether an audio is a background music since we should not remove the room of background music.
Currently, maybe we need to check whether the audio is streaming and streaming audio should not be killed while no more rooms for new audios.

Music should be reserved channel and separate functions to play/stop it.

Yep, yep.
A Pull Request for this issue will be appreciated.

I have try this method.
it’s report a bug.

cocos2d::experimental::AudioEngineImpl::init(),line:157,msg:“create opensl engine fail”

the device is vivo x3sw.
android version is 4.2.2

Engine version?
How did you try ?
Is it reproduced on other android devices?

engine version is 3.15.1
just use
AudioEngine::play2d(“background.mp3”, true,1);
in function
AudioEngineImpl::init()
auto result = slCreateEngine(&_engineObject, 0, nullptr, 0, nullptr, nullptr);
the result is SL_RESULT_FEATURE_UNSUPPORTED
so I think this devices is special.
the other devices vivo x5 is ok.

Oops, Vivo sucks. OpenSLES is android standard from Android 2.3.
I think it’s Vivo who removes the module from Android source.
We don’t have a plan to support such non-standard platform.

Hi,

I have made an obb through zip -r main.1.com.test.game.obb * & then i have put it in internal storage & then when i run the apk on device its sound not working.

I am getting this Error.

E/AudioEngineImpl: Failed to open file descriptor for ‘sounds/piano/fa.mp3’
11-24 17:39:52.615 15269-15295/com.test.game
E/AudioPlayerProvider: Failed to open file descriptor for ‘assets/sounds/piano/fa.mp3’
11-24 17:39:52.615 15269-15295/com.test.game
E/AudioPlayerProvider: File info is invalid, path: assets/sounds/piano/fa.mp3

I am using cocos v 3.16 & ndk r12 android - 15

Could you send me a test case for reproducing this issue? Thanks.

Hi,

I am just zipping the folder for my extra games & then putting it in Internal storage /Android/obb/com.test.games/ main.1.com.test.game.obb in the zip i am including sounds & texture in First time testing.

Second time testing i removed the sound & let it go with the apk & inside the obb i just kept the textures.

But in both the cases sound didnt work. When i go to the folder & rename the obb file then sound starts woking for the main scene & all the sounds inside apk & apk is not changed or recompiled.

I have also changed the Android & external.zip folder

Hi, I have updated the cmake to build the vorbis and pvmp3 decoder:

vorbis (put it in the same folder as the android.mk file: external/android-specific/pvmp3dec | tremolo)
https://pastebin.com/n997qPm8

pvmp3
https://pastebin.com/4SyhJVMq

NOTE: for the pvmp3, there are some options in the android.mk file that I don’t know how to translate in CMake language, if anybody could help:

LOCAL_CFLAGS += -Werror
LOCAL_CLANG := true
LOCAL_SANITIZE := signed-integer-overflow
...
LOCAL_ARM_MODE := arm

And if you want to add them to the cocos build, just change the cocos/CMakeLists.txt from

target_link_libraries(cocos2d cocos2dInternal cpufeatures)

to

target_link_libraries(cocos2d cocos2dInternal cpufeatures pvmp3dec vorbisidec)

and add (

if(ANDROID)
  include_directories(../external/android-specific/pvmp3dec/src)
  include_directories(../external/android-specific/pvmp3dec/include)
  include_directories(../external/android-specific/tremolo)
  include_directories(../external/android-specific/tremolo/Tremolo)
endif(ANDROID)

after those line:

  #todo: provide prebuild versions of the xx libs for all platforms
  include_directories(../external/xxtea)
  include_directories(../external/clipper)

it should build the library and put them in (tremolo | pvmp3dec)/library/lib

1 Like

Hi, I have a crash in the engine: