The experimental::AudioEngine definitely has an issue on Android with looping smoothly.
I tested with a 7 second long 44.1KHz 8 bit sample mono wave file on Android 5.0 and 5.1.1. With MP3 or WAV, there is a gap in the restarting of the loop.
I’m using android-ndk-r10d.
When using CocosDenshion::SimpleAudioEngine on Android API 21 and 22 with a looping wav file, I get smooth looping. So CocosDenshion::SimpleAudioEngine seems to work good, but we shouldn’t use SimpleAudioEngine on API 21 and the only way you can is if you change the source code in Cocos2d-x becaue…
In Cocos2d-x 3.7rc0, the SimpleAudioEngine on Android no longer exists if you are running an a API 21 device. Instead you get the experimental AudioEngine.
There was a critical bug that resulted in this change. But I cannot reproduce the bug on 5.0 or 5.1.1. But the bug does say you need 5.0.1. I will test on 5.0.1 soon and add a reply to this thread.
https://github.com/cocos2d/cocos2d-x/pull/12098
https://github.com/cocos2d/cocos2d-x/issues/9911
If I change _implementBaseOnAudioEngine = true to _implementBaseOnAudioEngine = false in the following code located at cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp then the code uses SimpleAudioEngine even on Android 5.0 API 21.
auto sdk_ver = atoi(sdk_ver_str);
__android_log_print(ANDROID_LOG_DEBUG, "cocos2d", "android build version:%d", sdk_ver);
if (sdk_ver == 21)
{
_implementBaseOnAudioEngine = false;
}
When I use an mp3 file with SimpleAudioEngine on Android, I get a popping sound on the restart of the loop. On iOS I get a gap in play. But I am ok with that. Using wav files for loops works good.
If I use the experimental audio engine on either API 21 or API 22, then the loop has a noticeable gap regardless of mp3 of wav.
I made the audio file with Adobe Audition and it is a very smooth loop on Mac, iOS, or Android with the SimpleAudioEngine, so definitely not an issue with the audio file.