[Android] Audio Decoding Issues Discussion

[Android] Audio Decoding Issues Discussion
0.0 0

#61

Solved it, a function was missing and that was causing the lag (getSDKVersion from JNIHelper). Now it works fine in all devices :slight_smile:


#62

Great. :grinning:


#63

I don’t use SimpleAudioEngine at all.
I was wondering if this could be related, for instance if the new AudioEngine used hashmaps as well.
I have no more info on these crahes, I only got them through analytics and had no similar crash on my personal devices…


#64

AudioEngine doesn’t use any java code, it’s implemented in native (cpp). So this crash seems not to be related to AudioEngine.
BTW, could you provide the whole crash stack log? And are you make sure this crash appear in the version of applying my patch?


#65

Here is the stack trace I get:

java.util.ConcurrentModificationException

at java.util.HashMap$HashIterator.nextEntry(HashMap.java:851)
at java.util.HashMap$EntryIterator.next(HashMap.java:891)
at java.util.HashMap$EntryIterator.next(HashMap.java:890)
at org.cocos2dx.lib.Cocos2dxSound.setEffectsVolume(Cocos2dxSound.java:250)
at org.cocos2dx.lib.Cocos2dxHelper.setEffectsVolume(Cocos2dxHelper.java:419)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native Method)
at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(Cocos2dxRenderer.java:104)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1553)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1253)


#66

@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 ?


#67

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


#68

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


#69

@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!


#70

@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.


#71

@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.


Android bad support
#72

@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.


#73

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


#74

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


#75

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


#76

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


#77

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.


#78

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.


#79

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


#80

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