Fail to play cause by limited max instance of AudioEngine?

Fail to play cause by limited max instance of AudioEngine?
0

#1

I upgraded my project to 3.10 from 3.8 today. Now I see the following output at my console

Fail to play audio/<something>.wav cause by limited max instance of AudioEngine

And audio engine stops playing sound effects. What could be the cause, I can’t find anything on here?

P.S: I’m using CocosDenshion::SimpleudioEngine


#2

Same problem here, but I’m using Cocos2d-x JS and I’m on linux - Ubuntu 15.10.

Anything about this problem?

By the way, as a workaround, now I’m using an array with a limited number of sounds, so I play the same sound (based on the ID) instead of just playing it as a new instance. Current limit: 30 sounds.


#3

I have this same issue in both linux and android builds. Using v3.10
Any suggestions how to handle this?


#4

can you provide any code samples? I haven’t figured it out how to store sound effects.


#5

I’m interested too.

In linux library preload() always create and return new sound channel element for preloaded sound file:

int id = mapChannelInfo.size() + 1;

and new sounds not creating when id > max instance of AudioEngine.

Can try increase max instances with setMaxAudioInstance(), but is bad way.


#6

With v3.8 build, Android 4.4 and 5.1 devices are good but same error occurs on 5.0 with slightly different way. Right after the 32th sound effect plays, AudioEngine is crashing immediately. Even if I play them one by one and make sure there is no sound effect playing simultaneously.

I’m wondering is there any way to play a sound effect from it’s ID, because it seems only way is to play an effect is provide it’s path and AudioEngine creates a new instance of it. And apparently in Android 5.0, these instances remain still in AudioEngine after played.

BTW I’m using ndk r10c and android-19 platform.


#7

Basically, the problem is that once a sound has ended there is no callback to “stop” the sound in cocos audio engine. So, every time I play a sound I keep a reference of its ID with an array. Once the array has reached a certain amount of items. I manually stop the first sound:

// Global variable
var _queue;
var MAX_SOUND_EFFECTS = 20;
        
// get id
if ( _queue.length >= MAX_SOUND_EFFECTS ) {
            
    var idSound = _queue.splice(0,1);
    if ( idSound[0] != undefined ) {
            cc.audioEngine.stopEffect(idSound[0]);    
        }                
    }
        
// Play new andio and keep track of ID
var id = cc.audioEngine.playEffect(url, loop);
_queue.push(id);

This is JavaScript code but C++ solution would look almost the same using maps or arrays.


#8

Same problem still on 3.11. I fix it by some changes in Audio Engine Linux implementation:
I add map that contain all IDs by filenames, and check if exist ID for file.

Also same problem on android, it can be fixed same way.


#9

That is a good idea, thanks for information @jptester, I used it :+1::+1: