[Android] Audio Decoding Issues Discussion

[Android] Audio Decoding Issues Discussion
0.0 0

#1

Hello Developers,

I’m James Chen, one of the core developers of Cocos2d-x in Chukong Technologies.
Recently, we have released Cocos2d-x v3.13, v3.14. We refactored AudioEngine implementation since v3.13 to resolve high latency while playing audio on some specific Android devices. Thanks to our developers, we received some feedbacks of audio issues. Let me explain more about those issues.

Since Android is Open Source, it has many fragments as it contains different Android versions, thousand of devices by different vendors. Nearly every vendor will modify android source more or less, probably add OMXCodec plugins or modify its implementation.
These fragments make Android audio decoding API (OpenSLES © / SoundPool (java)) not stable enough. Although we have tested a lot on different Android devices with different Android versions before releasing a new Cocos2d-X version, we still encounter with many problems of New AudioEngine. What’s more, audio decoding uses Android System API has very pool performance.

Community have reported some new AudioEngine issues like the following topics:

I checked all of them, analyzed the crash stack or performance issue. In the end, it’s almost the issues of System Audio Decoding API (OpenSLES API or SoundPool).
These issues are extremely hard to be resolved in engine side.

About a month ago, I have an idea that what about we do the decoding work rather than using System Decoding API directly?
In this way, I will be easier to maintain the decoding logic and every devices with different android versions will have the same decoding behavior.

Finally, I took some time to refactor current decoding code, the pull request is here https://github.com/cocos2d/cocos2d-x/pull/17233.
The performance result seems really great.

From the result above:

  • Decoding 101 ogg/mp3 files by 3rd-party decoder on Meizu MX3 (32bit Android 5.0.1, came into market about 3 years ago) is 5x faster than System OpenSLES Decoder, 10x faster than System SoundPool.

  • Decoding 101 ogg/mp3 files by 3rd-party decoder on Nexus 5X (64bit Android 7.1.1, came into market about 1.5 years ago) is 15x faster than System OpenSLES Decoder, 38x faster than System SoundPool.

I uses tremolo (https://android.googlesource.com/platform/external/tremolo.git) for decoding ogg and uses pvmp3dec (https://android.googlesource.com/platform/frameworks/av/+/android-7.1.1_r6/media/libstagefright/codecs/mp3dec/) for decoding mp3.
I think those two decoding libraries are stable enough since they’re used inside Android Source Code.

WHY DO WE GET BETTER PERFORMANCE BY USING 3RD-PARTY DECODING LIBRARIES?

Because OpenSLES or SoundPool Decoding API wastes much time in communicating to system audio service with different process, and this route isn’t well optimized for game. Even worse, lots of vendors will modify source code that make us even more difficult to analyze audio issues.

BUT THERE IS STILL A DRAWBACK (PROBABLY NOT AN ISSUE FOR MOST DEVELOPERS)

My refactoring and improvement of AudioEngine (https://github.com/cocos2d/cocos2d-x/pull/17233) will make your APK size 108K bytes larger.

Dear developers, please help to test this Pull Request, and feel free to give me your feedback or your thought . DO YOU MIND 108K PACKAGE LARGER? :slight_smile:

Thanks a lot.

James


#2

#3

In all seriousness, 108K increased file size is nothing at all when you consider the overall size of the APK.

I would be more than happy to test out the changes, but what is the best way to get the updated files and such? Is there a git command I can use to download all of them? (I rarely use git, which is why I’m asking).


#4

Sure, I have uploaded two zip files here:

android.zip (172.7 KB)
external.zip (314.6 KB)

Steps:

  • Please uses Cocos2d-x 3.13.1 or 3.14.
  • Delete cocos/audio/android folder
  • Extract android.zip (android folder) to cocos/audio/
  • Extract external.zip (tremolo and pvmp3dec folder) to external/
  • Rebuild your project

#5

Thank you for the links. I’ll test the changes out with Cocos2d-x 3.14.


#6

108k increase is no issue at all when you look at the performance upgrade. @dumganhar awesome work! :D.
I’ll be happy to do testing for you.


#7

Hello @dumganhar,

Thanks for your hard work, its about time as i have a game in which i am preloading about 80 sound files as soon as game resources start to load in my loading scene, total size is not more than 2.8MB in total and file format is .mp3.
Its taking about 8-10 seconds to preload these sounds and on Android i am getting following call-stack on Logcat from system :-

01-20 13:07:15.464: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 5
01-20 13:07:15.465: V/ACodec(24900): [OMX.google.mp3.decoder] calling emptyBuffer 4 w/ time 3708000 us
01-20 13:07:15.466: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXEmptyBufferDone 4
01-20 13:07:15.466: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXFillBufferDone 8 time 3708000 us, flags = 0x00000000
01-20 13:07:15.466: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 6
01-20 13:07:15.467: V/ACodec(24900): [OMX.google.mp3.decoder] calling emptyBuffer 1 w/ time 3744000 us
01-20 13:07:15.467: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXEmptyBufferDone 1
01-20 13:07:15.467: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXFillBufferDone 5 time 3744000 us, flags = 0x00000000
01-20 13:07:15.467: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 7
01-20 13:07:15.469: V/ACodec(24900): [OMX.google.mp3.decoder] calling emptyBuffer 2 w/ time 3780000 us
01-20 13:07:15.469: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 8
01-20 13:07:15.470: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXEmptyBufferDone 2
01-20 13:07:15.470: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXFillBufferDone 6 time 3780000 us, flags = 0x00000000
01-20 13:07:15.470: V/ACodec(24900): [OMX.google.mp3.decoder] calling emptyBuffer 3 w/ time 3816000 us
01-20 13:07:15.471: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXEmptyBufferDone 3
01-20 13:07:15.471: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXFillBufferDone 7 time 3816000 us, flags = 0x00000000
01-20 13:07:15.471: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 5
01-20 13:07:15.472: V/ACodec(24900): [OMX.google.mp3.decoder] calling emptyBuffer 4 w/ time 3852000 us
01-20 13:07:15.473: V/ACodec(24900): [OMX.google.mp3.decoder] calling fillBuffer 6
01-20 13:07:15.473: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXEmptyBufferDone 4
01-20 13:07:15.473: V/ACodec(24900): [OMX.google.mp3.decoder] onOMXFillBufferDone 8 time 3852000 us, flags = 0x00000000

more then 5000 lines of it. As my game have many scene created with cocos studio(20+) i am stuck with cocos2d-x 3.10 as of now. I firmly believe it the same issue pointed by @dumganhar.
My development environment and test environment is a follow:-

OS X El Capitan 10.11.6 (15G31)
NDK r10-c
android:minSdkVersion="9" 
and Test device is 
Redmi Note 3(MIUI Global 8.1.1.0)
Android version : 6.0.1

Is there is a way to test new audio engine with cocos2d-x 3.10(Engine version)? NO git

Regards


#8

I’m using cocos studio and managed to migrate to cocos2d-x 3.14 with almost all of my projects.


#9

Please refer to 3rd floor, I have uploaded the zip ball file there.
But it’s based on v3.13 or v3.14.
I guess it’s also easy for integrating it to v3.10. Just have a try. :slight_smile:


#10

Hello @dumganhar,

I did all the above steps and while compiling for android i got these errors for cocos2d-x 3.10

[armeabi] Compile++ thumb: cocos_flatbuffers_static <= idl_gen_fbs.cpp
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In destructor 'virtual CocosDenshion::android::AndroidJavaEngine::~AndroidJavaEngine()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:73:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "end");
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::preloadBackgroundMusic(const char*)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:78:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "preloadBackgroundMusic", fullPath);
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::playBackgroundMusic(const char*, bool)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:83:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "playBackgroundMusic", fullPath, loop);
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::stopBackgroundMusic(bool)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:87:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "stopBackgroundMusic");
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::pauseBackgroundMusic()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:91:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "pauseBackgroundMusic");
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::resumeBackgroundMusic()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:96:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "resumeBackgroundMusic");
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::rewindBackgroundMusic()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:100:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "rewindBackgroundMusic");
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual bool CocosDenshion::android::AndroidJavaEngine::willPlayBackgroundMusic()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:104:12: error: 'callStaticBooleanMethod' is not a member of 'cocos2d::JniHelper'
     return JniHelper::callStaticBooleanMethod(helperClassName, "willPlayBackgroundMusic");
            ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual bool CocosDenshion::android::AndroidJavaEngine::isBackgroundMusicPlaying()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:108:12: error: 'callStaticBooleanMethod' is not a member of 'cocos2d::JniHelper'
     return JniHelper::callStaticBooleanMethod(helperClassName, "isBackgroundMusicPlaying");
            ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual float CocosDenshion::android::AndroidJavaEngine::getBackgroundMusicVolume()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:112:12: error: 'callStaticFloatMethod' is not a member of 'cocos2d::JniHelper'
     return JniHelper::callStaticFloatMethod(helperClassName, "getBackgroundMusicVolume");
            ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::setBackgroundMusicVolume(float)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:116:5: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
     JniHelper::callStaticVoidMethod(helperClassName, "setBackgroundMusicVolume", volume);
     ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual float CocosDenshion::android::AndroidJavaEngine::getEffectsVolume()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:127:16: error: 'callStaticFloatMethod' is not a member of 'cocos2d::JniHelper'
         return JniHelper::callStaticFloatMethod(helperClassName, "getEffectsVolume");
                ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::setEffectsVolume(float)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:155:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "setEffectsVolume", volume);
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual unsigned int CocosDenshion::android::AndroidJavaEngine::playEffect(const char*, bool, float, float, float)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:179:19: error: 'callStaticIntMethod' is not a member of 'cocos2d::JniHelper'
         int ret = JniHelper::callStaticIntMethod(helperClassName, "playEffect", fullPath, loop, pitch, pan, gain);
                   ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::pauseEffect(unsigned int)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:192:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "pauseEffect", (int)soundID);
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::resumeEffect(unsigned int)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:204:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "resumeEffect", (int)soundID);
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::stopEffect(unsigned int)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:217:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "stopEffect", (int)soundID);
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::pauseAllEffects()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:232:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "pauseAllEffects");
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::resumeAllEffects()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:247:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "resumeAllEffects");
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::stopAllEffects()':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:263:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "stopAllEffects");
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::preloadEffect(const char*)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:272:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "preloadEffect", fullPath);
         ^
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp: In member function 'virtual void CocosDenshion::android::AndroidJavaEngine::unloadEffect(const char*)':
/Users/ajaychauhan/Documents/CocosProjects/BingoJazz/proj.android/../cocos2d/cocos/audio/android/jni/cddandroidAndroidJavaEngine.cpp:281:9: error: 'callStaticVoidMethod' is not a member of 'cocos2d::JniHelper'
         JniHelper::callStaticVoidMethod(helperClassName, "unloadEffect", fullPath);

can i have some pointers to resolve it ASAP, Thanks for your support and hard work.

Regards
Ajay


#11

This function seems to be added after v3.10, you could copy that function from v3.14 to v3.10 and have a test again.


#12

@dumganhar Initial impressions of the new code:

  • No more preload and decoding issues with OGG files.
  • No more sound sync issues when using OGG audio format. Sounds were always visibly out of sync with animations in my game, but that issue is gone.
  • Game starts up much quicker than before (roughly 30 audio files, mixed OGG/MP3 are preloaded).

If any specific issue arises, then I’ll post back, but for now this is an amazing change to the Android build. Thank you very much James and anyone else who may have contributed to bringing this to fruition.

If all goes well, how soon will it be before an official release of cocos2d-x is made with this new code?


#13

Hello @dumganhar,
Thanks for the pointer, I did modified the JNI as per the requirements, but still got errors from CCFileUtils-android by tracing back to logs i came to the conclusion that cocos2d-x is now trying to read data from OBB files due to introduction of OBB-File extension support from 3.12(AFAIR). I am a little lost as i have no idea what files were modified to implement OBB support. A pointer here would be much of an help.

Regards
Ajay


#14

Hello,

I’m new with cocos2d-x and currently porting my iOS game. Where I can read documentation about this new AudioEngine? Sample code example? Anything? What I’ve found is only this http://cocos2d-x.org/docs/programmers-guide/audio/index.html

Also, I’m looking for pitch option for sounds and music, is it available?


#15

If you don’t use OBB feature provided by Google Play, you could just disable it since it wasn’t supported in V3.10.

static int fdGetter(const std::string& url, off_t* start, off_t* length)
{
    int fd = -1;
//    if (cocos2d::FileUtilsAndroid::getObbFile() != nullptr)
//    {
//        fd = getObbAssetFileDescriptorJNI(url.c_str(), start, length);
//    } 
//    else
    {
        auto asset = AAssetManager_open(cocos2d::FileUtilsAndroid::getAssetManager(), url.c_str(), AASSET_MODE_UNKNOWN);
        // open asset as file descriptor
        fd = AAsset_openFileDescriptor(asset, start, length);
        AAsset_close(asset);
    }

    if (fd <= 0)
    {
        ALOGE("Failed to open file descriptor for '%s'", url.c_str());
    }

    return fd;
};

#16

It seems that the audio documentation is outdated for a long time. I didn’t find New AudioEngine docs too.
You could just visit the interfaces in AudioEngine.h and find the sample code in cpp-tests/NewAudioEngineTest .


#17

Probably, it will be in v3.15. :slight_smile:


#18

Look at this post: PreloadEffect very slow loading

There’s something wrong with waves.


#19

Ok, and what about pitch?


#20

Is it blocking main thread while loading files? In my game taking some real example I have a scene with several oggs. I don’t have any loading screen, just going there. Usually it was half a second lag before scene loaded, but now it’s much longer. I found out that just preloading isn’t harmful, but if you’d play sound before it’s loaded it’ll freeze game for 1-2 seconds.
In simple audio engine there were a code when after loading sample it checked if it should be played and then it was played.
Can we do something about it?