I have 5 characters that make a sound when they run. If they all start running together, I get a bunch of AI_Invalid_Operation errors in the log, and I think not all the clips play.
First question is, how many concurrent sounds (excluding the compressed channel) can I have on iPhone?
Second, is there some mechanism within unity to manage the number of concurrent sounds? Some place I can look to see how many sounds are currently playing?
The messages don’t appear to crash the iPhone, but I sure am nervous about the big red X’s in the log. I just came off a multi day bug hunt that involved crashes happening only on the iPhone, and only intermittently. I don’t want to get into that situation again and yank out the wisps of hair I have remaining.
Any insight would be greatly appreciated.
As many as you want. But the more you have the higher the CPU requirements and memory requirements.
As for sound managing: thats done by OpenAL.
Best place to find something on concurrent sound is the iphone documentation, tech specs and the closed dev boards at apple
I’ve read in a few places that the absolute concurrency limit of the iPhone’s openAL implementation is 32 sounds, but you’re very likely to encounter trouble before then (especially if you’re doing other CPU-intensive things).
I don’t believe there’s a pre-made “numberOfSoundsCurrentlyPlaying” function or anything like that, but you could whip up something like this in a script:
public class SoundCheck : MonoBehaviour {
private AudioSource[] audioSources;
public void Start() {
// Get all existing audio sources
Component[] sources = FindObjectsOfType(typeof(AudioSource));
audioSources = new AudioSource[sources.Length];
sources.CopyTo(audioSources, 0);
// Check how many sounds are playing every second
InvokeRepeating("CurrentlyPlaying", 1f, 1f);
}
public void CurrentlyPlaying() {
int currentlyPlaying = 0;
foreach (AudioSource source in audioSources) {
if (source.isPlaying)
currentlyPlaying++;
}
Debug.Log("Sources currently playing: " + currentlyPlaying);
}
}
If you instantiate new audio sources and such, you’ll need to re-aggregate the audioSources array, of course.
Note: code untested, but hopefully functional 
Thanks! I’ll check that out.