Search code examples
androidoboe

How to load multiple sound with Oboe


I have some issue with Oboe when I trying to load more than 90 - 100 sounds the app Crash with :

Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 32081 (AudioTrack), pid 32003

I have test to play only one of them all and all works fine. It crash only when I try to load a lot of files. For load all of them I juste user an array of Player :

std::array<std::array<std::unique_ptr<Player>, 16>,19> mSoundKit;

mSoundKit[instrument][intensity] = std::make_unique<Player>(mClapSource);

mMixer.addTrack(mSoundKit[instrument][intensity].get());

I try to upgrade the maxTracks of the app :

constexpr uint8_t kMaxTracks = 255;

But I just have a crash now for loading more than 130-140 sounds

The same crash with renderAudio :

mTracks[i]->renderAudio(mixingBuffer, numFrames);

from AudioReady :

mMixer.renderAudio(outputBuffer+(oboeStream->getChannelCount()*i), 1);

I do something wrong ?

I have to load 230 240 sound for play them at same time. Can I have help for that please ?


Solution

  • It's tough to debug your code without seeing a full stack trace and source code (could you post a link to a github project?), however, the most likely cause is that you are dereferencing a null pointer somewhere.

    Some possible causes:

    1. Are you sure kMaxTracks is high enough? You have a 16x19 2D array which equates to 304 possible players. Adding more than kMaxTracks tracks will result in undefined behaviour.
    2. Are the Player objects all successfully created? If not, there's a problem with your source files or the loading process.
    3. How big are these files? You might be running out of memory.